From nobody Sun Feb 8 03:57:36 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 EC40B2F6925 for ; Tue, 23 Dec 2025 05:48:59 +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=1766468942; cv=none; b=odvr24WdA/ixH+zcDL9n6jnW1bG2l3ZIbpHP11hkOdIU+VyUUoE/6lKvfhsGWYpmF1XXR+YPmrvXspkW4DeEsY0egnpBGL8myi3tKYmQ4uaEHyuYOtl4GXkuNyNW02Pm2y/BXmJibkS2FO4lb/AB8UGDZk9bYDYYrJr3r0rrjY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766468942; c=relaxed/simple; bh=AbpNJ53XiNQB+ihBMnJB1YHaPI4D8/93a/l9IvJQhA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DYHGPRwR0TkZNNUB9uXusS+gGqfKz82wO00m0dtD3WdbvV0AukrINk1dpdoh01XWdhZ+U9gSLT9GMuDJ6658YpC3LZoi0PEqVl70U0g6D87P9MWlzM0ExuYYapX2aJoeNZT8v9F+LnmcasCHm0YCrJpiB2DLsdDjz+5+YUKeUPo= 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=fs9aGpkC; 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="fs9aGpkC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1766468932; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=PtUq0ncq36I/75r0SFbFKqq7ZzUUx0G3Kvd2RjStNxc=; b=fs9aGpkCNiPUE/ARJ2RUEyvJpl4LC+hgxSZ7OMFxVLYU9mgcQN3DSImnaRwK+18jqNRofMcxyybIpNekJSpK8P55Bc3pN8DvWV0fyyfFheb/aIxZSZ5heIqnY2/dwnXchFiLUWV0pLs6WWT4paDzxdFjEeEAC9YRXIoqbZ9KAW4= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WvWaJjs_1766468930 cluster:ay36) by smtp.aliyun-inc.com; Tue, 23 Dec 2025 13:48:50 +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 v4 4/5] arm64: mm: implement the architecture-specific clear_flush_young_ptes() Date: Tue, 23 Dec 2025 13:48:38 +0800 Message-ID: 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 Reviewed-by: Ryan Roberts --- 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 d5fbe72e820a..84a6bdabb1f9 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, 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