Skip to contentSkip to conversation

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

PATCH In review SeongJae Park 4 participants 4 messages Jan 10, 2023 – Jan 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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.

---
 mm/slab.c | 4 ++--
 mm/slub.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
mm/slab.c +2 -2
index b77be9c6d6b1..a5398676dc60 100644
@@ -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)
mm/slub.c +1 -1
index 67020074ecb4..d5f20c062004 100644
@@ -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)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · SeongJae Park

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.

Thanks, pushed to slab/for-6.3/cleanups

Quoted 40 lines
---
 mm/slab.c | 4 ++--
 mm/slub.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
mm/slab.c +2 -2
index b77be9c6d6b1..a5398676dc60 100644
@@ -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)
mm/slub.c +1 -1
index 67020074ecb4..d5f20c062004 100644
@@ -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 on v1 1/1
#2 lore raw
In reply to SeongJae Park
Quoted 38 lines · SeongJae Park

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.

---
  mm/slab.c | 4 ++--
  mm/slub.c | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)
mm/slab.c +2 -2
index b77be9c6d6b1..a5398676dc60 100644
@@ -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)
mm/slub.c +0 -0
index 67020074ecb4..d5f20c062004 100644

mm/slub.c static void __free_slab(struct kmem_cache *s, struct slab *slab) · line 2072

Quoted 8 lines
mm/slub.c +1 -1
@@ -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)
Signature · 3 lines
Thanks,

David / dhildenb
Acked-by on v1 1/1
#3 lore raw
In reply to SeongJae Park
Quoted 50 lines · SeongJae Park

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.

---
 mm/slab.c | 4 ++--
 mm/slub.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
mm/slab.c +2 -2
index b77be9c6d6b1..a5398676dc60 100644
@@ -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)
mm/slub.c +1 -1
index 67020074ecb4..d5f20c062004 100644
@@ -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)
Signature · 1 line
2.25.1

Thanks!