linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Burt Holzman <burt@fnal.gov>
Cc: "hannes@cmpxchg.org" <hannes@cmpxchg.org>,
	"vdavydov.dev@gmail.com" <vdavydov.dev@gmail.com>,
	"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: OOM notification for cgroupsv1 broken in 4.19
Date: Fri, 21 Dec 2018 16:33:02 +0100	[thread overview]
Message-ID: <20181221153302.GB6410@dhcp22.suse.cz> (raw)
Message-ID: <20181221153302.s31ha_vczoV0XT0Fl7zsqV-ZimjvHzKswGv29v6dVXM@z> (raw)
In-Reply-To: <5ba5ba06-554c-d1ec-0967-b1d3486d0699@fnal.gov>

On Fri 21-12-18 14:49:38, Burt Holzman wrote:
> Hi,
> 
> This patch: 29ef680ae7c21110af8e6416d84d8a72fc147b14
> [PATCH] memcg, oom: move out_of_memory back to the charge path
> 
> has broken the eventfd notification for cgroups-v1. This is because 
> mem_cgroup_oom_notify() is called only in mem_cgroup_oom_synchronize and 
> not with the new, additional call to mem_cgroup_out_of_memory in the 
> charge path.

Yes, you are right and this is a clear regression. Does the following
patch fixes the issue for you? I am not super happy about the code
duplication but I wasn't able to separate this out from
mem_cgroup_oom_synchronize because that one has to handle the oom_killer
disabled case which is not the case in the charge path because we simply
back off and hand over to mem_cgroup_oom_synchronize in that case.
---
From 51633f683173013741f4d0ab3e31bae575341c55 Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.com>
Date: Fri, 21 Dec 2018 16:28:29 +0100
Subject: [PATCH] memcg, oom: notify on oom killer invocation from the charge
 path

Burt Holzman has noticed that memcg v1 doesn't notify about OOM events
via eventfd anymore. The reason is that 29ef680ae7c2 ("memcg, oom: move
out_of_memory back to the charge path") has moved the oom handling back
to the charge path. While doing so the notification was left behind in
mem_cgroup_oom_synchronize.

Fix the issue by replicating the oom hierarchy locking and the
notification.

Reported-by: Burt Holzman <burt@fnal.gov>
Fixes: 29ef680ae7c2 ("memcg, oom: move out_of_memory back to the charge path")
Cc: stable # 4.19+
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
 mm/memcontrol.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6e1469b80cb7..7e6bf74ddb1e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1666,6 +1666,9 @@ enum oom_status {
 
 static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order)
 {
+	enum oom_status ret;
+	bool locked;
+
 	if (order > PAGE_ALLOC_COSTLY_ORDER)
 		return OOM_SKIPPED;
 
@@ -1700,10 +1703,23 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int
 		return OOM_ASYNC;
 	}
 
+	mem_cgroup_mark_under_oom(memcg);
+
+	locked = mem_cgroup_oom_trylock(memcg);
+
+	if (locked)
+		mem_cgroup_oom_notify(memcg);
+
+	mem_cgroup_unmark_under_oom(memcg);
 	if (mem_cgroup_out_of_memory(memcg, mask, order))
-		return OOM_SUCCESS;
+		ret = OOM_SUCCESS;
+	else
+		ret = OOM_FAILED;
 
-	return OOM_FAILED;
+	if (locked)
+		mem_cgroup_oom_unlock(memcg);
+
+	return ret;
 }
 
 /**
-- 
2.19.2

-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2018-12-21 15:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21 14:49 OOM notification for cgroupsv1 broken in 4.19 Burt Holzman
2018-12-21 15:33 ` Michal Hocko [this message]
2018-12-21 15:33   ` Michal Hocko
2018-12-21 17:33   ` Burt Holzman
2018-12-21 19:02   ` Johannes Weiner
2018-12-24  9:11 ` [PATCH] memcg, oom: notify on oom killer invocation from the charge path Michal Hocko
2018-12-24  9:11   ` 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=20181221153302.GB6410@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=burt@fnal.gov \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=vdavydov.dev@gmail.com \
    /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).