linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (Oracle)" <ljs@kernel.org>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: akpm@linux-foundation.org, david@kernel.org,
	Liam.Howlett@oracle.com,  vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com, mhocko@suse.com,
	 linux-arm-kernel@lists.infradead.org, x86@kernel.org,
	linux-parisc@vger.kernel.org,  linuxppc-dev@lists.ozlabs.org,
	linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org,
	 kvm@vger.kernel.org, open <linux-mm@kvack.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] mm: change to return bool for ptep_clear_flush_young()/clear_flush_young_ptes()
Date: Thu, 19 Mar 2026 11:30:29 +0000	[thread overview]
Message-ID: <46390a7c-164c-4ffb-a1b2-fad21e3829df@lucifer.local> (raw)
In-Reply-To: <5d24b34d8b7860dc2188408b3fa530193bcc5caa.1773890510.git.baolin.wang@linux.alibaba.com>

On Thu, Mar 19, 2026 at 11:24:01AM +0800, Baolin Wang wrote:
> The ptep_clear_flush_young() and clear_flush_young_ptes() are used to clear
> the young flag and flush the TLB, returning whether the young flag was set.
> Change the return type to bool to make the intention clearer.
>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>

Couple nits but LGTM, so:

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>

> ---
>  arch/arm64/include/asm/pgtable.h             | 15 +++++++--------
>  arch/arm64/mm/contpte.c                      |  4 ++--
>  arch/parisc/include/asm/pgtable.h            |  2 +-
>  arch/parisc/kernel/cache.c                   |  8 ++++----
>  arch/powerpc/include/asm/nohash/64/pgtable.h |  2 +-
>  arch/riscv/include/asm/pgtable.h             |  4 ++--
>  arch/s390/include/asm/pgtable.h              |  4 ++--
>  arch/x86/include/asm/pgtable.h               |  4 ++--
>  arch/x86/mm/pgtable.c                        |  4 ++--
>  include/linux/pgtable.h                      |  8 ++++----
>  mm/pgtable-generic.c                         |  7 ++++---
>  11 files changed, 31 insertions(+), 31 deletions(-)
>
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index 8c651695204c..393a9d1873f6 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -1299,10 +1299,10 @@ static inline bool __ptep_test_and_clear_young(struct vm_area_struct *vma,
>  	return pte_young(pte);
>  }
>
> -static inline int __ptep_clear_flush_young(struct vm_area_struct *vma,
> -					 unsigned long address, pte_t *ptep)
> +static inline bool __ptep_clear_flush_young(struct vm_area_struct *vma,
> +					    unsigned long address, pte_t *ptep)

I mean this is subjective stuff but can we just put 2nd line 2 tabs indented
underneath? Makes it easier for changes like this to not propagate.

Same comment for all of these!

