The patch titled Subject: mm: memcg/slab: disable cache merging for KMALLOC_NORMAL caches has been added to the -mm tree. Its filename is mm-memcg-slab-disable-cache-merging-for-kmalloc_normal-caches.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-memcg-slab-disable-cache-merging-for-kmalloc_normal-caches.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-memcg-slab-disable-cache-merging-for-kmalloc_normal-caches.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Waiman Long <longman@xxxxxxxxxx> Subject: mm: memcg/slab: disable cache merging for KMALLOC_NORMAL caches The KMALLOC_NORMAL (kmalloc-<n>) caches are for unaccounted objects only when CONFIG_MEMCG_KMEM is enabled. To make sure that this condition remains true, we will have to prevent KMALOC_NORMAL caches to merge with other kmem caches. This is now done by setting its refcount to -1 right after its creation. Link: https://lkml.kernel.org/r/20210505200610.13943-4-longman@xxxxxxxxxx Signed-off-by: Waiman Long <longman@xxxxxxxxxx> Suggested-by: Roman Gushchin <guro@xxxxxx> Acked-by: Roman Gushchin <guro@xxxxxx> Reviewed-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/slab_common.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/mm/slab_common.c~mm-memcg-slab-disable-cache-merging-for-kmalloc_normal-caches +++ a/mm/slab_common.c @@ -856,6 +856,13 @@ new_kmalloc_cache(int idx, enum kmalloc_ kmalloc_info[idx].name[type], kmalloc_info[idx].size, flags, 0, kmalloc_info[idx].size); + + /* + * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for + * KMALLOC_NORMAL caches. + */ + if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL)) + kmalloc_caches[type][idx]->refcount = -1; } /* _ Patches currently in -mm which might be from longman@xxxxxxxxxx are mm-memcg-move-mod_objcg_state-to-memcontrolc.patch mm-memcg-cache-vmstat-data-in-percpu-memcg_stock_pcp.patch mm-memcg-improve-refill_obj_stock-performance.patch mm-memcg-optimize-user-context-object-stock-access.patch mm-memcg-slab-properly-set-up-gfp-flags-for-objcg-pointer-array.patch mm-memcg-slab-create-a-new-set-of-kmalloc-cg-n-caches.patch mm-memcg-slab-disable-cache-merging-for-kmalloc_normal-caches.patch