From: Shakeel Butt Date: Wed, 28 Mar 2018 23:00:57 +0000 (-0700) Subject: mm, slab: memcg_link the SLAB's kmem_cache X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=da9ec481d66dcca59f3556c2fc783967da2c7697;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git mm, slab: memcg_link the SLAB's kmem_cache [ Upstream commit 880cd276dff17ea29e9a8404275c9502b265afa7 ] All the root caches are linked into slab_root_caches which was introduced by the commit 510ded33e075 ("slab: implement slab_root_caches list") but it missed to add the SLAB's kmem_cache. While experimenting with opt-in/opt-out kmem accounting, I noticed system crashes due to NULL dereference inside cache_from_memcg_idx() while deferencing kmem_cache.memcg_params.memcg_caches. The upstream clean kernel will not see these crashes but SLAB should be consistent with SLUB which does linked its boot caches (kmem_cache_node and kmem_cache) into slab_root_caches. Link: http://lkml.kernel.org/r/20180319210020.60289-1-shakeelb@google.com Fixes: 510ded33e075c ("slab: implement slab_root_caches list") Signed-off-by: Shakeel Butt Cc: Tejun Heo Cc: Vladimir Davydov Cc: Greg Thelen Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Johannes Weiner Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/mm/slab.c b/mm/slab.c index 1bfc3d847a0a..198c1e2c5358 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1283,6 +1283,7 @@ void __init kmem_cache_init(void) nr_node_ids * sizeof(struct kmem_cache_node *), SLAB_HWCACHE_ALIGN); list_add(&kmem_cache->list, &slab_caches); + memcg_link_cache(kmem_cache); slab_state = PARTIAL; /*