Re: [PATCH v3 15/19] mm: memcg/slab: deprecate slab_root_caches

From: Vlastimil Babka
Date: Tue May 26 2020 - 06:52:28 EST


On 4/22/20 10:47 PM, Roman Gushchin wrote:
> Currently there are two lists of kmem_caches:
> 1) slab_caches, which contains all kmem_caches,
> 2) slab_root_caches, which contains only root kmem_caches.
>
> And there is some preprocessor magic to have a single list
> if CONFIG_MEMCG_KMEM isn't enabled.
>
> It was required earlier because the number of non-root kmem_caches
> was proportional to the number of memory cgroups and could reach
> really big values. Now, when it cannot exceed the number of root
> kmem_caches, there is really no reason to maintain two lists.
>
> We never iterate over the slab_root_caches list on any hot paths,
> so it's perfectly fine to iterate over slab_caches and filter out
> non-root kmem_caches.
>
> It allows to remove a lot of config-dependent code and two pointers
> from the kmem_cache structure.
>
> Signed-off-by: Roman Gushchin <guro@xxxxxx>

Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>

> @@ -1148,11 +1126,12 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
>
> static int slab_show(struct seq_file *m, void *p)
> {
> - struct kmem_cache *s = list_entry(p, struct kmem_cache, root_caches_node);
> + struct kmem_cache *s = list_entry(p, struct kmem_cache, list);
>
> - if (p == slab_root_caches.next)
> + if (p == slab_caches.next)
> print_slabinfo_header(m);
> - cache_show(s, m);
> + if (is_root_cache(s))
> + cache_show(s, m);

If there wasn't patch 17/19 we could just remove this condition and have
/proc/slabinfo contain the -memcg variants?