linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mm: minor cleanups in rmap and memory-failure
@ 2025-04-18  7:52 Ye Liu
  2025-04-18  7:52 ` [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency Ye Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Ye Liu @ 2025-04-18  7:52 UTC (permalink / raw)
  To: akpm, linmiaohe, nao.horiguchi; +Cc: linux-mm, linux-kernel, Ye Liu

From: Ye Liu <liuye@kylinos.cn>

Minor cleanups in mm/rmap.c and mm/memory-failure.c:

- Rename a local variable for consistency
- Fix a typo in a comment
- Inline a trivial helper function to its call sites

No functional changes.

Ye Liu (3):
  mm/rmap: rename page__anon_vma to page_anon_vma for consistency
  mm/rmap: fix typo in comment in page_address_in_vma
  mm/memory-failure: inline add_to_kill_anon_file() logic at call sites

 mm/memory-failure.c | 15 ++++-----------
 mm/rmap.c           | 10 +++++-----
 2 files changed, 9 insertions(+), 16 deletions(-)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency
  2025-04-18  7:52 [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Ye Liu
@ 2025-04-18  7:52 ` Ye Liu
  2025-04-18  9:14   ` Lorenzo Stoakes
  2025-04-18  7:52 ` [PATCH 2/3] mm/rmap: fix typo in comment in page_address_in_vma Ye Liu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Ye Liu @ 2025-04-18  7:52 UTC (permalink / raw)
  To: akpm, linmiaohe, nao.horiguchi; +Cc: linux-mm, linux-kernel, Ye Liu

From: Ye Liu <liuye@kylinos.cn>

Renamed local variable page__anon_vma in page_address_in_vma() to
page_anon_vma. The previous naming convention of using double underscores
(__) is unnecessary and inconsistent with typical kernel style, which uses
single underscores to denote local variables. Also updated comments to
reflect the new variable name.

