From: Roman Gushchin <guro@fb.com>
To: Shakeel Butt <shakeelb@google.com>
Cc: <rpalethorpe@suse.de>, Linux MM <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
LTP List <ltp@lists.linux.it>,
Johannes Weiner <hannes@cmpxchg.org>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Michal Hocko <mhocko@kernel.org>, Tejun Heo <tj@kernel.org>,
Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH v3] mm: memcg/slab: Stop reparented obj_cgroups from charging root
Date: Wed, 21 Oct 2020 13:32:31 -0700 [thread overview]
Message-ID: <20201021203231.GB300658@carbon.dhcp.thefacebook.com> (raw)
In-Reply-To: <CALvZod45mAzyo9LNR4YtX_3J0gZJDagYTNv8NbJAuXzwK5A2DA@mail.gmail.com>
On Tue, Oct 20, 2020 at 09:56:51AM -0700, Shakeel Butt wrote:
> On Tue, Oct 20, 2020 at 6:49 AM Richard Palethorpe <rpalethorpe@suse.de> wrote:
> >
> > Hello,
> >
> > Richard Palethorpe <rpalethorpe@suse.de> writes:
> >
> > > Hello Shakeel,
> > >
> > > Shakeel Butt <shakeelb@google.com> writes:
> > >>>
> > >>> V3: Handle common case where use_hierarchy=1 and update description.
> > >>>
> > >>> mm/memcontrol.c | 7 +++++--
> > >>> 1 file changed, 5 insertions(+), 2 deletions(-)
> > >>>
> > >>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > >>> index 6877c765b8d0..34b8c4a66853 100644
> > >>> --- a/mm/memcontrol.c
> > >>> +++ b/mm/memcontrol.c
> > >>> @@ -291,7 +291,7 @@ static void obj_cgroup_release(struct percpu_ref *ref)
> > >>>
> > >>> spin_lock_irqsave(&css_set_lock, flags);
> > >>> memcg = obj_cgroup_memcg(objcg);
> > >>> - if (nr_pages)
> > >>> + if (nr_pages && (!mem_cgroup_is_root(memcg) || memcg->use_hierarchy))
> > >>
> > >> If we have non-root memcg with use_hierarchy as 0 and this objcg was
> > >> reparented then this __memcg_kmem_uncharge() can potentially underflow
> > >> the page counter and give the same warning.
> > >
> > > Yes, although the kernel considers such a config to be broken, and
> > > prints a warning to the log, it does allow it.
> >
> > Actually this can not happen because if use_hierarchy=0 then the objcg
> > will be reparented to root.
> >
>
> Yup, you are right. I do wonder if we should completely deprecate
> use_hierarchy=0.
+1
Until that happy time maybe we can just link all page counters
to root page counters if use_hierarchy == false?
That would solve the original problem without complicating the code
in the main use_hierarchy == true mode.
Are there any bad consequences, which I miss?
Thanks!
--
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2636f8bad908..fbbc74b82e1a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5339,17 +5339,22 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
memcg->swappiness = mem_cgroup_swappiness(parent);
memcg->oom_kill_disable = parent->oom_kill_disable;
}
- if (parent && parent->use_hierarchy) {
+ if (!parent) {
+ page_counter_init(&memcg->memory, NULL);
+ page_counter_init(&memcg->swap, NULL);
+ page_counter_init(&memcg->kmem, NULL);
+ page_counter_init(&memcg->tcpmem, NULL);
+ } else if (parent->use_hierarchy) {
memcg->use_hierarchy = true;
page_counter_init(&memcg->memory, &parent->memory);
page_counter_init(&memcg->swap, &parent->swap);
page_counter_init(&memcg->kmem, &parent->kmem);
page_counter_init(&memcg->tcpmem, &parent->tcpmem);
} else {
- page_counter_init(&memcg->memory, NULL);
- page_counter_init(&memcg->swap, NULL);
- page_counter_init(&memcg->kmem, NULL);
- page_counter_init(&memcg->tcpmem, NULL);
+ page_counter_init(&memcg->memory, &root_mem_cgroup->memory);
+ page_counter_init(&memcg->swap, &root_mem_cgroup->swap);
+ page_counter_init(&memcg->kmem, &root_mem_cgroup->kmem);
+ page_counter_init(&memcg->tcpmem, &root_mem_cgroup->tcpmem);
/*
* Deeper hierachy with use_hierarchy == false doesn't make
* much sense so let cgroup subsystem know about this
next prev parent reply other threads:[~2020-10-21 20:33 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-14 19:07 [RFC PATCH] " Richard Palethorpe
2020-10-14 20:08 ` Roman Gushchin
2020-10-16 5:40 ` Richard Palethorpe
2020-10-16 9:47 ` Michal Koutný
2020-10-16 10:41 ` Richard Palethorpe
2020-10-16 15:05 ` Richard Palethorpe
2020-10-16 17:26 ` Michal Koutný
2020-10-16 14:53 ` Johannes Weiner
2020-10-16 17:02 ` Roman Gushchin
2020-10-16 17:15 ` Michal Koutný
2020-10-19 8:45 ` Richard Palethorpe
2020-10-19 9:58 ` [PATCH v3] " Richard Palethorpe
2020-10-19 16:58 ` Shakeel Butt
2020-10-20 5:52 ` Richard Palethorpe
2020-10-20 13:49 ` Richard Palethorpe
2020-10-20 16:56 ` Shakeel Butt
2020-10-21 20:32 ` Roman Gushchin [this message]
2020-10-20 17:24 ` Michal Koutný
2020-10-22 7:04 ` Richard Palethorpe
2020-10-22 12:28 ` [PATCH v4] " Richard Palethorpe
2020-10-22 16:37 ` Shakeel Butt
2020-10-22 17:25 ` Roman Gushchin
2020-10-22 23:59 ` Shakeel Butt
2020-10-23 0:40 ` Roman Gushchin
2020-10-23 15:44 ` Johannes Weiner
2020-10-23 16:41 ` Shakeel Butt
2020-10-26 7:32 ` Richard Palethorpe
2020-10-26 23:14 ` Roman Gushchin
2020-10-19 22:28 ` [RFC PATCH] " Roman Gushchin
2020-10-20 6:04 ` Richard Palethorpe
2020-10-20 12:02 ` Richard Palethorpe
2020-10-20 14:48 ` Richard Palethorpe
2020-10-20 16:27 ` Michal Koutný
2020-10-20 17:07 ` Roman Gushchin
2020-10-20 18:18 ` Johannes Weiner
2020-10-21 19:33 ` Roman Gushchin
2020-10-23 16:30 ` Johannes Weiner
2020-11-10 1:27 ` Roman Gushchin
2020-11-10 15:11 ` Shakeel Butt
2020-11-10 19:13 ` Roman Gushchin
2020-11-20 17:46 ` Michal Koutný
2020-11-03 13:22 ` Michal Hocko
2020-11-03 21:30 ` Roman Gushchin
2020-10-20 16:55 ` Shakeel Butt
2020-10-20 17:17 ` Roman Gushchin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201021203231.GB300658@carbon.dhcp.thefacebook.com \
--to=guro@fb.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ltp@lists.linux.it \
--cc=mhocko@kernel.org \
--cc=rpalethorpe@suse.de \
--cc=shakeelb@google.com \
--cc=tj@kernel.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox