linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: "Michal Koutný" <mkoutny@suse.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Kernel Team <Kernel-team@fb.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 1/2] mm: memcg: switch to css_tryget() in get_mem_cgroup_from_mm()
Date: Wed, 13 Nov 2019 17:08:29 +0000	[thread overview]
Message-ID: <20191113170823.GA12464@castle.DHCP.thefacebook.com> (raw)
In-Reply-To: <20191113162934.GF19372@blackbody.suse.cz>

On Wed, Nov 13, 2019 at 05:29:34PM +0100, Michal Koutný wrote:
> Hi.
> 
> On Wed, Nov 06, 2019 at 02:51:30PM -0800, Roman Gushchin <guro@fb.com> wrote:
> > Let's fix it by switching from css_tryget_online() to css_tryget().
> Is this a safe thing to do? The stack captures a kmem charge path, with
> css_tryget() it may happen it gets an offlined memcg and carry out
> charge into it. What happens when e.g. memcg_deactivate_kmem_caches is
> skipped as a consequence?

The thing here is that css_tryget_online() cannot pin the online state,
so even if returned true, the cgroup can be offline at the return from
the function. So if we rely somewhere on it, it's already broken.

Generally speaking, it's better to reduce it's usage to the bare minimum.

> 
> > The problem is caused by an exiting task which is associated with
> > an offline memcg. We're iterating over and over in the
> > do {} while (!css_tryget_online()) loop, but obviously the memcg won't
> > become online and the exiting task won't be migrated to a live memcg.
> As discussed in other replies, the task is not yet exiting. However, the
> access to memcg isn't through `current` but `mm->owner`, i.e. another
> task of a threadgroup may have got stuck in an offlined memcg (I don't
> have a good explanation for that though).

Yes, it's true, and I've no idea how the memcg can be offline in this case too.
We've seen it only several times in fb production, so it seems to be a really
rare case. Could be anything from a tiny race somewhere to cpu bugs.

Thanks!


  reply	other threads:[~2019-11-13 17:08 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 22:51 [PATCH 1/2] mm: memcg: switch to css_tryget() in get_mem_cgroup_from_mm() Roman Gushchin
2019-11-06 22:51 ` [PATCH 2/2] mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup() Roman Gushchin
2019-11-07  0:26   ` Johannes Weiner
2019-11-07  2:31   ` Shakeel Butt
2019-11-07 15:44   ` Tejun Heo
2019-11-07  0:22 ` [PATCH 1/2] mm: memcg: switch to css_tryget() in get_mem_cgroup_from_mm() Johannes Weiner
2019-11-07  1:25   ` Shakeel Butt
2019-11-07  1:43     ` Johannes Weiner
2019-11-07  1:43     ` Roman Gushchin
2019-11-07  2:21       ` Shakeel Butt
2019-11-07  2:28         ` Shakeel Butt
2019-11-07 12:21 ` Michal Hocko
2019-11-07 15:43   ` Tejun Heo
2019-11-07 16:42   ` Roman Gushchin
2019-11-07 17:02     ` Michal Hocko
2019-11-07 22:41       ` Roman Gushchin
2019-11-08  8:53         ` Michal Hocko
2019-11-07 15:43 ` Tejun Heo
2019-11-13 16:29 ` Michal Koutný
2019-11-13 17:08   ` Roman Gushchin [this message]
2019-11-14 19:16     ` Michal Hocko
2019-11-14 19:20       ` Tejun Heo
2019-11-14 19:33         ` Michal Hocko
2019-11-14 19:37           ` Tejun Heo
2019-11-15 17:40             ` Michal Hocko
2019-11-15 17:45               ` Tejun Heo
2019-11-15 17:47               ` Michal Hocko
2019-11-15 17:48                 ` Tejun Heo
2019-11-15 18:03                   ` Michal Hocko
2019-11-15 18:07                 ` Roman Gushchin
2019-11-18  9:43                   ` Michal Hocko
2019-11-15 18:13       ` Roman Gushchin
2019-11-21 15:28     ` Michal Koutný
2019-11-22  8:20       ` Michal Hocko

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=20191113170823.GA12464@castle.DHCP.thefacebook.com \
    --to=guro@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).