Functionality unchanged.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 mm/rmap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 67bb273dfb80..b509c226e50d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -789,13 +789,13 @@ unsigned long page_address_in_vma(const struct folio *folio,
 		const struct page *page, const struct vm_area_struct *vma)
 {
 	if (folio_test_anon(folio)) {
-		struct anon_vma *page__anon_vma = folio_anon_vma(folio);
+		struct anon_vma *page_anon_vma = folio_anon_vma(folio);
 		/*
 		 * Note: swapoff's unuse_vma() is more efficient with this
 		 * check, and needs it to match anon_vma when KSM is active.
 		 */
-		if (!vma->anon_vma || !page__anon_vma ||
-		    vma->anon_vma->root != page__anon_vma->root)
+		if (!vma->anon_vma || !page_anon_vma ||
+		    vma->anon_vma->root != page_anon_vma->root)
 			return -EFAULT;
 	} else if (!vma->vm_file) {
 		return -EFAULT;
@@ -803,7 +803,7 @@ unsigned long page_address_in_vma(const struct folio *folio,
 		return -EFAULT;
 	}
 
-	/* KSM folios don't reach here because of the !page__anon_vma check */
+	/* KSM folios don't reach here because of the !page_anon_vma check */
 	return vma_address(vma, page_pgoff(folio, page), 1);
 }
 
-- 
2.25.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/3] mm/rmap: fix typo in comment in page_address_in_vma
  2025-04-18  7:52 [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Ye Liu
  2025-04-18  7:52 ` [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency Ye Liu
@ 2025-04-18  7:52 ` Ye Liu
  2025-04-18  9:14   ` Lorenzo Stoakes
  2025-04-18  7:52 ` [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites Ye Liu
  2025-04-18  9:12 ` [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Lorenzo Stoakes
  3 siblings, 1 reply; 10+ messages in thread
From: Ye Liu @ 2025-04-18  7:52 UTC (permalink / raw)
  To: akpm, linmiaohe, nao.horiguchi; +Cc: linux-mm, linux-kernel, Ye Liu

From: Ye Liu <liuye@kylinos.cn>

Fixes a minor typo in the comment above page_address_in_vma():
"responsibililty" → "responsibility"

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 mm/rmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index b509c226e50d..a9eed8981e18 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -774,7 +774,7 @@ static bool should_defer_flush(struct mm_struct *mm, enum ttu_flags flags)
  * @vma: The VMA we need to know the address in.
  *
  * Calculates the user virtual address of this page in the specified VMA.
- * It is the caller's responsibililty to check the page is actually
+ * It is the caller's responsibility to check the page is actually
  * within the VMA.  There may not currently be a PTE pointing at this
  * page, but if a page fault occurs at this address, this is the page
  * which will be accessed.
-- 
2.25.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites
  2025-04-18  7:52 [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Ye Liu
  2025-04-18  7:52 ` [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency Ye Liu
  2025-04-18  7:52 ` [PATCH 2/3] mm/rmap: fix typo in comment in page_address_in_vma Ye Liu
@ 2025-04-18  7:52 ` Ye Liu
  2025-04-18  9:18   ` Lorenzo Stoakes
  2025-04-18  9:12 ` [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Lorenzo Stoakes
  3 siblings, 1 reply; 10+ messages in thread
From: Ye Liu @ 2025-04-18  7:52 UTC (permalink / raw)
  To: akpm, linmiaohe, nao.horiguchi; +Cc: linux-mm, linux-kernel, Ye Liu

From: Ye Liu <liuye@kylinos.cn>

The add_to_kill_anon_file() helper function only checked for -EFAULT
return values before calling __add_to_kill(). Removes the unnecessary
wrapper and moves the addr == -EFAULT checks directly into
collect_procs_anon() and collect_procs_file().

This ensures that error handling is performed close to where the address
is derived (via page_mapped_in_vma() or page_address_in_vma()), rather
than being obscured inside a helper function.

No functional changes are introduced.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 mm/memory-failure.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b91a33fb6c69..ec0041c95b27 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -486,15 +486,6 @@ static void __add_to_kill(struct task_struct *tsk, const struct page *p,
 	list_add_tail(&tk->nd, to_kill);
 }
 
-static void add_to_kill_anon_file(struct task_struct *tsk, const struct page *p,
-		struct vm_area_struct *vma, struct list_head *to_kill,
-		unsigned long addr)
-{
-	if (addr == -EFAULT)
-		return;
-	__add_to_kill(tsk, p, vma, to_kill, addr);
-}
-
 #ifdef CONFIG_KSM
 static bool task_in_to_kill_list(struct list_head *to_kill,
 				 struct task_struct *tsk)
@@ -634,7 +625,8 @@ static void collect_procs_anon(const struct folio *folio,
 			if (vma->vm_mm != t->mm)
 				continue;
 			addr = page_mapped_in_vma(page, vma);
-			add_to_kill_anon_file(t, page, vma, to_kill, addr);
+			if (addr != -EFAULT)
+				__add_to_kill(t, page, vma, to_kill, addr);
 		}
 	}
 	rcu_read_unlock();
@@ -674,7 +666,8 @@ static void collect_procs_file(const struct folio *folio,
 			if (vma->vm_mm != t->mm)
 				continue;
 			addr = page_address_in_vma(folio, page, vma);
-			add_to_kill_anon_file(t, page, vma, to_kill, addr);
+			if (addr != -EFAULT)
+				__add_to_kill(t, page, vma, to_kill, addr);
 		}
 	}
 	rcu_read_unlock();
-- 
2.25.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] mm: minor cleanups in rmap and memory-failure
  2025-04-18  7:52 [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Ye Liu
                   ` (2 preceding siblings ...)
  2025-04-18  7:52 ` [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites Ye Liu
@ 2025-04-18  9:12 ` Lorenzo Stoakes
  3 siblings, 0 replies; 10+ messages in thread
From: Lorenzo Stoakes @ 2025-04-18  9:12 UTC (permalink / raw)
  To: Ye Liu
  Cc: akpm, linmiaohe, nao.horiguchi, linux-mm, linux-kernel, Ye Liu,
	David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Harry Yoo,
	Rik van Riel

Hi Ye,

I asked you in the other thread to cc- rmap stuff to a number of people
while we sort out the MAINTAINERS file, please do try to do so in future. I
caught this due to a lei rule but otherwise we might miss it.

I have added the cc's here for you manually. Thanks!

On Fri, Apr 18, 2025 at 03:52:23PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Minor cleanups in mm/rmap.c and mm/memory-failure.c:
>
> - Rename a local variable for consistency
> - Fix a typo in a comment
> - Inline a trivial helper function to its call sites
>
> No functional changes.
>
> Ye Liu (3):
>   mm/rmap: rename page__anon_vma to page_anon_vma for consistency
>   mm/rmap: fix typo in comment in page_address_in_vma
>   mm/memory-failure: inline add_to_kill_anon_file() logic at call sites
>
>  mm/memory-failure.c | 15 ++++-----------
>  mm/rmap.c           | 10 +++++-----
>  2 files changed, 9 insertions(+), 16 deletions(-)
>
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency
  2025-04-18  7:52 ` [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency Ye Liu
@ 2025-04-18  9:14   ` Lorenzo Stoakes
  2025-04-18  9:37     ` Harry Yoo
  0 siblings, 1 reply; 10+ messages in thread
From: Lorenzo Stoakes @ 2025-04-18  9:14 UTC (permalink / raw)
  To: Ye Liu
  Cc: akpm, linmiaohe, nao.horiguchi, linux-mm, linux-kernel, Ye Liu,
	David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Harry Yoo,
	Rik van Riel

On Fri, Apr 18, 2025 at 03:52:24PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Renamed local variable page__anon_vma in page_address_in_vma() to
> page_anon_vma. The previous naming convention of using double underscores
> (__) is unnecessary and inconsistent with typical kernel style, which uses
> single underscores to denote local variables. Also updated comments to
> reflect the new variable name.
>
> Functionality unchanged.
>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>

Thanks, this looks good. I don't know why we named it this way :)

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

> ---
>  mm/rmap.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 67bb273dfb80..b509c226e50d 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -789,13 +789,13 @@ unsigned long page_address_in_vma(const struct folio *folio,
>  		const struct page *page, const struct vm_area_struct *vma)
>  {
>  	if (folio_test_anon(folio)) {
> -		struct anon_vma *page__anon_vma = folio_anon_vma(folio);
> +		struct anon_vma *page_anon_vma = folio_anon_vma(folio);
>  		/*
>  		 * Note: swapoff's unuse_vma() is more efficient with this
>  		 * check, and needs it to match anon_vma when KSM is active.
>  		 */
> -		if (!vma->anon_vma || !page__anon_vma ||
> -		    vma->anon_vma->root != page__anon_vma->root)
> +		if (!vma->anon_vma || !page_anon_vma ||
> +		    vma->anon_vma->root != page_anon_vma->root)
>  			return -EFAULT;
>  	} else if (!vma->vm_file) {
>  		return -EFAULT;
> @@ -803,7 +803,7 @@ unsigned long page_address_in_vma(const struct folio *folio,
>  		return -EFAULT;
>  	}
>
> -	/* KSM folios don't reach here because of the !page__anon_vma check */
> +	/* KSM folios don't reach here because of the !page_anon_vma check */
>  	return vma_address(vma, page_pgoff(folio, page), 1);
>  }
>
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] mm/rmap: fix typo in comment in page_address_in_vma
  2025-04-18  7:52 ` [PATCH 2/3] mm/rmap: fix typo in comment in page_address_in_vma Ye Liu
@ 2025-04-18  9:14   ` Lorenzo Stoakes
  0 siblings, 0 replies; 10+ messages in thread
From: Lorenzo Stoakes @ 2025-04-18  9:14 UTC (permalink / raw)
  To: Ye Liu
  Cc: akpm, linmiaohe, nao.horiguchi, linux-mm, linux-kernel, Ye Liu,
	David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Harry Yoo,
	Rik van Riel

On Fri, Apr 18, 2025 at 03:52:25PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Fixes a minor typo in the comment above page_address_in_vma():
> "responsibililty" → "responsibility"
>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>

LGTM,

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

> ---
>  mm/rmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index b509c226e50d..a9eed8981e18 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -774,7 +774,7 @@ static bool should_defer_flush(struct mm_struct *mm, enum ttu_flags flags)
>   * @vma: The VMA we need to know the address in.
>   *
>   * Calculates the user virtual address of this page in the specified VMA.
> - * It is the caller's responsibililty to check the page is actually
> + * It is the caller's responsibility to check the page is actually
>   * within the VMA.  There may not currently be a PTE pointing at this
>   * page, but if a page fault occurs at this address, this is the page
>   * which will be accessed.
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites
  2025-04-18  7:52 ` [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites Ye Liu
@ 2025-04-18  9:18   ` Lorenzo Stoakes
  0 siblings, 0 replies; 10+ messages in thread
From: Lorenzo Stoakes @ 2025-04-18  9:18 UTC (permalink / raw)
  To: Ye Liu
  Cc: akpm, linmiaohe, nao.horiguchi, linux-mm, linux-kernel, Ye Liu,
	David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Harry Yoo,
	Rik van Riel

On Fri, Apr 18, 2025 at 03:52:26PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> The add_to_kill_anon_file() helper function only checked for -EFAULT
> return values before calling __add_to_kill(). Removes the unnecessary
> wrapper and moves the addr == -EFAULT checks directly into
> collect_procs_anon() and collect_procs_file().
>
> This ensures that error handling is performed close to where the address
> is derived (via page_mapped_in_vma() or page_address_in_vma()), rather
> than being obscured inside a helper function.

Yeah, no.

You're duplicating logic here (the old classic - what if we change logic in one
call site but not the other etc.) and removing self-documentation of what's
going on here.

This is actually a net negative imo. Please drop this patch from the series +
send a v2 for the 2 good patches (with correct cc's ;)

Thanks!

>
> No functional changes are introduced.
>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
>  mm/memory-failure.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index b91a33fb6c69..ec0041c95b27 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -486,15 +486,6 @@ static void __add_to_kill(struct task_struct *tsk, const struct page *p,
>  	list_add_tail(&tk->nd, to_kill);
>  }
>
> -static void add_to_kill_anon_file(struct task_struct *tsk, const struct page *p,
> -		struct vm_area_struct *vma, struct list_head *to_kill,
> -		unsigned long addr)
> -{
> -	if (addr == -EFAULT)
> -		return;
> -	__add_to_kill(tsk, p, vma, to_kill, addr);
> -}
> -
>  #ifdef CONFIG_KSM
>  static bool task_in_to_kill_list(struct list_head *to_kill,
>  				 struct task_struct *tsk)
> @@ -634,7 +625,8 @@ static void collect_procs_anon(const struct folio *folio,
>  			if (vma->vm_mm != t->mm)
>  				continue;
>  			addr = page_mapped_in_vma(page, vma);
> -			add_to_kill_anon_file(t, page, vma, to_kill, addr);
> +			if (addr != -EFAULT)
> +				__add_to_kill(t, page, vma, to_kill, addr);
>  		}
>  	}
>  	rcu_read_unlock();
> @@ -674,7 +666,8 @@ static void collect_procs_file(const struct folio *folio,
>  			if (vma->vm_mm != t->mm)
>  				continue;
>  			addr = page_address_in_vma(folio, page, vma);
> -			add_to_kill_anon_file(t, page, vma, to_kill, addr);
> +			if (addr != -EFAULT)
> +				__add_to_kill(t, page, vma, to_kill, addr);
>  		}
>  	}
>  	rcu_read_unlock();
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency
  2025-04-18  9:14   ` Lorenzo Stoakes
@ 2025-04-18  9:37     ` Harry Yoo
  2025-04-18  9:42       ` Lorenzo Stoakes
  0 siblings, 1 reply; 10+ messages in thread
From: Harry Yoo @ 2025-04-18  9:37 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Ye Liu, akpm, linmiaohe, nao.horiguchi, linux-mm, linux-kernel,
	Ye Liu, David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
	Rik van Riel

On Fri, Apr 18, 2025 at 10:14:25AM +0100, Lorenzo Stoakes wrote:
> On Fri, Apr 18, 2025 at 03:52:24PM +0800, Ye Liu wrote:
> > From: Ye Liu <liuye@kylinos.cn>
> >
> > Renamed local variable page__anon_vma in page_address_in_vma() to
> > page_anon_vma. The previous naming convention of using double underscores
> > (__) is unnecessary and inconsistent with typical kernel style, which uses
> > single underscores to denote local variables. Also updated comments to
> > reflect the new variable name.
> >
> > Functionality unchanged.
> >
> > Signed-off-by: Ye Liu <liuye@kylinos.cn>
> 
> Thanks, this looks good. I don't know why we named it this way :)

At that time there was page_anon_vma() instead of folio_anon_vma()
so the author couldn't name the variable page_anon_vma :)

-- 
Cheers,
Harry / Hyeonggon

> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>
> > ---
> >  mm/rmap.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/mm/rmap.c b/mm/rmap.c
> > index 67bb273dfb80..b509c226e50d 100644
> > --- a/mm/rmap.c
> > +++ b/mm/rmap.c
> > @@ -789,13 +789,13 @@ unsigned long page_address_in_vma(const struct folio *folio,
> >  		const struct page *page, const struct vm_area_struct *vma)
> >  {
> >  	if (folio_test_anon(folio)) {
> > -		struct anon_vma *page__anon_vma = folio_anon_vma(folio);
> > +		struct anon_vma *page_anon_vma = folio_anon_vma(folio);
> >  		/*
> >  		 * Note: swapoff's unuse_vma() is more efficient with this
> >  		 * check, and needs it to match anon_vma when KSM is active.
> >  		 */
> > -		if (!vma->anon_vma || !page__anon_vma ||
> > -		    vma->anon_vma->root != page__anon_vma->root)
> > +		if (!vma->anon_vma || !page_anon_vma ||
> > +		    vma->anon_vma->root != page_anon_vma->root)
> >  			return -EFAULT;
> >  	} else if (!vma->vm_file) {
> >  		return -EFAULT;
> > @@ -803,7 +803,7 @@ unsigned long page_address_in_vma(const struct folio *folio,
> >  		return -EFAULT;
> >  	}
> >
> > -	/* KSM folios don't reach here because of the !page__anon_vma check */
> > +	/* KSM folios don't reach here because of the !page_anon_vma check */
> >  	return vma_address(vma, page_pgoff(folio, page), 1);
> >  }
> >
> > --
> > 2.25.1
> >


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency
  2025-04-18  9:37     ` Harry Yoo
@ 2025-04-18  9:42       ` Lorenzo Stoakes
  0 siblings, 0 replies; 10+ messages in thread
From: Lorenzo Stoakes @ 2025-04-18  9:42 UTC (permalink / raw)
  To: Harry Yoo
  Cc: Ye Liu, akpm, linmiaohe, nao.horiguchi, linux-mm, linux-kernel,
	Ye Liu, David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
	Rik van Riel

On Fri, Apr 18, 2025 at 06:37:58PM +0900, Harry Yoo wrote:
> On Fri, Apr 18, 2025 at 10:14:25AM +0100, Lorenzo Stoakes wrote:
> > On Fri, Apr 18, 2025 at 03:52:24PM +0800, Ye Liu wrote:
> > > From: Ye Liu <liuye@kylinos.cn>
> > >
> > > Renamed local variable page__anon_vma in page_address_in_vma() to
> > > page_anon_vma. The previous naming convention of using double underscores
> > > (__) is unnecessary and inconsistent with typical kernel style, which uses
> > > single underscores to denote local variables. Also updated comments to
> > > reflect the new variable name.
> > >
> > > Functionality unchanged.
> > >
> > > Signed-off-by: Ye Liu <liuye@kylinos.cn>
> >
> > Thanks, this looks good. I don't know why we named it this way :)
>
> At that time there was page_anon_vma() instead of folio_anon_vma()
> so the author couldn't name the variable page_anon_vma :)

Ahhh mystery__solved! Thanks Harry ;)

>
> --
> Cheers,
> Harry / Hyeonggon
>
> > Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> >
> > > ---
> > >  mm/rmap.c | 8 ++++----
> > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/mm/rmap.c b/mm/rmap.c
> > > index 67bb273dfb80..b509c226e50d 100644
> > > --- a/mm/rmap.c
> > > +++ b/mm/rmap.c
> > > @@ -789,13 +789,13 @@ unsigned long page_address_in_vma(const struct folio *folio,
> > >  		const struct page *page, const struct vm_area_struct *vma)
> > >  {
> > >  	if (folio_test_anon(folio)) {
> > > -		struct anon_vma *page__anon_vma = folio_anon_vma(folio);
> > > +		struct anon_vma *page_anon_vma = folio_anon_vma(folio);
> > >  		/*
> > >  		 * Note: swapoff's unuse_vma() is more efficient with this
> > >  		 * check, and needs it to match anon_vma when KSM is active.
> > >  		 */
> > > -		if (!vma->anon_vma || !page__anon_vma ||
> > > -		    vma->anon_vma->root != page__anon_vma->root)
> > > +		if (!vma->anon_vma || !page_anon_vma ||
> > > +		    vma->anon_vma->root != page_anon_vma->root)
> > >  			return -EFAULT;
> > >  	} else if (!vma->vm_file) {
> > >  		return -EFAULT;
> > > @@ -803,7 +803,7 @@ unsigned long page_address_in_vma(const struct folio *folio,
> > >  		return -EFAULT;
> > >  	}
> > >
> > > -	/* KSM folios don't reach here because of the !page__anon_vma check */
> > > +	/* KSM folios don't reach here because of the !page_anon_vma check */
> > >  	return vma_address(vma, page_pgoff(folio, page), 1);
> > >  }
> > >
> > > --
> > > 2.25.1
> > >


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-04-18  9:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-18  7:52 [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Ye Liu
2025-04-18  7:52 ` [PATCH 1/3] mm/rmap: rename page__anon_vma to page_anon_vma for consistency Ye Liu
2025-04-18  9:14   ` Lorenzo Stoakes
2025-04-18  9:37     ` Harry Yoo
2025-04-18  9:42       ` Lorenzo Stoakes
2025-04-18  7:52 ` [PATCH 2/3] mm/rmap: fix typo in comment in page_address_in_vma Ye Liu
2025-04-18  9:14   ` Lorenzo Stoakes
2025-04-18  7:52 ` [PATCH 3/3] mm/memory-failure: inline add_to_kill_anon_file() logic at call sites Ye Liu
2025-04-18  9:18   ` Lorenzo Stoakes
2025-04-18  9:12 ` [PATCH 0/3] mm: minor cleanups in rmap and memory-failure Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox