]> Git Repo - linux.git/commit
slub: fix kmem cgroup bug in kmem_cache_alloc_bulk
authorJesper Dangaard Brouer <[email protected]>
Fri, 20 Nov 2015 23:57:52 +0000 (15:57 -0800)
committerLinus Torvalds <[email protected]>
Sun, 22 Nov 2015 19:58:44 +0000 (11:58 -0800)
commit03ec0ed57ffc77720b811dbb6d44733b58360d9f
treea697617cf6f04b22ebc4cb677c163586f4f349a1
parentd0ecd894e3d5f768a84403b34019c4a7daa05882
slub: fix kmem cgroup bug in kmem_cache_alloc_bulk

The call slab_pre_alloc_hook() interacts with kmemgc and is not allowed to
be called several times inside the bulk alloc for loop, due to the call to
memcg_kmem_get_cache().

This would result in hitting the VM_BUG_ON in __memcg_kmem_get_cache.

As suggested by Vladimir Davydov, change slab_post_alloc_hook() to be able
to handle an array of objects.

A subtle detail is, loop iterator "i" in slab_post_alloc_hook() must have
same type (size_t) as size argument.  This helps the compiler to easier
realize that it can remove the loop, when all debug statements inside loop
evaluates to nothing.  Note, this is only an issue because the kernel is
compiled with GCC option: -fno-strict-overflow

In slab_alloc_node() the compiler inlines and optimizes the invocation of
slab_post_alloc_hook(s, flags, 1, &object) by removing the loop and access
object directly.

Signed-off-by: Jesper Dangaard Brouer <[email protected]>
Reported-by: Vladimir Davydov <[email protected]>
Suggested-by: Vladimir Davydov <[email protected]>
Reviewed-by: Vladimir Davydov <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/slub.c
This page took 0.045656 seconds and 4 git commands to generate.