]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/slub: fix bulk alloc and free stats
authorVlastimil Babka <vbabka@suse.cz>
Mon, 7 Aug 2023 18:50:44 +0000 (20:50 +0200)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 21 Nov 2023 18:03:21 +0000 (13:03 -0500)
The SLUB sysfs stats enabled CONFIG_SLUB_STATS have two deficiencies
identified wrt bulk alloc/free operations:

- Bulk allocations from cpu freelist are not counted. Add the
  ALLOC_FASTPATH counter there.

- Bulk fastpath freeing will count a list of multiple objects with a
  single FREE_FASTPATH inc. Add a stat_add() variant to count them all.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c

index 63d281dfacdbca13ff951a4dcacc031d1b6536c0..f0cd55bb4e11a4d7756fcf005c8f582bf5d19232 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -341,6 +341,14 @@ static inline void stat(const struct kmem_cache *s, enum stat_item si)
 #endif
 }
 
+static inline void stat_add(const struct kmem_cache *s, enum stat_item si, int v)
+{
+#ifdef CONFIG_SLUB_STATS
+       raw_cpu_add(s->cpu_slab->stat[si], v);
+#endif
+}
+
+
 /*
  * Tracks for which NUMA nodes we have kmem_cache_nodes allocated.
  * Corresponds to node_state[N_NORMAL_MEMORY], but can temporarily
@@ -3784,7 +3792,7 @@ redo:
 
                local_unlock(&s->cpu_slab->lock);
        }
-       stat(s, FREE_FASTPATH);
+       stat_add(s, FREE_FASTPATH, cnt);
 }
 #else /* CONFIG_SLUB_TINY */
 static void do_slab_free(struct kmem_cache *s,
@@ -3986,6 +3994,7 @@ static inline int __kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags,
                c->freelist = get_freepointer(s, object);
                p[i] = object;
                maybe_wipe_obj_freeptr(s, p[i]);
+               stat(s, ALLOC_FASTPATH);
        }
        c->tid = next_tid(c->tid);
        local_unlock_irqrestore(&s->cpu_slab->lock, irqflags);