Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5497970rwb; Wed, 17 Aug 2022 19:45:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wTW/WV3HGbDne4ZUvraQP8/RXaLIMrSTSS+6XucOhCu3JxToCPw53ng+tYMKon9wTAHPZ X-Received: by 2002:a17:907:3da6:b0:739:282d:987f with SMTP id he38-20020a1709073da600b00739282d987fmr559024ejc.222.1660790713043; Wed, 17 Aug 2022 19:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660790713; cv=none; d=google.com; s=arc-20160816; b=f6+uIbYUyOcHyh9uj+AwxNoY37NUQYbzRnKdO4CyhqAcfVNR7MQkS6tBiJPeNK8V4B h8sc03oHc1RUn6rV1TyIpgyUTuXmKJKdtKwdhijdtFTYzn5SVS3R3rn6OlfzCm+BCwYC BnGmIQk6oLzJAEeCEK2gSWPemelnqXoljzpF+B65pIhvQ3EancZ5r8JBr7U+jVT8RbS6 p+OKqjPz1QTM9rB9fxQfnB6I3+NCqbCilXjAGRMppui+eVPgh+pgW8RoTBqwKOATU7pB 5oYqonMBqBwzu1iob8bxRTVxPtLN2ByMqcJEFEwQ9XXA64XnzQeNqFnZ4VBB0EkHBakK Spvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KrNKLeAoD0vtyuYHEkq2DpvCzdxNy73sDnzaAy5WV5c=; b=s2zhfTRWRlfXsHMiuDN2/fyPYj2fnMA10oGwLAhNYnTktspHDtiFON27uo8SKdDuq3 UsuitakR/tsVQhcUkyqDeLiTP8/lu3AuZyDG8c8dPIOYt5RJZ2RQPTLbs3e0u3Lvn1M8 glRR8Uxk5E2L7QpYzPvBXF5zpKNCg4Akbwwh8PMbLbuNR8cdQ3YDi0lBT9X/xMCb6zFo qRBQxtMMuUfifVR0ylqWbdSAp296itzQ+sfI1w3UeOBhHbtO7cjS7myR4anG6EbzWZJa msSGVRTY2X67p6Zi/JAeYxf8JvcGJvmkQyaUPVOUsP5c7uCxMF9gPECtPdxMUIai0flp Xv/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gT4QxK02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv8-20020a17090760c800b007310a8a411csi195064ejc.843.2022.08.17.19.44.21; Wed, 17 Aug 2022 19:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gT4QxK02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242756AbiHRC36 (ORCPT + 99 others); Wed, 17 Aug 2022 22:29:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234779AbiHRC3y (ORCPT ); Wed, 17 Aug 2022 22:29:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113092E6B7 for ; Wed, 17 Aug 2022 19:29:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BC028B81FFF for ; Thu, 18 Aug 2022 02:29:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04E97C433D6; Thu, 18 Aug 2022 02:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660789790; bh=IbHRphQ2b92jhpElJ6AvJaGXNhM8PpSwQuoZJ6b/O7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gT4QxK02c4TRCU8K+zu5foxMlZRli3U213tr9VRnbmnSRuzMsqx7zKZSLeOBXjLO/ XsGCcxtWbe/yQJQGvFni2mbMOVi3xKaxRCWwmiwdy2Nu4eK/ijDzk/1rjfTvJznDvH RnpQGAIDC4uQb/9vCScAv4xA2SH7+Dqy0M9cwObajnk6qAvINSYMt05zJlgX8ZSPxG ICASJVgcB2PS/2J6QSRHbVZNFlEbj8tYkLRy4hEkCZN/xneeDMm0hvV9dbE2JKx12w 1TUHLPfCK4lKmq9B1U7gsIOQzXyrqo4FxYSliRxGvKnWRftwVrMt+cBNedx5k0wbLG IrVmxuryaDpDw== From: SeongJae Park To: Baolin Wang Cc: SeongJae Park , akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/damon: Validate if the pmd entry is present before accessing Date: Thu, 18 Aug 2022 02:29:47 +0000 Message-Id: <20220818022947.94345-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Anyway, Reviewed-by: SeongJae Park Thanks, SJ