Skip to content

Commit 88da03a

Browse files
Christoph Lametertorvalds
authored andcommitted
slub: use raw_cpu_inc for incrementing statistics
Statistics are not critical to the operation of the allocation but should also not cause too much overhead. When __this_cpu_inc is altered to check if preemption is disabled this triggers. Use raw_cpu_inc to avoid the checks. Using this_cpu_ops may cause interrupt disable/enable sequences on various arches which may significantly impact allocator performance. [akpm@linux-foundation.org: add comment] Signed-off-by: Christoph Lameter <cl@linux.com> Cc: Fengguang Wu <fengguang.wu@intel.com> Cc: Pekka Enberg <penberg@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3ed66e9 commit 88da03a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎mm/slub.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ static inline void memcg_propagate_slab_attrs(struct kmem_cache *s) { }
224224
static inline void stat(const struct kmem_cache *s, enum stat_item si)
225225
{
226226
#ifdef CONFIG_SLUB_STATS
227-
__this_cpu_inc(s->cpu_slab->stat[si]);
227+
/*
228+
* The rmw is racy on a preemptible kernel but this is acceptable, so
229+
* avoid this_cpu_add()'s irq-disable overhead.
230+
*/
231+
raw_cpu_inc(s->cpu_slab->stat[si]);
228232
#endif
229233
}
230234

0 commit comments

Comments
 (0)