diff mbox series

mm/sl{a,u}b: fix wrong usages of folio_page() for getting head pages

Message ID 20230110005124.1609-1-sj@kernel.org (mailing list archive)
State New
Headers show
Series mm/sl{a,u}b: fix wrong usages of folio_page() for getting head pages | expand

Commit Message

SeongJae Park Jan. 10, 2023, 12:51 a.m. UTC
The standard idiom for getting head page of a given folio is
'&folio->page', but some are wrongly using 'folio_page(folio, 0)' for
the purpose.  Fix those to use the idiom.

Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/slab.c | 4 ++--
 mm/slub.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Vlastimil Babka Jan. 10, 2023, 2:28 p.m. UTC | #1
On 1/10/23 01:51, SeongJae Park wrote:
> The standard idiom for getting head page of a given folio is
> '&folio->page', but some are wrongly using 'folio_page(folio, 0)' for
> the purpose.  Fix those to use the idiom.
> 
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: SeongJae Park <sj@kernel.org>

Thanks, pushed to slab/for-6.3/cleanups

> ---
>  mm/slab.c | 4 ++--
>  mm/slub.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> index b77be9c6d6b1..a5398676dc60 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1389,7 +1389,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
>  
>  	BUG_ON(!folio_test_slab(folio));
>  	__slab_clear_pfmemalloc(slab);
> -	page_mapcount_reset(folio_page(folio, 0));
> +	page_mapcount_reset(&folio->page);
>  	folio->mapping = NULL;
>  	/* Make the mapping reset visible before clearing the flag */
>  	smp_wmb();
> @@ -1398,7 +1398,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
>  	if (current->reclaim_state)
>  		current->reclaim_state->reclaimed_slab += 1 << order;
>  	unaccount_slab(slab, order, cachep);
> -	__free_pages(folio_page(folio, 0), order);
> +	__free_pages(&folio->page, order);
>  }
>  
>  static void kmem_rcu_free(struct rcu_head *head)
> diff --git a/mm/slub.c b/mm/slub.c
> index 67020074ecb4..d5f20c062004 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2066,7 +2066,7 @@ static void __free_slab(struct kmem_cache *s, struct slab *slab)
>  	if (current->reclaim_state)
>  		current->reclaim_state->reclaimed_slab += pages;
>  	unaccount_slab(slab, order, s);
> -	__free_pages(folio_page(folio, 0), order);
> +	__free_pages(&folio->page, order);
>  }
>  
>  static void rcu_free_slab(struct rcu_head *h)
David Hildenbrand Jan. 10, 2023, 2:41 p.m. UTC | #2
On 10.01.23 01:51, SeongJae Park wrote:
> The standard idiom for getting head page of a given folio is
> '&folio->page', but some are wrongly using 'folio_page(folio, 0)' for
> the purpose.  Fix those to use the idiom.
> 
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
>   mm/slab.c | 4 ++--
>   mm/slub.c | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> index b77be9c6d6b1..a5398676dc60 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1389,7 +1389,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
>   
>   	BUG_ON(!folio_test_slab(folio));
>   	__slab_clear_pfmemalloc(slab);
> -	page_mapcount_reset(folio_page(folio, 0));
> +	page_mapcount_reset(&folio->page);
>   	folio->mapping = NULL;
>   	/* Make the mapping reset visible before clearing the flag */
>   	smp_wmb();
> @@ -1398,7 +1398,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
>   	if (current->reclaim_state)
>   		current->reclaim_state->reclaimed_slab += 1 << order;
>   	unaccount_slab(slab, order, cachep);
> -	__free_pages(folio_page(folio, 0), order);
> +	__free_pages(&folio->page, order);
>   }
>   
>   static void kmem_rcu_free(struct rcu_head *head)
> diff --git a/mm/slub.c b/mm/slub.c
> index 67020074ecb4..d5f20c062004 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2066,7 +2066,7 @@ static void __free_slab(struct kmem_cache *s, struct slab *slab)
>   	if (current->reclaim_state)
>   		current->reclaim_state->reclaimed_slab += pages;
>   	unaccount_slab(slab, order, s);
> -	__free_pages(folio_page(folio, 0), order);
> +	__free_pages(&folio->page, order);
>   }
>   
>   static void rcu_free_slab(struct rcu_head *h)

Reviewed-by: David Hildenbrand <david@redhat.com>
Hyeonggon Yoo Jan. 11, 2023, 9:36 a.m. UTC | #3
On Tue, Jan 10, 2023 at 12:51:24AM +0000, SeongJae Park wrote:
> The standard idiom for getting head page of a given folio is
> '&folio->page', but some are wrongly using 'folio_page(folio, 0)' for
> the purpose.  Fix those to use the idiom.
> 
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
>  mm/slab.c | 4 ++--
>  mm/slub.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> index b77be9c6d6b1..a5398676dc60 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1389,7 +1389,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
>  
>  	BUG_ON(!folio_test_slab(folio));
>  	__slab_clear_pfmemalloc(slab);
> -	page_mapcount_reset(folio_page(folio, 0));
> +	page_mapcount_reset(&folio->page);
>  	folio->mapping = NULL;
>  	/* Make the mapping reset visible before clearing the flag */
>  	smp_wmb();
> @@ -1398,7 +1398,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
>  	if (current->reclaim_state)
>  		current->reclaim_state->reclaimed_slab += 1 << order;
>  	unaccount_slab(slab, order, cachep);
> -	__free_pages(folio_page(folio, 0), order);
> +	__free_pages(&folio->page, order);
>  }
>  
>  static void kmem_rcu_free(struct rcu_head *head)
> diff --git a/mm/slub.c b/mm/slub.c
> index 67020074ecb4..d5f20c062004 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2066,7 +2066,7 @@ static void __free_slab(struct kmem_cache *s, struct slab *slab)
>  	if (current->reclaim_state)
>  		current->reclaim_state->reclaimed_slab += pages;
>  	unaccount_slab(slab, order, s);
> -	__free_pages(folio_page(folio, 0), order);
> +	__free_pages(&folio->page, order);
>  }
>  
>  static void rcu_free_slab(struct rcu_head *h)
> -- 
> 2.25.1
> 
>

Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

Thanks!
diff mbox series

Patch

diff --git a/mm/slab.c b/mm/slab.c
index b77be9c6d6b1..a5398676dc60 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1389,7 +1389,7 @@  static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
 
 	BUG_ON(!folio_test_slab(folio));
 	__slab_clear_pfmemalloc(slab);
-	page_mapcount_reset(folio_page(folio, 0));
+	page_mapcount_reset(&folio->page);
 	folio->mapping = NULL;
 	/* Make the mapping reset visible before clearing the flag */
 	smp_wmb();
@@ -1398,7 +1398,7 @@  static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
 	if (current->reclaim_state)
 		current->reclaim_state->reclaimed_slab += 1 << order;
 	unaccount_slab(slab, order, cachep);
-	__free_pages(folio_page(folio, 0), order);
+	__free_pages(&folio->page, order);
 }
 
 static void kmem_rcu_free(struct rcu_head *head)
diff --git a/mm/slub.c b/mm/slub.c
index 67020074ecb4..d5f20c062004 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2066,7 +2066,7 @@  static void __free_slab(struct kmem_cache *s, struct slab *slab)
 	if (current->reclaim_state)
 		current->reclaim_state->reclaimed_slab += pages;
 	unaccount_slab(slab, order, s);
-	__free_pages(folio_page(folio, 0), order);
+	__free_pages(&folio->page, order);
 }
 
 static void rcu_free_slab(struct rcu_head *h)