linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Michal Hocko <mhocko@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	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: Tue, 15 Mar 2016 22:18:48 -0700	[thread overview]
Message-ID: <20160316051848.GA11006@cmpxchg.org> (raw)
In-Reply-To: <20160311091931.GK1946@esperanza>

On Fri, Mar 11, 2016 at 12:19:31PM +0300, Vladimir Davydov wrote:
> On Fri, Mar 11, 2016 at 09:18:25AM +0100, Michal Hocko wrote:
> > On Thu 10-03-16 15:50:14, Johannes Weiner wrote:
> ...
> > > @@ -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.
> 
> I suppose the user might want to interrupt the write by hitting CTRL-C.

Yeah. This is the same thing we do for the current limit setting loop.

> Come to think of it, shouldn't we restore the old limit and return EBUSY
> if we failed to reclaim enough memory?

I suspect it's very rare that it would fail. But even in that case
it's probably better to at least not allow new charges past what the
user requested, even if we can't push the level back far enough.

  reply	other threads:[~2016-03-16  5:19 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
2016-03-11  9:19   ` Vladimir Davydov
2016-03-16  5:18     ` Johannes Weiner [this message]
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=20160316051848.GA11006@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.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).