Skip to content

Commit 0337451

Browse files
netoptimizertorvalds
authored andcommitted
slub: add missing kmem cgroup support to kmem_cache_free_bulk
Initial implementation missed support for kmem cgroup support in kmem_cache_free_bulk() call, add this. If CONFIG_MEMCG_KMEM is not enabled, the compiler should be smart enough to not add any asm code. Incoming bulk free objects can belong to different kmem cgroups, and object free call can happen at a later point outside memcg context. Thus, we need to keep the orig kmem_cache, to correctly verify if a memcg object match against its "root_cache" (s->memcg_params.root_cache). Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Reviewed-by: Vladimir Davydov <vdavydov@virtuozzo.com> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 03ec0ed commit 0337451

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mm/slub.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2887,13 +2887,17 @@ static int build_detached_freelist(struct kmem_cache *s, size_t size,
28872887

28882888

28892889
/* Note that interrupts must be enabled when calling this function. */
2890-
void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p)
2890+
void kmem_cache_free_bulk(struct kmem_cache *orig_s, size_t size, void **p)
28912891
{
28922892
if (WARN_ON(!size))
28932893
return;
28942894

28952895
do {
28962896
struct detached_freelist df;
2897+
struct kmem_cache *s;
2898+
2899+
/* Support for memcg */
2900+
s = cache_from_obj(orig_s, p[size - 1]);
28972901

28982902
size = build_detached_freelist(s, size, p, &df);
28992903
if (unlikely(!df.page))

0 commit comments

Comments
 (0)