From: Michal Hocko <mhocko@kernel.org>
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org,
Vladimir Davydov <vdavydov.dev@gmail.com>
Subject: Re: [PATCH RFC] mm/memcontrol: reclaim severe usage over high limit in get_user_pages loop
Date: Fri, 2 Aug 2019 13:44:38 +0200 [thread overview]
Message-ID: <20190802114438.GH6461@dhcp22.suse.cz> (raw)
In-Reply-To: <105a2f1f-de5c-7bac-3aa5-87bd1dbcaed9@yandex-team.ru>
On Fri 02-08-19 13:01:07, Konstantin Khlebnikov wrote:
>
>
> On 02.08.2019 12:40, Michal Hocko wrote:
> > On Mon 29-07-19 20:55:09, Michal Hocko wrote:
> > > On Mon 29-07-19 11:49:52, Johannes Weiner wrote:
> > > > On Sun, Jul 28, 2019 at 03:29:38PM +0300, Konstantin Khlebnikov wrote:
> > > > > --- a/mm/gup.c
> > > > > +++ b/mm/gup.c
> > > > > @@ -847,8 +847,11 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
> > > > > ret = -ERESTARTSYS;
> > > > > goto out;
> > > > > }
> > > > > - cond_resched();
> > > > > + /* Reclaim memory over high limit before stocking too much */
> > > > > + mem_cgroup_handle_over_high(true);
> > > >
> > > > I'd rather this remained part of the try_charge() call. The code
> > > > comment in try_charge says this:
> > > >
> > > > * We can perform reclaim here if __GFP_RECLAIM but let's
> > > > * always punt for simplicity and so that GFP_KERNEL can
> > > > * consistently be used during reclaim.
> > > >
> > > > The simplicity argument doesn't hold true anymore once we have to add
> > > > manual calls into allocation sites. We should instead fix try_charge()
> > > > to do synchronous reclaim for __GFP_RECLAIM and only punt to userspace
> > > > return when actually needed.
> > >
> > > Agreed. If we want to do direct reclaim on the high limit breach then it
> > > should go into try_charge same way we do hard limit reclaim there. I am
> > > not yet sure about how/whether to scale the excess. The only reason to
> > > move reclaim to return-to-userspace path was GFP_NOWAIT charges. As you
> > > say, maybe we should start by always performing the reclaim for
> > > sleepable contexts first and only defer for non-sleeping requests.
> >
> > In other words. Something like patch below (completely untested). Could
> > you give it a try Konstantin?
>
> This should work but also eliminate all benefits from deferred reclaim:
> bigger batching and running without of any locks.
Yes, but we already have to deal with for hard limit reclaim. Also I
would like to see any actual data to back any more complex solution.
We should definitely start simple.
> After that gap between high and max will work just as reserve for atomic allocations.
>
> >
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index ba9138a4a1de..53a35c526e43 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -2429,8 +2429,12 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
> > schedule_work(&memcg->high_work);
> > break;
> > }
> > - current->memcg_nr_pages_over_high += batch;
> > - set_notify_resume(current);
> > + if (gfpflags_allow_blocking(gfp_mask)) {
> > + reclaim_high(memcg, nr_pages, GFP_KERNEL);
ups, this should be s@GFP_KERNEL@gfp_mask@
> > + } else {
> > + current->memcg_nr_pages_over_high += batch;
> > + set_notify_resume(current);
> > + }
> > break;
> > }
> > } while ((memcg = parent_mem_cgroup(memcg)));
> >
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2019-08-02 11:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-28 12:29 [PATCH RFC] mm/memcontrol: reclaim severe usage over high limit in get_user_pages loop Konstantin Khlebnikov
2019-07-29 9:17 ` Michal Hocko
2019-07-29 9:40 ` Konstantin Khlebnikov
2019-07-29 10:33 ` Michal Hocko
2019-07-29 11:24 ` Konstantin Khlebnikov
2019-07-29 17:28 ` Yang Shi
2019-07-29 18:48 ` Michal Hocko
2019-08-01 21:00 ` Yang Shi
2019-08-02 9:35 ` Michal Hocko
2019-08-02 18:56 ` Yang Shi
2019-08-05 14:32 ` Michal Hocko
2019-08-05 19:24 ` Shakeel Butt
2019-08-06 3:28 ` Yang Shi
2019-08-06 7:05 ` Michal Hocko
2019-07-29 15:49 ` Johannes Weiner
2019-07-29 18:55 ` Michal Hocko
2019-08-02 9:40 ` Michal Hocko
2019-08-02 10:01 ` Konstantin Khlebnikov
2019-08-02 11:44 ` Michal Hocko [this message]
2019-08-06 7:07 ` Michal Hocko
2019-08-06 7:19 ` Konstantin Khlebnikov
2019-08-06 7:36 ` 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=20190802114438.GH6461@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.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).