[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200623154027.GB345679@carbon.dhcp.thefacebook.com>
Date: Tue, 23 Jun 2020 08:40:27 -0700
From: Roman Gushchin <guro@...com>
To: Shakeel Butt <shakeelb@...gle.com>
CC: Andrew Morton <akpm@...ux-foundation.org>,
Christoph Lameter <cl@...ux.com>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Linux MM <linux-mm@...ck.org>,
Vlastimil Babka <vbabka@...e.cz>,
Kernel Team <kernel-team@...com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v7 09/19] mm: memcg/slab: charge individual slab objects
instead of pages
On Mon, Jun 22, 2020 at 10:19:25PM -0700, Shakeel Butt wrote:
> On Mon, Jun 22, 2020 at 6:58 PM Roman Gushchin <guro@...com> wrote:
> >
> > Switch to per-object accounting of non-root slab objects.
> >
> > Charging is performed using obj_cgroup API in the pre_alloc hook.
> > Obj_cgroup is charged with the size of the object and the size of
> > metadata: as now it's the size of an obj_cgroup pointer. If the amount of
> > memory has been charged successfully, the actual allocation code is
> > executed. Otherwise, -ENOMEM is returned.
> >
> > In the post_alloc hook if the actual allocation succeeded, corresponding
> > vmstats are bumped and the obj_cgroup pointer is saved. Otherwise, the
> > charge is canceled.
> >
> > On the free path obj_cgroup pointer is obtained and used to uncharge the
> > size of the releasing object.
> >
> > Memcg and lruvec counters are now representing only memory used by active
> > slab objects and do not include the free space. The free space is shared
> > and doesn't belong to any specific cgroup.
> >
> > Global per-node slab vmstats are still modified from
> > (un)charge_slab_page() functions. The idea is to keep all slab pages
> > accounted as slab pages on system level.
> >
> > Signed-off-by: Roman Gushchin <guro@...com>
> > Reviewed-by: Vlastimil Babka <vbabka@...e.cz>
> > ---
> [snip]
> > +static inline struct kmem_cache *memcg_slab_pre_alloc_hook(struct kmem_cache *s,
> > + struct obj_cgroup **objcgp,
> > + size_t objects, gfp_t flags)
> > +{
> > + struct kmem_cache *cachep;
> > +
> > + cachep = memcg_kmem_get_cache(s, objcgp);
> > + if (is_root_cache(cachep))
> > + return s;
> > +
> > + if (obj_cgroup_charge(*objcgp, flags, objects * obj_full_size(s))) {
> > + memcg_kmem_put_cache(cachep);
>
> I think you forgot to put obj_cgroup_put(*objcgp) here again.
Indeed. I've added it, but looks like I've lost it during one of rebases.
Will put it back and resend. Good catch!
Thank you!
Powered by blists - more mailing lists