diff mbox series

[1/2] mm: slub: call account_slab_page() after slab page initialization

Message ID 20201110195753.530157-1-guro@fb.com (mailing list archive)
State New, archived
Headers show
Series [1/2] mm: slub: call account_slab_page() after slab page initialization | expand

Commit Message

Roman Gushchin Nov. 10, 2020, 7:57 p.m. UTC
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.

Signed-off-by: Roman Gushchin <guro@fb.com>
---
 mm/slub.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Johannes Weiner Nov. 12, 2020, 3:18 p.m. UTC | #1
On Tue, Nov 10, 2020 at 11:57:52AM -0800, Roman Gushchin wrote:
> 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.
> 
> Signed-off-by: Roman Gushchin <guro@fb.com>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Shakeel Butt Nov. 17, 2020, 5:16 p.m. UTC | #2
On Tue, Nov 10, 2020 at 11:58 AM Roman Gushchin <guro@fb.com> wrote:
>
> 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.
>
> Signed-off-by: Roman Gushchin <guro@fb.com>

Reviewed-by: Shakeel Butt <shakeelb@google.com>
diff mbox series

Patch

diff --git a/mm/slub.c b/mm/slub.c
index 8c9fa24ebbf3..ccdbb62e025d 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1622,9 +1622,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;
 }
 
@@ -1777,6 +1774,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, flags);
+
 	page->slab_cache = s;
 	__SetPageSlab(page);
 	if (page_is_pfmemalloc(page))