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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 938D0C43334 for ; Thu, 9 Jun 2022 15:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jnK4vITlgfGyFC7GnhLctoT1CPOsqLClQbW/rtjcEnE=; b=bLQIpn2IjXYohZ 2v92K2S3xdkO7v0P/mrA5ytJZgJJ86YKls/ESYQhPkOa87R1jHcUsyTfSPUOMp7NnFdlPlkeph+Xu qv4cf2D8XthAP+O22CYWv1qYh0a1uMy/QbBVMEHGbx7liXr9zPdcfEmLCw+3uQvFVmLSVJ5iPhjks wXmcpePWsrhp9fiJVxGN+V+ybzjGhysUNb9WlJ1muQKpyqLUbyjJ98MGLrwnEiRII6PySTImv1FTQ P2qlBq/l8y678a/Eac7Ty9s7poM63bVlo79cX+PERkcdNUg2Wg37Ilam/hEAXhbAvHyi8+ECbKNwi O5Lmsz4p/CMWyud37/bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzKLA-002lgj-Kd; Thu, 09 Jun 2022 15:44:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzKL7-002leh-9W for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2022 15:44:54 +0000 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_084453_456151_CD050D88 X-CRM114-Status: GOOD ( 25.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel