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 A3240C43334 for ; Thu, 9 Jun 2022 15:44:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C01C8D002A; Thu, 9 Jun 2022 11:44:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06F798D0022; Thu, 9 Jun 2022 11:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E78A58D002A; Thu, 9 Jun 2022 11:44:47 -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 D50258D0022 for ; Thu, 9 Jun 2022 11:44:47 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B24BB32B8B for ; Thu, 9 Jun 2022 15:44:47 +0000 (UTC) X-FDA: 79559120214.06.2D7DB2A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 3744180071 for ; Thu, 9 Jun 2022 15:44:47 +0000 (UTC) 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 dfw.source.kernel.org (Postfix) with ESMTPS id BDAE561F38; Thu, 9 Jun 2022 15:44:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88A0CC34114; Thu, 9 Jun 2022 15:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654789484; bh=X32KAVJGD/FwLau5Ef5i2Ezt7M4IokoLndTY3ECDt7M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GciSWBOzy3fCiZevlR74T0Zp5Pe3pQp/56aaAN5ZTdbtF8BxCYv37C3foVv4SfjdC Bh48K/4IE55rmBxz1Xf1DnaHAPnVlKIUry/9mbiY0+/3qnKS+U915CxDBL/aABi9Y6 xmOnIRtW07+CgS72vEicSxNXBuVyi1w6rZzgU7GdWZdCbMM5uJXZaUsAHS7n3Uzco5 Ch+i7qIn44isV8kq/rCQkivL5BYUNl/43wDkHFq9IVpJ5TDcBYtfFX7OUz42UVZDpj F288nHIkx2pZc2xUNnDspU5STO2RwjRi8VVrQIADqOsPtPrdcdMGLBw0LGwYDtk1dx vG4QIfW+jQ/ew== Date: Thu, 9 Jun 2022 16:44:38 +0100 From: Will Deacon To: Baolin Wang Cc: catalin.marinas@arm.com, mike.kravetz@oracle.com, songmuchun@bytedance.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] arm64/hugetlb: Simplify the huge_ptep_set_access_flags() Message-ID: <20220609154438.GA3444@willie-the-truck> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654789487; a=rsa-sha256; cv=none; b=Vq7d5DRRRf9+medXJXypjDBj9HzGpoB9Hdy57DsKJ6OcWmCBl2z5U9XJ+kzSryhJjuKNh7 fXVRW4pp/y1MBWINg9XxD95090SCgDePMSVJiWuNFjKx3LCELspGRshGfopNie8rtBKQal LHKJEGDL1kYqFav8cmLLys73ZoV+f+o= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GciSWBOz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654789487; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MRfZo2qlYkOJkQYMo1Za4m9w3jfxytGqW9LNzA8qhV4=; b=BC0zs9+ieWjl5I7eu6tUd8u+34mAkjUn5dxPaNfl1bYhV11sK6p1MbSpV7hIMD+9fDYL+O NGR/GPSXaKYJXCCMoLq2IDdq5mdlT/bQinQQu+9csMc17g00YFjU67b7Wjzk9JTtjSZ0Kj bPK7WLvAUcqAq0moBzSLknZOJLspck0= X-Stat-Signature: g8czcu4ifmfn5ey6ba5ytuawqfe8pj9j X-Rspam-User: X-Rspamd-Queue-Id: 3744180071 X-Rspamd-Server: rspam07 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GciSWBOz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org X-HE-Tag: 1654789487-947754 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 Wed, May 25, 2022 at 06:31:09PM +0800, Baolin Wang wrote: > After commit bc5dfb4fd7bd ("arm64/hugetlb: Implement arm64 specific > huge_ptep_get()"), the arm64 specific huge_ptep_get() will always > consider the subpages' dirty and young state for CONT-PTE/PMD hugetlb, > so there is no need to check them again when setting the access flags > for CONT-PTE/PMD hugetlb in huge_ptep_set_access_flags(). > > Meanwhile this also fixes an issue when users want to make the CONT-PTE/PMD > hugetlb's pte entry old, which will be failed to make the pte entry old > since the original code will always consider the subpages' young state > if the subpages' young state is set. For example, we will make the > CONT-PTE/PMD hugetlb pte entry old in DAMON to monitoring the accesses, > but we'll failed to monitoring the actual accesses of the CONT-PTE/PMD > hugetlb page, due to we can not make its pte old. > > Thus remove the code considering the subpages' dirty and young state in > huge_ptep_set_access_flags() to fix this issue and simplify the function. > > Signed-off-by: Baolin Wang > --- > arch/arm64/mm/hugetlbpage.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > index e2a5ec9..5c703aa 100644 > --- a/arch/arm64/mm/hugetlbpage.c > +++ b/arch/arm64/mm/hugetlbpage.c > @@ -448,7 +448,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, > size_t pgsize = 0; > unsigned long pfn = pte_pfn(pte), dpfn; > pgprot_t hugeprot; > - pte_t orig_pte; > > if (!pte_cont(pte)) > return ptep_set_access_flags(vma, addr, ptep, pte, dirty); > @@ -459,14 +458,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, > if (!__cont_access_flags_changed(ptep, pte, ncontig)) > return 0; > > - orig_pte = get_clear_contig(vma->vm_mm, addr, ptep, pgsize, ncontig); > - > - /* Make sure we don't lose the dirty or young state */ > - if (pte_dirty(orig_pte)) > - pte = pte_mkdirty(pte); > - > - if (pte_young(orig_pte)) > - pte = pte_mkyoung(pte); > + clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); I don't understand what this clear_flush() call is doing here; notably, it includes TLB invalidation which we don't have for the non-cont case. Why isn't huge_ptep_set_access_flags() just a loop around ptep_set_access_flags() if huge_ptep_get() is taking care of collapsing the dirty/young state? Will