Skip to content

Commit

Permalink
slub: add missing kmem cgroup support to kmem_cache_free_bulk
Browse files Browse the repository at this point in the history
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 <[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]>
  • Loading branch information
netoptimizer authored and torvalds committed Nov 22, 2015
1 parent 03ec0ed commit 0337451
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2887,13 +2887,17 @@ static int build_detached_freelist(struct kmem_cache *s, size_t size,


/* Note that interrupts must be enabled when calling this function. */
void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p)
void kmem_cache_free_bulk(struct kmem_cache *orig_s, size_t size, void **p)
{
if (WARN_ON(!size))
return;

do {
struct detached_freelist df;
struct kmem_cache *s;

/* Support for memcg */
s = cache_from_obj(orig_s, p[size - 1]);

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

0 comments on commit 0337451

Please sign in to comment.