From: Vladimir Davydov <vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
kernel-team-b10kYP2dOMg@public.gmane.org
Subject: Re: [PATCH v2 3/2] memcg: punt high overage reclaim to return-to-userland path
Date: Mon, 7 Sep 2015 14:38:22 +0300 [thread overview]
Message-ID: <20150907113822.GB31800@esperanza> (raw)
In-Reply-To: <20150904210011.GH25329-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
On Fri, Sep 04, 2015 at 05:00:11PM -0400, Tejun Heo wrote:
> Currently, try_charge() tries to reclaim memory synchronously when the
> high limit is breached; however, if the allocation doesn't have
> __GFP_WAIT, synchronous reclaim is skipped. If a process performs
> only speculative allocations, it can blow way past the high limit.
> This is actually easily reproducible by simply doing "find /".
> slab/slub allocator tries speculative allocations first, so as long as
> there's memory which can be consumed without blocking, it can keep
> allocating memory regardless of the high limit.
>
> This patch makes try_charge() always punt the over-high reclaim to the
> return-to-userland path. If try_charge() detects that high limit is
> breached, it adds the overage to current->memcg_nr_pages_over_high and
> schedules execution of mem_cgroup_handle_over_high() which performs
> synchronous reclaim from the return-to-userland path.
>
> As long as kernel doesn't have a run-away allocation spree, this
> should provide enough protection while making kmemcg behave more
> consistently.
Another good thing about such an approach is that it copes with prio
inversion. Currently, a task with small memory.high might issue
memory.high reclaim on kmem charge with a bunch of various locks held.
If a task with a big value of memory.high needs any of these locks,
it'll have to wait until the low prio task finishes reclaim and releases
the locks. By handing over reclaim to task_work whenever possible we
might avoid this issue and improve overall performance.
>
> v2: - Switched to reclaiming only the overage caused by current rather
> than the difference between usage and high as suggested by
> Michal.
> - Don't record the memcg which went over high limit. This makes
> exit path handling unnecessary. Dropped.
> - Drop mentions of avoiding high stack usage from description as
> suggested by Vladimir. max limit still triggers direct reclaim.
>
> Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Vladimir Davydov <vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Reviewed-by: Vladimir Davydov <vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
next prev parent reply other threads:[~2015-09-07 11:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-28 22:01 [PATCH 1/2] memcg: flatten task_struct->memcg_oom Tejun Heo
[not found] ` <20150828220158.GD11089-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2015-08-28 22:02 ` [PATCH 2/2] memcg: always enable kmemcg on the default hierarchy Tejun Heo
2015-08-31 22:54 ` Andrew Morton
2015-09-04 21:00 ` [PATCH v2 3/2] memcg: punt high overage reclaim to return-to-userland path Tejun Heo
[not found] ` <20150904210011.GH25329-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-09-07 9:23 ` Michal Hocko
[not found] ` <20150907092346.GC6022-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2015-09-08 16:59 ` Tejun Heo
2015-09-07 11:38 ` Vladimir Davydov [this message]
2015-09-08 17:00 ` Tejun Heo
[not found] ` <20150828220237.GE11089-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2015-09-15 9:20 ` [PATCH 2/2] memcg: always enable kmemcg on the default hierarchy Johannes Weiner
2015-09-01 15:25 ` [PATCH 1/2] memcg: flatten task_struct->memcg_oom Michal Hocko
2015-09-02 11:45 ` 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=20150907113822.GB31800@esperanza \
--to=vdavydov-bzqdu9zft3wakbo8gow8eq@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=kernel-team-b10kYP2dOMg@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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