The patch titled Subject: mm, memcg: add ":deact" tag for reparented kmem caches in memcg_slabinfo has been added to the -mm tree. Its filename is mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo.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: add ":deact" tag for reparented kmem caches in memcg_slabinfo With Roman's kmem cache reparent patch ("mm: memcg/slab: reparent memcg kmem_caches on cgroup removal"), multiple kmem caches of the same type can be seen attached to the same memcg id. All of them, except maybe one, are reparent'ed kmem caches. It can be useful to tag those reparented caches by adding a new slab flag "SLAB_DEACTIVATED" to those kmem caches that will be reparent'ed if it cannot be destroyed completely. For the reparent'ed memcg kmem caches, the tag ":deact" will now be shown in <debugfs>/memcg_slabinfo. Link: http://lkml.kernel.org/r/20190621173005.31514-1-longman@xxxxxxxxxx Signed-off-by: Waiman Long <longman@xxxxxxxxxx> Cc: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Roman Gushchin <guro@xxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/slab.h | 4 ++++ mm/slab.c | 1 + mm/slab_common.c | 14 ++++++++------ mm/slub.c | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) --- a/include/linux/slab.h~mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo +++ a/include/linux/slab.h @@ -116,6 +116,10 @@ /* Objects are reclaimable */ #define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0x00020000U) #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ + +/* Slab deactivation flag */ +#define SLAB_DEACTIVATED ((slab_flags_t __force)0x10000000U) + /* * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. * --- a/mm/slab.c~mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo +++ a/mm/slab.c @@ -2237,6 +2237,7 @@ int __kmem_cache_shrink(struct kmem_cach #ifdef CONFIG_MEMCG void __kmemcg_cache_deactivate(struct kmem_cache *cachep) { + cachep->flags |= SLAB_DEACTIVATED; __kmem_cache_shrink(cachep); } --- a/mm/slab_common.c~mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo +++ a/mm/slab_common.c @@ -1533,7 +1533,7 @@ static int memcg_slabinfo_show(struct se struct slabinfo sinfo; mutex_lock(&slab_mutex); - seq_puts(m, "# <name> <css_id[:dead]> <active_objs> <num_objs>"); + seq_puts(m, "# <name> <css_id[:dead|deact]> <active_objs> <num_objs>"); seq_puts(m, " <active_slabs> <num_slabs>\n"); list_for_each_entry(s, &slab_root_caches, root_caches_node) { /* @@ -1544,22 +1544,24 @@ static int memcg_slabinfo_show(struct se memset(&sinfo, 0, sizeof(sinfo)); get_slabinfo(s, &sinfo); - seq_printf(m, "%-17s root %6lu %6lu %6lu %6lu\n", + seq_printf(m, "%-17s root %6lu %6lu %6lu %6lu\n", cache_name(s), sinfo.active_objs, sinfo.num_objs, sinfo.active_slabs, sinfo.num_slabs); for_each_memcg_cache(c, s) { struct cgroup_subsys_state *css; - char *dead = ""; + char *status = ""; css = &c->memcg_params.memcg->css; if (!(css->flags & CSS_ONLINE)) - dead = ":dead"; + status = ":dead"; + else if (c->flags & SLAB_DEACTIVATED) + status = ":deact"; memset(&sinfo, 0, sizeof(sinfo)); get_slabinfo(c, &sinfo); - seq_printf(m, "%-17s %4d%5s %6lu %6lu %6lu %6lu\n", - cache_name(c), css->id, dead, + seq_printf(m, "%-17s %4d%-6s %6lu %6lu %6lu %6lu\n", + cache_name(c), css->id, status, sinfo.active_objs, sinfo.num_objs, sinfo.active_slabs, sinfo.num_slabs); } --- a/mm/slub.c~mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo +++ a/mm/slub.c @@ -4034,6 +4034,7 @@ void __kmemcg_cache_deactivate(struct km */ slub_set_cpu_partial(s, 0); s->min_partial = 0; + s->flags |= SLAB_DEACTIVATED; } #endif /* CONFIG_MEMCG */ _ Patches currently in -mm which might be from longman@xxxxxxxxxx are debugobjects-move-printk-out-of-db-lock-critical-sections.patch mm-memcg-add-a-memcg_slabinfo-debugfs-file.patch mm-memcg-add-deact-tag-for-reparented-kmem-caches-in-memcg_slabinfo.patch