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 81CEDC25B08 for ; Thu, 18 Aug 2022 01:05:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A40C36B0073; Wed, 17 Aug 2022 21:05:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F07C6B0074; Wed, 17 Aug 2022 21:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B72D8D0002; Wed, 17 Aug 2022 21:05:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 79FD06B0073 for ; Wed, 17 Aug 2022 21:05:52 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4865F406CA for ; Thu, 18 Aug 2022 01:05:52 +0000 (UTC) X-FDA: 79810921344.31.B4615BC Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by imf21.hostedemail.com (Postfix) with ESMTP id 504171C0010 for ; Thu, 18 Aug 2022 01:05:49 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VMYSBOp_1660784746; Received: from 30.97.48.48(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VMYSBOp_1660784746) by smtp.aliyun-inc.com; Thu, 18 Aug 2022 09:05:46 +0800 Message-ID: Date: Thu, 18 Aug 2022 09:05:58 +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: <20220817160902.98613-1-sj@kernel.org> From: Baolin Wang In-Reply-To: <20220817160902.98613-1-sj@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660784750; a=rsa-sha256; cv=none; b=4Rm19EhnQj50QWGS25BsJhKy/pOSEZjTJ9pzW3zibs+tAYiizvZeCi3Y8cPiLv3oQWeGO7 JmuqHo6mZ7SeVeyF3IXnBgD8VNcqzGsuZFiauqHREjEjAzRZl/SZoKvmzAjLk1qhxbx8NV 9zevTnu9WYGYYb9BjuHCLlQ4QXDvBXg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.42 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660784750; 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=4nRbabAkARnSIG+u8FeReuRQmGyah2c7zQ8H9oQgg2s=; b=spL2xqei6BG+CfHLRYCJIx5hwmHPwmh8s9B805q5IGpy1MNSHn4ztaU7pQzou1yqC+dg4k Dk9Cal+k51vRoOl6npovSjM9+EsI0BWAv/9/vURCF9HR3MkuQSJUwv4qy5bsqRxqjrGzFl a5RE9aVSTCAHeQdv7F+ZLEiw6wrVy14= X-Stat-Signature: oyja64bddiriucrc1xrdqx7tjbb49f1f X-Rspamd-Queue-Id: 504171C0010 Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.42 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1660784749-600630 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 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.