From nobody Sun Feb 8 05:29:50 2026 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (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 D7C88280A56 for ; Fri, 26 Dec 2025 06:08:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766729305; cv=none; b=gz7qCR9esnlPDt2rGkOoItmn2zFbYo2ccDK4nFp8l7r/Bq3X5+5i07DFwESdoAKZqAIgM6kNF7jlx0nJfck1wtYvxSPmlJKk3HDjNrNG73rz2i3JJFA1S9FarA85BOPuUkyUs3hR/KvNBXwCfbHTXsNVVMHhw9KUVlNJzX5kfOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766729305; c=relaxed/simple; bh=VHSVTjzKpDH3KUKGinOnHaBhjZLxL8YRaw11218pWCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TUY0jLoxon51aNRwwiQdJcqD9QmzSv6ol3m5/0fbHVxzA2xqv6CclUHfadG5LlmNz7c/BAIh6LTNYXU+TwGVqEq1ysfjqVZvBi9187f85/V3k7SfxpRVCH1abMgne80iMuhoaT1jb0yGQaIDl0YqIszV0HA9gFfFBd30Q2wIWVw= 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=Li39vxjv; arc=none smtp.client-ip=115.124.30.97 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="Li39vxjv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1766729294; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=BnRd4EJWYs/9sCTzmmaNbKrgHdbTp0fWSzYOWQAfVac=; b=Li39vxjv1AV0extfVhIRjLLqV3q06zyPMGS4XS+kxbuBYL1QurXsBD5UsrFHtUH/L3LH6HkVbES1RKD4BHM8lrGSt8gsNo+dsAcYv81Q9vVlXEA+5zpIBj3hVfURKu2a+94fSbVaX0hzSzq1jWGfqKExsuxYbme0d+czgPnTN0s= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WvgaV6i_1766729291 cluster:ay36) by smtp.aliyun-inc.com; Fri, 26 Dec 2025 14:08:12 +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 v5 4/5] arm64: mm: implement the architecture-specific clear_flush_young_ptes() Date: Fri, 26 Dec 2025 14:07:58 +0800 Message-ID: <9d866a2644051e13a41ef4d6ca3909c6e1f9e229.1766631066.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 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 Reviewed-by: Ryan Roberts 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 5e9ff16146c3..aa8f642f1260 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1838,6 +1838,17 @@ static inline int ptep_clear_flush_young(struct vm_a= rea_struct *vma, return contpte_clear_flush_young_ptes(vma, addr, ptep, 1); } =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