From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 813DB256C88 for ; Wed, 24 Dec 2025 14:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766585398; cv=none; b=TLvA+Juo9KInism3cOhsQ+kGTmleI3FQhugLDE9+0FJ+rFFbAaXZ3hiqAlGbvRZwvzErUMe/1RwakYrCJE3549gNp719lWVhnWcrWvgT7IQp2lqvYLMuuaZeXIq46y/7uI1L1vYBM6cpvo+KmpvphdNDGXy7jT49L2IvfQhv1xE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766585398; c=relaxed/simple; bh=4dhafFULqw6oW8gINPt8Ne9SD8tX7xgLhVvVlzoJN30=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FQ98ZTYVdk9epB9F84/VejOaBJCu7mqRt23DCALLGLyv1tCQfekDiDduRb4RkiYHjaiNTpJKMgHdWjDzfkgS+CujQfMnWwTd9UtTdJRv6nlaS1hxZbnoE0lH5M9LWKep6qnUUTl9M8cOb7BOmAWy4MJZeF3rgaXS3wfud930Q80= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E5FA497; Wed, 24 Dec 2025 06:09:48 -0800 (PST) Received: from [10.57.93.190] (unknown [10.57.93.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1C61E3F5A1; Wed, 24 Dec 2025 06:09:52 -0800 (PST) Message-ID: Date: Wed, 24 Dec 2025 14:09:51 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 4/5] arm64: mm: implement the architecture-specific clear_flush_young_ptes() Content-Language: en-GB To: Baolin Wang , akpm@linux-foundation.org, david@kernel.org, catalin.marinas@arm.com, will@kernel.org Cc: lorenzo.stoakes@oracle.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, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 23/12/2025 05:48, Baolin Wang wrote: > Implement the Arm64 architecture-specific clear_flush_young_ptes() to enable > batched checking of young flags and TLB flushing, improving performance during > 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 observe > 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/pgtable.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_area_struct *vma, > return contpte_clear_flush_young_ptes(vma, addr, ptep, CONT_PTES); > } > > +#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 == 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)