From nobody Tue Apr 28 02:37:54 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C69F6C43334 for ; Wed, 8 Jun 2022 08:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230377AbiFHIsj (ORCPT ); Wed, 8 Jun 2022 04:48:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231156AbiFHIsC (ORCPT ); Wed, 8 Jun 2022 04:48:02 -0400 Received: from out199-11.us.a.mail.aliyun.com (out199-11.us.a.mail.aliyun.com [47.90.199.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD1A4253831 for ; Wed, 8 Jun 2022 01:05:54 -0700 (PDT) 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=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VFl.CFb_1654675462; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VFl.CFb_1654675462) by smtp.aliyun-inc.com; Wed, 08 Jun 2022 16:04:22 +0800 From: Baolin Wang To: catalin.marinas@arm.com, will@kernel.org Cc: anshuman.khandual@arm.com, mike.kravetz@oracle.com, songmuchun@bytedance.com, baolin.wang@linux.alibaba.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RESEND PATCH] arm64/hugetlb: Simplify the huge_ptep_set_access_flags() Date: Wed, 8 Jun 2022 16:04:09 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Thus there is no need to check them again when setting the access flags for CONT-PTE/PMD hugetlb in huge_ptep_set_access_flags(), since the original pte value already considered the subpages' dirty and young state by huge_ptep_get(). 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 be failed to monitoring the actual accesses of the CONT-PTE/PMD hugetlb page, due to we can not make its pte old if some subpages are accessing. 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 *v= ma, size_t pgsize =3D 0; unsigned long pfn =3D pte_pfn(pte), dpfn; pgprot_t hugeprot; - pte_t orig_pte; =20 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; =20 - orig_pte =3D 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 =3D pte_mkdirty(pte); - - if (pte_young(orig_pte)) - pte =3D pte_mkyoung(pte); + clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); =20 hugeprot =3D pte_pgprot(pte); for (i =3D 0; i < ncontig; i++, ptep++, addr +=3D pgsize, pfn +=3D dpfn) --=20 1.8.3.1