Skip to content

Commit

Permalink
mm: slub: call account_slab_page() after slab page initialization
Browse files Browse the repository at this point in the history
It's convenient to have page->objects initialized before calling into
account_slab_page().  In particular, this information can be used to
pre-alloc the obj_cgroup vector.

Let's call account_slab_page() a bit later, after the initialization of
page->objects.

This commit doesn't bring any functional change, but is required for
further optimizations.

[[email protected]: undo changes needed by forthcoming mm-memcg-slab-pre-allocate-obj_cgroups-for-slab-caches-with-slab_account.patch]

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Roman Gushchin <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Reviewed-by: Shakeel Butt <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Christoph Lameter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rgushchin authored and torvalds committed Dec 29, 2020
1 parent 605cc30 commit 1f3147b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,6 @@ static inline struct page *alloc_slab_page(struct kmem_cache *s,
else
page = __alloc_pages_node(node, flags, order);

if (page)
account_slab_page(page, order, s);

return page;
}

Expand Down Expand Up @@ -1774,6 +1771,8 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)

page->objects = oo_objects(oo);

account_slab_page(page, oo_order(oo), s);

page->slab_cache = s;
__SetPageSlab(page);
if (page_is_pfmemalloc(page))
Expand Down

0 comments on commit 1f3147b

Please sign in to comment.