>  {
> -	int young = __ptep_test_and_clear_young(vma, address, ptep);
> +	bool young = __ptep_test_and_clear_young(vma, address, ptep);
>
>  	if (young) {
>  		/*
> @@ -1648,7 +1648,7 @@ extern pte_t contpte_get_and_clear_full_ptes(struct mm_struct *mm,
>  				unsigned int nr, int full);
>  bool contpte_test_and_clear_young_ptes(struct vm_area_struct *vma,
>  				unsigned long addr, pte_t *ptep, unsigned int nr);
> -int contpte_clear_flush_young_ptes(struct vm_area_struct *vma,
> +bool contpte_clear_flush_young_ptes(struct vm_area_struct *vma,
>  				unsigned long addr, pte_t *ptep, unsigned int nr);
>  extern void contpte_wrprotect_ptes(struct mm_struct *mm, unsigned long addr,
>  				pte_t *ptep, unsigned int nr);
> @@ -1831,7 +1831,7 @@ static inline bool ptep_test_and_clear_young(struct vm_area_struct *vma,
>  }
>
>  #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
> -static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
> +static inline bool ptep_clear_flush_young(struct vm_area_struct *vma,
>  				unsigned long addr, pte_t *ptep)
>  {
>  	pte_t orig_pte = __ptep_get(ptep);
> @@ -1843,9 +1843,8 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
>  }
>
>  #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)
> +static inline bool 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);
> diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c
> index 0b88278927a4..2ef4bff3b998 100644
> --- a/arch/arm64/mm/contpte.c
> +++ b/arch/arm64/mm/contpte.c
> @@ -535,11 +535,11 @@ bool contpte_test_and_clear_young_ptes(struct vm_area_struct *vma,
>  }
>  EXPORT_SYMBOL_GPL(contpte_test_and_clear_young_ptes);
>
> -int contpte_clear_flush_young_ptes(struct vm_area_struct *vma,
> +bool contpte_clear_flush_young_ptes(struct vm_area_struct *vma,
>  				unsigned long addr, pte_t *ptep,
>  				unsigned int nr)
>  {
> -	int young;
> +	bool young;
>
>  	young = contpte_test_and_clear_young_ptes(vma, addr, ptep, nr);
>
> diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
> index d5e39f2eb415..f6984b3ba531 100644
> --- a/arch/parisc/include/asm/pgtable.h
> +++ b/arch/parisc/include/asm/pgtable.h
> @@ -450,7 +450,7 @@ static inline bool ptep_test_and_clear_young(struct vm_area_struct *vma, unsigne
>  	return true;
>  }
>
> -int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
> +bool ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
>  pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
>
>  struct mm_struct;
> diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
> index 4c5240d3a3c7..268530eb107d 100644
> --- a/arch/parisc/kernel/cache.c
> +++ b/arch/parisc/kernel/cache.c
> @@ -781,18 +781,18 @@ void flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned lon
>  	__flush_cache_page(vma, vmaddr, PFN_PHYS(page_to_pfn(page)));
>  }
>
> -int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr,
> -			   pte_t *ptep)
> +bool ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr,
> +			    pte_t *ptep)
>  {
>  	pte_t pte = ptep_get(ptep);
>
>  	if (!pte_young(pte))
> -		return 0;
> +		return false;
>  	set_pte(ptep, pte_mkold(pte));
>  #if CONFIG_FLUSH_PAGE_ACCESSED
>  	__flush_cache_page(vma, addr, PFN_PHYS(pte_pfn(pte)));
>  #endif
> -	return 1;
> +	return true;
>  }
>
>  /*
> diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
> index 2deb955b7bc8..661eb3820d12 100644
> --- a/arch/powerpc/include/asm/nohash/64/pgtable.h
> +++ b/arch/powerpc/include/asm/nohash/64/pgtable.h
> @@ -155,7 +155,7 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
>  #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
>  #define ptep_clear_flush_young(__vma, __address, __ptep)		\
>  ({									\
> -	int __young = ptep_test_and_clear_young(__vma, __address, __ptep);\
> +	bool __young = ptep_test_and_clear_young(__vma, __address, __ptep);\
>  	__young;							\
>  })
>
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index fb010dcdf343..11f57ccf6dc9 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -695,8 +695,8 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,
>  }
>
>  #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
> -static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
> -					 unsigned long address, pte_t *ptep)
> +static inline bool ptep_clear_flush_young(struct vm_area_struct *vma,
> +					  unsigned long address, pte_t *ptep)
>  {
>  	/*
>  	 * This comment is borrowed from x86, but applies equally to RISC-V:
> diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> index da1a7a31fa22..c9ab81caaf75 100644
> --- a/arch/s390/include/asm/pgtable.h
> +++ b/arch/s390/include/asm/pgtable.h
> @@ -1174,8 +1174,8 @@ static inline bool ptep_test_and_clear_young(struct vm_area_struct *vma,
>  }
>
>  #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
> -static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
> -					 unsigned long address, pte_t *ptep)
> +static inline bool ptep_clear_flush_young(struct vm_area_struct *vma,
> +					  unsigned long address, pte_t *ptep)
>  {
>  	return ptep_test_and_clear_young(vma, address, ptep);
>  }
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index 563a6289ea44..554dea93eb99 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -1236,8 +1236,8 @@ extern bool ptep_test_and_clear_young(struct vm_area_struct *vma,
>  				      unsigned long addr, pte_t *ptep);
>
>  #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
> -extern int ptep_clear_flush_young(struct vm_area_struct *vma,
> -				  unsigned long address, pte_t *ptep);
> +extern bool ptep_clear_flush_young(struct vm_area_struct *vma,
> +				   unsigned long address, pte_t *ptep);

Drop extern please!

>
>  #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
>  static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
> diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
> index c594976afc5c..0007dc3d739e 100644
> --- a/arch/x86/mm/pgtable.c
> +++ b/arch/x86/mm/pgtable.c
> @@ -483,8 +483,8 @@ int pudp_test_and_clear_young(struct vm_area_struct *vma,
>  }
>  #endif
>
> -int ptep_clear_flush_young(struct vm_area_struct *vma,
> -			   unsigned long address, pte_t *ptep)
> +bool ptep_clear_flush_young(struct vm_area_struct *vma,
> +			    unsigned long address, pte_t *ptep)
>  {
>  	/*
>  	 * On x86 CPUs, clearing the accessed bit without a TLB flush
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index 8e75dc9f7932..1198e216fde3 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -531,8 +531,8 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
>  #endif
>
>  #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
> -int ptep_clear_flush_young(struct vm_area_struct *vma,
> -			   unsigned long address, pte_t *ptep);
> +bool ptep_clear_flush_young(struct vm_area_struct *vma,
> +			    unsigned long address, pte_t *ptep);
>  #endif
>
>  #ifndef __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
> @@ -1086,10 +1086,10 @@ static inline void wrprotect_ptes(struct mm_struct *mm, unsigned long addr,
>   * Context: The caller holds the page table lock.  The PTEs map consecutive
>   * pages that belong to the same folio.  The PTEs are all in the same PMD.
>   */
> -static inline int clear_flush_young_ptes(struct vm_area_struct *vma,
> +static inline bool clear_flush_young_ptes(struct vm_area_struct *vma,
>  		unsigned long addr, pte_t *ptep, unsigned int nr)
>  {
> -	int young = 0;
> +	bool young = false;
>
>  	for (;;) {
>  		young |= ptep_clear_flush_young(vma, addr, ptep);
> diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
> index af7966169d69..db0ee918b08a 100644
> --- a/mm/pgtable-generic.c
> +++ b/mm/pgtable-generic.c
> @@ -81,10 +81,11 @@ int ptep_set_access_flags(struct vm_area_struct *vma,
>  #endif
>
>  #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
> -int ptep_clear_flush_young(struct vm_area_struct *vma,
> -			   unsigned long address, pte_t *ptep)
> +bool ptep_clear_flush_young(struct vm_area_struct *vma,
> +		unsigned long address, pte_t *ptep)
>  {
> -	int young;
> +	bool young;
> +
>  	young = ptep_test_and_clear_young(vma, address, ptep);
>  	if (young)
>  		flush_tlb_page(vma, address);
> --
> 2.47.3
>


  reply	other threads:[~2026-03-19 11:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19  3:23 [PATCH 0/6] change young flag check functions to return bool Baolin Wang
2026-03-19  3:24 ` [PATCH 1/6] mm: change to return bool for ptep_test_and_clear_young() Baolin Wang
2026-03-19 11:28   ` Lorenzo Stoakes (Oracle)
2026-03-20  2:59     ` Baolin Wang
2026-03-20  5:57   ` Ritesh Harjani
2026-03-21  5:22     ` Baolin Wang
2026-03-19  3:24 ` [PATCH 2/6] mm: change to return bool for ptep_clear_flush_young()/clear_flush_young_ptes() Baolin Wang
2026-03-19 11:30   ` Lorenzo Stoakes (Oracle) [this message]
2026-03-20  3:05     ` Baolin Wang
2026-03-21  5:18   ` Ritesh Harjani
2026-03-19  3:24 ` [PATCH 3/6] mm: change to return bool for pmdp_test_and_clear_young() Baolin Wang
2026-03-19 11:31   ` Lorenzo Stoakes (Oracle)
2026-03-20  3:07     ` Baolin Wang
2026-03-21  5:24   ` Ritesh Harjani
2026-03-19  3:24 ` [PATCH 4/6] mm: change to return bool for pmdp_clear_flush_young() Baolin Wang
2026-03-19 11:33   ` Lorenzo Stoakes (Oracle)
2026-03-20  3:09     ` Baolin Wang
2026-03-19  3:24 ` [PATCH 5/6] mm: change to return bool for pudp_test_and_clear_young() Baolin Wang
2026-03-19 11:34   ` Lorenzo Stoakes (Oracle)
2026-03-21  5:30   ` Ritesh Harjani
2026-03-19  3:24 ` [PATCH 6/6] mm: change to return bool for the MMU notifier's young flag check Baolin Wang
2026-03-19 11:39   ` Lorenzo Stoakes (Oracle)
2026-03-20  3:18     ` Baolin Wang
2026-04-03 23:12       ` Sean Christopherson
2026-04-07  6:23         ` Baolin Wang
2026-04-07 17:52           ` Sean Christopherson
2026-03-20  3:18 ` [PATCH 0/6] change young flag check functions to return bool Andrew Morton
2026-03-20  3:21   ` Baolin Wang
2026-03-21  5:31 ` Ritesh Harjani
2026-03-21 13:02   ` Baolin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46390a7c-164c-4ffb-a1b2-fad21e3829df@lucifer.local \
    --to=ljs@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox