Skip to content

Commit b918653

Browse files
Matthew Wilcox (Oracle)tehcaster
authored andcommitted
mm: Convert [un]account_slab_page() to struct slab
Convert the parameter of these functions to struct slab instead of struct page and drop _page from the names. For now their callers just convert page to slab. [ [email protected]: replace existing functions instead of calling them ] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]> Acked-by: Johannes Weiner <[email protected]> Reviewed-by: Roman Gushchin <[email protected]>
1 parent d122019 commit b918653

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

mm/slab.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ static struct page *kmem_getpages(struct kmem_cache *cachep, gfp_t flags,
13801380
return NULL;
13811381
}
13821382

1383-
account_slab_page(page, cachep->gfporder, cachep, flags);
1383+
account_slab(page_slab(page), cachep->gfporder, cachep, flags);
13841384
__SetPageSlab(page);
13851385
/* Record if ALLOC_NO_WATERMARKS was set when allocating the slab */
13861386
if (sk_memalloc_socks() && page_is_pfmemalloc(page))
@@ -1405,7 +1405,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct page *page)
14051405

14061406
if (current->reclaim_state)
14071407
current->reclaim_state->reclaimed_slab += 1 << order;
1408-
unaccount_slab_page(page, order, cachep);
1408+
unaccount_slab(page_slab(page), order, cachep);
14091409
__free_pages(page, order);
14101410
}
14111411

mm/slab.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,24 +583,23 @@ static inline struct kmem_cache *virt_to_cache(const void *obj)
583583
return page->slab_cache;
584584
}
585585

586-
static __always_inline void account_slab_page(struct page *page, int order,
587-
struct kmem_cache *s,
588-
gfp_t gfp)
586+
static __always_inline void account_slab(struct slab *slab, int order,
587+
struct kmem_cache *s, gfp_t gfp)
589588
{
590589
if (memcg_kmem_enabled() && (s->flags & SLAB_ACCOUNT))
591-
memcg_alloc_page_obj_cgroups(page, s, gfp, true);
590+
memcg_alloc_page_obj_cgroups(slab_page(slab), s, gfp, true);
592591

593-
mod_node_page_state(page_pgdat(page), cache_vmstat_idx(s),
592+
mod_node_page_state(slab_pgdat(slab), cache_vmstat_idx(s),
594593
PAGE_SIZE << order);
595594
}
596595

597-
static __always_inline void unaccount_slab_page(struct page *page, int order,
598-
struct kmem_cache *s)
596+
static __always_inline void unaccount_slab(struct slab *slab, int order,
597+
struct kmem_cache *s)
599598
{
600599
if (memcg_kmem_enabled())
601-
memcg_free_page_obj_cgroups(page);
600+
memcg_free_page_obj_cgroups(slab_page(slab));
602601

603-
mod_node_page_state(page_pgdat(page), cache_vmstat_idx(s),
602+
mod_node_page_state(slab_pgdat(slab), cache_vmstat_idx(s),
604603
-(PAGE_SIZE << order));
605604
}
606605

mm/slub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
19431943

19441944
page->objects = oo_objects(oo);
19451945

1946-
account_slab_page(page, oo_order(oo), s, flags);
1946+
account_slab(page_slab(page), oo_order(oo), s, flags);
19471947

19481948
page->slab_cache = s;
19491949
__SetPageSlab(page);
@@ -2014,7 +2014,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
20142014
page->slab_cache = NULL;
20152015
if (current->reclaim_state)
20162016
current->reclaim_state->reclaimed_slab += pages;
2017-
unaccount_slab_page(page, order, s);
2017+
unaccount_slab(page_slab(page), order, s);
20182018
__free_pages(page, order);
20192019
}
20202020

0 commit comments

Comments
 (0)