Re: [PATCH] mm: slab: make page_cgroup_ino() to recognize non-compound slab pages properly

From: Daniel Jordan
Date: Wed Oct 30 2019 - 17:04:41 EST


Hi Roman,

On Fri, Oct 25, 2019 at 04:27:10PM -0700, Roman Gushchin wrote:
> page_cgroup_ino() doesn't return a valid memcg pointer for non-compund
> slab pages, because it depends on PgHead AND PgSlab flags to be set
> to determine the memory cgroup from the kmem_cache.
> It's correct for compound pages, but not for generic small pages. Those
> don't have PgHead set, so it ends up returning zero.
>
> Fix this by replacing the condition to PageSlab() && !PageTail().

You may also want to update the comment above memcg_from_slab_page():

* So this function assumes that the page can pass PageHead() and PageSlab()
* checks.