From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90051C25B08 for ; Thu, 18 Aug 2022 02:39:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AF428D0002; Wed, 17 Aug 2022 22:39:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15F268D0001; Wed, 17 Aug 2022 22:39:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0261D8D0002; Wed, 17 Aug 2022 22:39:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E56548D0001 for ; Wed, 17 Aug 2022 22:39:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B4895AC0FE for ; Thu, 18 Aug 2022 02:39:52 +0000 (UTC) X-FDA: 79811158224.23.9BF5D54 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf31.hostedemail.com (Postfix) with ESMTP id 6AFBB201DB for ; Thu, 18 Aug 2022 02:39:51 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VMYx6pz_1660790387; Received: from 30.97.48.48(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VMYx6pz_1660790387) by smtp.aliyun-inc.com; Thu, 18 Aug 2022 10:39:47 +0800 Message-ID: Date: Thu, 18 Aug 2022 10:39:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] mm/damon: Validate if the pmd entry is present before accessing To: SeongJae Park Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220818022947.94345-1-sj@kernel.org> From: Baolin Wang In-Reply-To: <20220818022947.94345-1-sj@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=none; spf=pass (imf31.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660790392; a=rsa-sha256; cv=none; b=yXP36GshenRR0mY3eDi5b6mUtQ+O+bfAtA3BxMGblaTtUxU1V3NxRwYKwi9ho7+jdGtVZC CGJ5HJciGGweWNMI1U3mJTWvBrsrbIpZLOYVt9kTu4SI301OGBQ8Kkec1LlxTb0N4SSEaD Yh3Nao4aOLnfTHMvsOcNRDYIpgx6lZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660790392; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R4OYfwJptoC45HbP003TZExts/dieC9FPDVe/vMcjIs=; b=0FxE2ps5b00BRVuaVyH6jRVLDX5axuhVsjuaiTQ6TdAMg/FM+oXwxPjtKT8RvtDc7llX/k vIe7kBu3LUFq3/p5AHCBKVXfaqR3/SZT4zsKIqyYJvK+W12Kwm0BuSW+rKzLHEpX8KD9v8 HBEa0krv/KsuE7Aq7o8zucs82X+3iX4= Authentication-Results: imf31.hostedemail.com; dkim=none; spf=pass (imf31.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Stat-Signature: p7rcbqx3pkpu4xkramun388okp5pmme7 X-Rspamd-Queue-Id: 6AFBB201DB X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1660790391-107854 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 8/18/2022 10:29 AM, SeongJae Park wrote: > Hi Baolin, > > On Thu, 18 Aug 2022 09:05:58 +0800 Baolin Wang wrote: > >> >> >> On 8/18/2022 12:09 AM, SeongJae Park wrote: >>> Hi Baolin, >>> >>> >>> Thank you always for your great patch! >>> >>> On Wed, 17 Aug 2022 14:21:12 +0800 Baolin Wang wrote: >>> >>>> The pmd_huge() is used to validate if the pmd entry is mapped by a huge >>>> page, also including the case of non-present (migration or hwpoisoned) >>>> pmd entry on arm64 or x86 architectures. Thus we should validate if it >>>> is present before making the pmd entry old or getting young state, >>>> otherwise we can not get the correct corresponding page. >>> >>> Maybe I'm missing something, but... I'm unsure if the page is present or not >>> really matters from the perspective of access checking. In the case, DAMON >>> could simply report the page has accessed once for the first check after the >>> page being non-present if it really accessed before, and then report the page >>> as not accessed, which is true. >> >> Yes, that's the patch's goal to make the accesses correct. However if >> the PMD entry is not present, we can not get the correct page object by >> pmd_pfn(*pmd), since the non-present pmd entry will contain swap type >> and swap offset with below format on ARM64, that means the pfn number is >> saved in bits 8-57 in a migration or poisoned entry, but pmd_pfn() still >> treat bits 12-47 as the pfn number on ARM64, which may get an incorrect >> page struct (also maybe is NULL by pfn_to_online_page()) to make the >> access statistics incorrect. >> >> /* >> * Encode and decode a swap entry: >> * bits 0-1: present (must be zero) >> * bits 2: remember PG_anon_exclusive >> * bits 3-7: swap type >> * bits 8-57: swap offset >> * bit 58: PTE_PROT_NONE (must be zero) >> */ >> >> >> Moreoever I don't think we should still waste time to get the page of >> the non-present entry, just treat it as not-accessed and skip it, that >> keeps consistent with non-present pte level entry. >> >> Does that make sense for you? Thanks. > > Yes, that totally makes sense. Thank you very much for the kind answer. I > think it would be great if we could put the detailed explanation in the commit > message. Could you please update the commit message and post v2 of the patch? Sure, will update the commit message to make it more clear and I think that can also answer Andrew's concern. > > Reviewed-by: SeongJae Park Thanks.