Skip to content

Commit 0028517

Browse files
committed
Merge branch 'slab/for-6.3/cleanups' into slab/for-linus
A bunch of cleanups for SLAB and SLUB: - Use the standard idiom to get head page of folio (by SeongJae Park) - Simplify and inline is_debug_pagealloc_cache() in SLAB (by lvqian) - Remove unused variable in SLAB (by Gou Hao)
2 parents cc2e9d2 + 81ce2eb commit 0028517

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

mm/slab.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ static inline void fixup_objfreelist_debug(struct kmem_cache *cachep,
220220
static inline void fixup_slab_list(struct kmem_cache *cachep,
221221
struct kmem_cache_node *n, struct slab *slab,
222222
void **list);
223-
static int slab_early_init = 1;
224223

225224
#define INDEX_NODE kmalloc_index(sizeof(struct kmem_cache_node))
226225

@@ -1249,8 +1248,6 @@ void __init kmem_cache_init(void)
12491248
slab_state = PARTIAL_NODE;
12501249
setup_kmalloc_cache_index_table();
12511250

1252-
slab_early_init = 0;
1253-
12541251
/* 5) Replace the bootstrap kmem_cache_node */
12551252
{
12561253
int nid;
@@ -1389,7 +1386,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
13891386

13901387
BUG_ON(!folio_test_slab(folio));
13911388
__slab_clear_pfmemalloc(slab);
1392-
page_mapcount_reset(folio_page(folio, 0));
1389+
page_mapcount_reset(&folio->page);
13931390
folio->mapping = NULL;
13941391
/* Make the mapping reset visible before clearing the flag */
13951392
smp_wmb();
@@ -1398,7 +1395,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct slab *slab)
13981395
if (current->reclaim_state)
13991396
current->reclaim_state->reclaimed_slab += 1 << order;
14001397
unaccount_slab(slab, order, cachep);
1401-
__free_pages(folio_page(folio, 0), order);
1398+
__free_pages(&folio->page, order);
14021399
}
14031400

14041401
static void kmem_rcu_free(struct rcu_head *head)
@@ -1413,13 +1410,10 @@ static void kmem_rcu_free(struct rcu_head *head)
14131410
}
14141411

14151412
#if DEBUG
1416-
static bool is_debug_pagealloc_cache(struct kmem_cache *cachep)
1413+
static inline bool is_debug_pagealloc_cache(struct kmem_cache *cachep)
14171414
{
1418-
if (debug_pagealloc_enabled_static() && OFF_SLAB(cachep) &&
1419-
(cachep->size % PAGE_SIZE) == 0)
1420-
return true;
1421-
1422-
return false;
1415+
return debug_pagealloc_enabled_static() && OFF_SLAB(cachep) &&
1416+
((cachep->size % PAGE_SIZE) == 0);
14231417
}
14241418

14251419
#ifdef CONFIG_DEBUG_PAGEALLOC

mm/slub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ static void __free_slab(struct kmem_cache *s, struct slab *slab)
20662066
if (current->reclaim_state)
20672067
current->reclaim_state->reclaimed_slab += pages;
20682068
unaccount_slab(slab, order, s);
2069-
__free_pages(folio_page(folio, 0), order);
2069+
__free_pages(&folio->page, order);
20702070
}
20712071

20722072
static void rcu_free_slab(struct rcu_head *h)

0 commit comments

Comments
 (0)