From: Michal Hocko <mhocko@kernel.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Vladimir Davydov <vdavydov@virtuozzo.com>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] mm: memcontrol: reclaim and OOM kill when shrinking memory.max below usage
Date: Fri, 11 Mar 2016 09:18:25 +0100 [thread overview]
Message-ID: <20160311081825.GC27701@dhcp22.suse.cz> (raw)
In-Reply-To: <1457643015-8828-2-git-send-email-hannes@cmpxchg.org>
On Thu 10-03-16 15:50:14, Johannes Weiner wrote:
> Setting the original memory.limit_in_bytes hardlimit is subject to a
> race condition when the desired value is below the current usage. The
> code tries a few times to first reclaim and then see if the usage has
> dropped to where we would like it to be, but there is no locking, and
> the workload is free to continue making new charges up to the old
> limit. Thus, attempting to shrink a workload relies on pure luck and
> hope that the workload happens to cooperate.
OK this would be indeed a problem when you want to stop a runaway load.
> To fix this in the cgroup2 memory.max knob, do it the other way round:
> set the limit first, then try enforcement. And if reclaim is not able
> to succeed, trigger OOM kills in the group. Keep going until the new
> limit is met, we run out of OOM victims and there's only unreclaimable
> memory left, or the task writing to memory.max is killed. This allows
> users to shrink groups reliably, and the behavior is consistent with
> what happens when new charges are attempted in excess of memory.max.
Here as well. I think this should go into 4.5 final or later to stable
so that we do not have different behavior of the knob.
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
One nit below
[...]
> @@ -5037,9 +5040,36 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
> if (err)
> return err;
>
> - err = mem_cgroup_resize_limit(memcg, max);
> - if (err)
> - return err;
> + xchg(&memcg->memory.limit, max);
> +
> + for (;;) {
> + unsigned long nr_pages = page_counter_read(&memcg->memory);
> +
> + if (nr_pages <= max)
> + break;
> +
> + if (signal_pending(current)) {
Didn't you want fatal_signal_pending here? At least the changelog
suggests that.
> + err = -EINTR;
> + break;
> + }
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2016-03-11 8:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 20:50 [PATCH] mm: memcontrol: reclaim and OOM kill when shrinking memory.max below usage Johannes Weiner
2016-03-11 8:18 ` Michal Hocko [this message]
2016-03-11 9:19 ` Vladimir Davydov
2016-03-16 5:18 ` Johannes Weiner
2016-03-16 8:43 ` Michal Hocko
2016-03-16 15:15 ` Vladimir Davydov
2016-03-16 20:13 ` Johannes Weiner
2016-03-17 8:23 ` Vladimir Davydov
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=20160311081825.GC27701@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vdavydov@virtuozzo.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).