From nobody Sun Feb 8 00:12:07 2026 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (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 548982D8797 for ; Fri, 19 Dec 2025 06:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766124197; cv=none; b=lF7bavc8Jvcb2WsWWl66cny1y7TyJXIZt8bT7TdalhdJAMG8JdODQyb5cU+/06RyBxLNSnk9I2TZS432IEAT6b8G7qTTAvGBUz+EKDPEnwyafa6cq6cNj6peTEVELgm81hin4xbyLlcmf4p2GEh9vM861HEKSJxl7mrym7ADkeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766124197; c=relaxed/simple; bh=c+KlqA1uruULKhAZf+QtCVMl6um+QWNXfA+9KAoQjiI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I5VKITc1cjss7HNEGZVzgelleFTZnF/JFoGvYaoPyiANKivkPO/FjxXXctT6aaK3kEkC5X39IRf19F4rJOFxub5hchktCNThhrHA9xxSACbPyJzfCH4HVFoG4yNgPBTFbeyrEUGPKjId6YB6JphxdZUxyuCoCmxXiF4tIrW9J5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=LMjS0eHn; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="LMjS0eHn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1766124191; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=U4MSwdop2NxYytb9NkJpD0u6xgL6N8xbLEBChXF1nyE=; b=LMjS0eHnpR5a/+0HB7vaaEcgPkTdB+GGvR2A2fCgsGF2ga0p49eF1LnyrjEWaNIqEl87APlxmhxczUMuKhmlWWsXXxAXOvlnWykLlHBiSLFZjRIFp+KGtvAYYgzAlir8jzAbHA+5oyY/jciTF/CHJuJSkhRCYWTlTQ/KOMwuWQE= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WvBfipZ_1766124187 cluster:ay36) by smtp.aliyun-inc.com; Fri, 19 Dec 2025 14:03:08 +0800 From: Baolin Wang To: akpm@linux-foundation.org, david@kernel.org, catalin.marinas@arm.com, will@kernel.org Cc: lorenzo.stoakes@oracle.com, ryan.roberts@arm.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, willy@infradead.org, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/5] arm64: mm: implement the architecture-specific clear_flush_young_ptes() Date: Fri, 19 Dec 2025 14:02:54 +0800 Message-ID: <511d0f46d5f02f5e1ecc67318bc2ce8997208c85.1766121341.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Implement the Arm64 architecture-specific clear_flush_young_ptes() to enable batched checking of young flags and TLB flushing, improving performance dur= ing large folio reclamation. Performance testing: 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 obser= ve 33% performance improvement on my Arm64 32-core server (and 10%+ improvement on my X86 machine). Meanwhile, the hotspot folio_check_references() dropped from approximately 35% to around 5%. W/o patchset: real 0m1.518s user 0m0.000s sys 0m1.518s W/ patchset: real 0m1.018s user 0m0.000s sys 0m1.018s Signed-off-by: Baolin Wang --- arch/arm64/include/asm/pgtable.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgta= ble.h index 9086753f68b4..c57eda654d9b 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1869,6 +1869,17 @@ static inline int ptep_clear_flush_young(struct vm_a= rea_struct *vma, return contpte_clear_flush_young_ptes(vma, addr, ptep, CONT_PTES); } =20 +#define clear_flush_young_ptes clear_flush_young_ptes +static inline int clear_flush_young_ptes(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep, + unsigned int nr) +{ + if (likely(nr =3D=3D 1 && !pte_cont(__ptep_get(ptep)))) + return __ptep_clear_flush_young(vma, addr, ptep); + + return contpte_clear_flush_young_ptes(vma, addr, ptep, nr); +} + #define wrprotect_ptes wrprotect_ptes static __always_inline void wrprotect_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned int nr) --=20 2.47.3