Re: [PATCH v3 07/19] mm: memcg/slab: allocate obj_cgroups for non-root slab pages

From: Roman Gushchin
Date: Thu Apr 23 2020 - 16:20:25 EST


On Wed, Apr 22, 2020 at 01:46:56PM -0700, Roman Gushchin wrote:
> Allocate and release memory to store obj_cgroup pointers for each
> non-root slab page. Reuse page->mem_cgroup pointer to store a pointer
> to the allocated space.
>
> To distinguish between obj_cgroups and memcg pointers in case
> when it's not obvious which one is used (as in page_cgroup_ino()),
> let's always set the lowest bit in the obj_cgroup case.
>
> Signed-off-by: Roman Gushchin <guro@xxxxxx>
> ---
> include/linux/mm_types.h | 5 ++++-
> include/linux/slab_def.h | 5 +++++
> include/linux/slub_def.h | 2 ++
> mm/memcontrol.c | 17 +++++++++++---
> mm/slab.c | 3 ++-
> mm/slab.h | 48 ++++++++++++++++++++++++++++++++++++++++
> mm/slub.c | 5 +++++
> 7 files changed, 80 insertions(+), 5 deletions(-)
>
...
> diff --git a/mm/slub.c b/mm/slub.c
> index 8d16babe1829..68c2c45dfac1 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5992,4 +5992,9 @@ ssize_t slabinfo_write(struct file *file, const char __user *buffer,
> {
> return -EIO;
> }
> +
> +int objs_per_slab(struct kmem_cache *cache)
> +{
> + return oo_objects(cache->oo);
> +}
> #endif /* CONFIG_SLUB_DEBUG */
> --
> 2.25.3
>


Ooops, the build bot found that objs_per_slab() was accidentally guarded by
CONFIG_SLUB_DEBUG. An updated version below.

--