From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2CB51DF261 for ; Sat, 28 Feb 2026 20:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772308951; cv=none; b=mYX+2xdRIEx3Aim9YSKp04XgknMvsCC4GwUQgwnvGMS+6RNwPKp5OvTPXeMdT8xz4voxaJQiPXrdTJRoDCAUhoUIiw2BoNUVHKSQlk+AvPr9E8Lsbdj2Z7Cbf/L+I6NI3v9+qGzgYdu/TNv29e/2xpKi0Rj+HXQIIAAjnbaz/f8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772308951; c=relaxed/simple; bh=AvElFMrHbl39hL+WIXWAq9h+zaJGqMDqebPhkQvZnmQ=; h=Date:To:From:Subject:Message-Id; b=IttPDUUmBLjuB5HVj+fNE57f4SSUJusSQpg856ELB1G87OJEBe7ejJ/3+9wfEek1viYXhvCyqxpIbwuNhvbOT9MdA0rxK3as4j2dTGjfEoBNVKIxoVpv+itd5Ym6uN7Lqa0/Z4pFOx6fWyZ2iybG2R/vjtgqh5I1TmntwrQMh8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=zGCJsbZb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="zGCJsbZb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77649C116D0; Sat, 28 Feb 2026 20:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1772308951; bh=AvElFMrHbl39hL+WIXWAq9h+zaJGqMDqebPhkQvZnmQ=; h=Date:To:From:Subject:From; b=zGCJsbZbMzNStO94VPk+Ado/caTg6dlKxT2J+tGVlrq3suN8/UOByLk4xWS+wTjjN OiKEKbno+8iwKmLG0AdgtAsY1AI5nHlMiZVjXriRAnwb/e1T5eIe0a9YVe/HqC41OI TZsNk1vXzTbOOT/OeZ+32dFGc18LMZ6YpeQKzV9Y= Date: Sat, 28 Feb 2026 12:02:30 -0800 To: mm-commits@vger.kernel.org,zhengqi.arch@bytedance.com,yuanchu@google.com,willy@infradead.org,will@kernel.org,weixugc@google.com,vbabka@suse.cz,surenb@google.com,shakeel.butt@linux.dev,ryan.roberts@arm.com,rppt@kernel.org,riel@surriel.com,mhocko@suse.com,lorenzo.stoakes@oracle.com,liam.howlett@oracle.com,jannh@google.com,hannes@cmpxchg.org,dev.jain@arm.com,david@kernel.org,catalin.marinas@arm.com,baohua@kernel.org,axelrasmussen@google.com,apopple@nvidia.com,baolin.wang@linux.alibaba.com,akpm@linux-foundation.org From: Andrew Morton Subject: + arm64-mm-implement-the-architecture-specific-test_and_clear_young_ptes.patch added to mm-new branch Message-Id: <20260228200231.77649C116D0@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: arm64: mm: implement the architecture-specific test_and_clear_young_ptes() has been added to the -mm mm-new branch. Its filename is arm64-mm-implement-the-architecture-specific-test_and_clear_young_ptes.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/arm64-mm-implement-the-architecture-specific-test_and_clear_young_ptes.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Baolin Wang Subject: arm64: mm: implement the architecture-specific test_and_clear_young_ptes() Date: Fri, 27 Feb 2026 17:44:40 +0800 Implement the Arm64 architecture-specific test_and_clear_young_ptes() to enable batched checking of young flags, improving performance during large folio reclamation when MGLRU is enabled. While we're at it, simplify ptep_test_and_clear_young() by calling test_and_clear_young_ptes(). Since callers guarantee that PTEs are present before calling these functions, we can use pte_cont() to check the CONT_PTE flag instead of pte_valid_cont(). Performance testing: Enable MGLRU, then allocate 10G clean file-backed folios by mmap() in a memory cgroup, and try to reclaim 8G file-backed folios via the memory.reclaim interface. I can observe 60%+ performance improvement on my Arm64 32-core server (and about 15% improvement on my X86 machine). W/o patchset: real 0m0.470s user 0m0.000s sys 0m0.470s W/ patchset: real 0m0.180s user 0m0.001s sys 0m0.179s Link: https://lkml.kernel.org/r/5d9298b94607b2bf4f1f92ea29a4c96217c5bcc1.1772185080.git.baolin.wang@linux.alibaba.com Reviewed-by: Rik van Riel Signed-off-by: Baolin Wang Cc: Alistair Popple Cc: Axel Rasmussen Cc: Barry Song Cc: Catalin Marinas Cc: David Hildenbrand (Arm) Cc: Dev Jain Cc: Jann Horn Cc: Johannes Weiner Cc: Liam Howlett Cc: Lorenzo Stoakes Cc: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: Mike Rapoport Cc: Qi Zheng Cc: Ryan Roberts Cc: Shakeel Butt Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Wei Xu Cc: Will Deacon Cc: Yuanchu Xie Signed-off-by: Andrew Morton --- arch/arm64/include/asm/pgtable.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) --- a/arch/arm64/include/asm/pgtable.h~arm64-mm-implement-the-architecture-specific-test_and_clear_young_ptes +++ a/arch/arm64/include/asm/pgtable.h @@ -1812,16 +1812,22 @@ static inline pte_t ptep_get_and_clear(s return __ptep_get_and_clear(mm, addr, ptep); } +#define test_and_clear_young_ptes test_and_clear_young_ptes +static inline int test_and_clear_young_ptes(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep, + unsigned int nr) +{ + if (likely(nr == 1 && !pte_cont(__ptep_get(ptep)))) + return __ptep_test_and_clear_young(vma, addr, ptep); + + return contpte_test_and_clear_young_ptes(vma, addr, ptep, nr); +} + #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { - pte_t orig_pte = __ptep_get(ptep); - - if (likely(!pte_valid_cont(orig_pte))) - return __ptep_test_and_clear_young(vma, addr, ptep); - - return contpte_test_and_clear_young_ptes(vma, addr, ptep, 1); + return test_and_clear_young_ptes(vma, addr, ptep, 1); } #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH _ Patches currently in -mm which might be from baolin.wang@linux.alibaba.com are mm-use-inline-helper-functions-instead-of-ugly-macros.patch mm-rename-ptep-pmdp_clear_young_notify-to-ptep-pmdp_test_and_clear_young_notify.patch mm-rmap-add-a-zone_device-folio-warning-in-folio_referenced.patch mm-add-a-batched-helper-to-clear-the-young-flag-for-large-folios.patch mm-support-batched-checking-of-the-young-flag-for-mglru.patch arm64-mm-implement-the-architecture-specific-test_and_clear_young_ptes.patch