From: Vladimir Davydov <vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
To: Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org>
Cc: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
mhocko-AlSwsSmVLrQ@public.gmane.org,
dchinner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
Mel Gorman <mgorman-l3A5Bk7waGM@public.gmane.org>,
Rik van Riel <riel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
Balbir Singh
<bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
KAMEZAWA Hiroyuki
<kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
Subject: Re: [PATCH v12 09/18] vmscan: shrink slab on memcg pressure
Date: Wed, 4 Dec 2013 10:31:32 +0400 [thread overview]
Message-ID: <529ECC44.8040508@parallels.com> (raw)
In-Reply-To: <20131204045147.GN10988@dastard>
On 12/04/2013 08:51 AM, Dave Chinner wrote:
> On Tue, Dec 03, 2013 at 04:15:57PM +0400, Vladimir Davydov wrote:
>> On 12/03/2013 02:48 PM, Dave Chinner wrote:
>>>> @@ -236,11 +236,17 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker,
>>>> return 0;
>>>>
>>>> /*
>>>> - * copy the current shrinker scan count into a local variable
>>>> - * and zero it so that other concurrent shrinker invocations
>>>> - * don't also do this scanning work.
>>>> + * Do not touch global counter of deferred objects on memcg pressure to
>>>> + * avoid isolation issues. Ideally the counter should be per-memcg.
>>>> */
>>>> - nr = atomic_long_xchg(&shrinker->nr_deferred[nid], 0);
>>>> + if (!shrinkctl->target_mem_cgroup) {
>>>> + /*
>>>> + * copy the current shrinker scan count into a local variable
>>>> + * and zero it so that other concurrent shrinker invocations
>>>> + * don't also do this scanning work.
>>>> + */
>>>> + nr = atomic_long_xchg(&shrinker->nr_deferred[nid], 0);
>>>> + }
>>> That's ugly. Effectively it means that memcg reclaim is going to be
>>> completely ineffective when large numbers of allocations and hence
>>> reclaim attempts are done under GFP_NOFS context.
>>>
>>> The only thing that keeps filesystem caches in balance when there is
>>> lots of filesystem work going on (i.e. lots of GFP_NOFS allocations)
>>> is the deferal of reclaim work to a context that can do something
>>> about it.
>> Imagine the situation: a memcg issues a GFP_NOFS allocation and goes to
>> shrink_slab() where it defers them to the global counter; then another
>> memcg issues a GFP_KERNEL allocation, also goes to shrink_slab() where
>> it sees a huge number of deferred objects and starts shrinking them,
>> which is not good IMHO.
> That's exactly what the deferred mechanism is for - we know we have
> to do the work, but we can't do it right now so let someone else do
> it who can.
>
> In most cases, deferral is handled by kswapd, because when a
> filesystem workload is causing memory pressure then most allocations
> are done in GFP_NOFS conditions. Hence the only memory reclaim that
> can make progress here is kswapd.
>
> Right now, you aren't deferring any of this memory pressure to some
> other agent, so it just does not get done. That's a massive problem
> - it's a design flaw - and instead I see lots of crazy hacks being
> added to do stuff that should simply be deferred to kswapd like is
> done for global memory pressure.
>
> Hell, kswapd shoul dbe allowed to walk memcg LRU lists and trim
> them, just like it does for the global lists. We only need a single
> "deferred work" counter per node for that - just let kswapd
> proportion the deferred work over the per-node LRU and the
> memcgs....
Seems I misunderstand :-(
Let me try. You mean we have the only nr_deferred counter per-node, and
kswapd scans
nr_deferred*memcg_kmem_size/total_kmem_size
objects in each memcg, right?
Then if there were a lot of objects deferred on memcg (not global)
pressure due to a memcg issuing a lot of GFP_NOFS allocations, kswapd
will reclaim objects from all, even unlimited, memcgs. This looks like
an isolation issue :-/
Currently we have a per-node nr_deferred counter for each shrinker. If
we add per-memcg reclaim, we have to make it per-memcg per-node, don't we?
Thanks.
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Davydov <vdavydov@parallels.com>
To: Dave Chinner <david@fromorbit.com>
Cc: hannes@cmpxchg.org, mhocko@suse.cz, dchinner@redhat.com,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, cgroups@vger.kernel.org, devel@openvz.org,
glommer@openvz.org, Mel Gorman <mgorman@suse.de>,
Rik van Riel <riel@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>,
Balbir Singh <bsingharora@gmail.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [PATCH v12 09/18] vmscan: shrink slab on memcg pressure
Date: Wed, 4 Dec 2013 10:31:32 +0400 [thread overview]
Message-ID: <529ECC44.8040508@parallels.com> (raw)
In-Reply-To: <20131204045147.GN10988@dastard>
On 12/04/2013 08:51 AM, Dave Chinner wrote:
> On Tue, Dec 03, 2013 at 04:15:57PM +0400, Vladimir Davydov wrote:
>> On 12/03/2013 02:48 PM, Dave Chinner wrote:
>>>> @@ -236,11 +236,17 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker,
>>>> return 0;
>>>>
>>>> /*
>>>> - * copy the current shrinker scan count into a local variable
>>>> - * and zero it so that other concurrent shrinker invocations
>>>> - * don't also do this scanning work.
>>>> + * Do not touch global counter of deferred objects on memcg pressure to
>>>> + * avoid isolation issues. Ideally the counter should be per-memcg.
>>>> */
>>>> - nr = atomic_long_xchg(&shrinker->nr_deferred[nid], 0);
>>>> + if (!shrinkctl->target_mem_cgroup) {
>>>> + /*
>>>> + * copy the current shrinker scan count into a local variable
>>>> + * and zero it so that other concurrent shrinker invocations
>>>> + * don't also do this scanning work.
>>>> + */
>>>> + nr = atomic_long_xchg(&shrinker->nr_deferred[nid], 0);
>>>> + }
>>> That's ugly. Effectively it means that memcg reclaim is going to be
>>> completely ineffective when large numbers of allocations and hence
>>> reclaim attempts are done under GFP_NOFS context.
>>>
>>> The only thing that keeps filesystem caches in balance when there is
>>> lots of filesystem work going on (i.e. lots of GFP_NOFS allocations)
>>> is the deferal of reclaim work to a context that can do something
>>> about it.
>> Imagine the situation: a memcg issues a GFP_NOFS allocation and goes to
>> shrink_slab() where it defers them to the global counter; then another
>> memcg issues a GFP_KERNEL allocation, also goes to shrink_slab() where
>> it sees a huge number of deferred objects and starts shrinking them,
>> which is not good IMHO.
> That's exactly what the deferred mechanism is for - we know we have
> to do the work, but we can't do it right now so let someone else do
> it who can.
>
> In most cases, deferral is handled by kswapd, because when a
> filesystem workload is causing memory pressure then most allocations
> are done in GFP_NOFS conditions. Hence the only memory reclaim that
> can make progress here is kswapd.
>
> Right now, you aren't deferring any of this memory pressure to some
> other agent, so it just does not get done. That's a massive problem
> - it's a design flaw - and instead I see lots of crazy hacks being
> added to do stuff that should simply be deferred to kswapd like is
> done for global memory pressure.
>
> Hell, kswapd shoul dbe allowed to walk memcg LRU lists and trim
> them, just like it does for the global lists. We only need a single
> "deferred work" counter per node for that - just let kswapd
> proportion the deferred work over the per-node LRU and the
> memcgs....
Seems I misunderstand :-(
Let me try. You mean we have the only nr_deferred counter per-node, and
kswapd scans
nr_deferred*memcg_kmem_size/total_kmem_size
objects in each memcg, right?
Then if there were a lot of objects deferred on memcg (not global)
pressure due to a memcg issuing a lot of GFP_NOFS allocations, kswapd
will reclaim objects from all, even unlimited, memcgs. This looks like
an isolation issue :-/
Currently we have a per-node nr_deferred counter for each shrinker. If
we add per-memcg reclaim, we have to make it per-memcg per-node, don't we?
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Davydov <vdavydov@parallels.com>
To: Dave Chinner <david@fromorbit.com>
Cc: <hannes@cmpxchg.org>, <mhocko@suse.cz>, <dchinner@redhat.com>,
<akpm@linux-foundation.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <cgroups@vger.kernel.org>,
<devel@openvz.org>, <glommer@openvz.org>,
Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Balbir Singh <bsingharora@gmail.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [PATCH v12 09/18] vmscan: shrink slab on memcg pressure
Date: Wed, 4 Dec 2013 10:31:32 +0400 [thread overview]
Message-ID: <529ECC44.8040508@parallels.com> (raw)
In-Reply-To: <20131204045147.GN10988@dastard>
On 12/04/2013 08:51 AM, Dave Chinner wrote:
> On Tue, Dec 03, 2013 at 04:15:57PM +0400, Vladimir Davydov wrote:
>> On 12/03/2013 02:48 PM, Dave Chinner wrote:
>>>> @@ -236,11 +236,17 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker,
>>>> return 0;
>>>>
>>>> /*
>>>> - * copy the current shrinker scan count into a local variable
>>>> - * and zero it so that other concurrent shrinker invocations
>>>> - * don't also do this scanning work.
>>>> + * Do not touch global counter of deferred objects on memcg pressure to
>>>> + * avoid isolation issues. Ideally the counter should be per-memcg.
>>>> */
>>>> - nr = atomic_long_xchg(&shrinker->nr_deferred[nid], 0);
>>>> + if (!shrinkctl->target_mem_cgroup) {
>>>> + /*
>>>> + * copy the current shrinker scan count into a local variable
>>>> + * and zero it so that other concurrent shrinker invocations
>>>> + * don't also do this scanning work.
>>>> + */
>>>> + nr = atomic_long_xchg(&shrinker->nr_deferred[nid], 0);
>>>> + }
>>> That's ugly. Effectively it means that memcg reclaim is going to be
>>> completely ineffective when large numbers of allocations and hence
>>> reclaim attempts are done under GFP_NOFS context.
>>>
>>> The only thing that keeps filesystem caches in balance when there is
>>> lots of filesystem work going on (i.e. lots of GFP_NOFS allocations)
>>> is the deferal of reclaim work to a context that can do something
>>> about it.
>> Imagine the situation: a memcg issues a GFP_NOFS allocation and goes to
>> shrink_slab() where it defers them to the global counter; then another
>> memcg issues a GFP_KERNEL allocation, also goes to shrink_slab() where
>> it sees a huge number of deferred objects and starts shrinking them,
>> which is not good IMHO.
> That's exactly what the deferred mechanism is for - we know we have
> to do the work, but we can't do it right now so let someone else do
> it who can.
>
> In most cases, deferral is handled by kswapd, because when a
> filesystem workload is causing memory pressure then most allocations
> are done in GFP_NOFS conditions. Hence the only memory reclaim that
> can make progress here is kswapd.
>
> Right now, you aren't deferring any of this memory pressure to some
> other agent, so it just does not get done. That's a massive problem
> - it's a design flaw - and instead I see lots of crazy hacks being
> added to do stuff that should simply be deferred to kswapd like is
> done for global memory pressure.
>
> Hell, kswapd shoul dbe allowed to walk memcg LRU lists and trim
> them, just like it does for the global lists. We only need a single
> "deferred work" counter per node for that - just let kswapd
> proportion the deferred work over the per-node LRU and the
> memcgs....
Seems I misunderstand :-(
Let me try. You mean we have the only nr_deferred counter per-node, and
kswapd scans
nr_deferred*memcg_kmem_size/total_kmem_size
objects in each memcg, right?
Then if there were a lot of objects deferred on memcg (not global)
pressure due to a memcg issuing a lot of GFP_NOFS allocations, kswapd
will reclaim objects from all, even unlimited, memcgs. This looks like
an isolation issue :-/
Currently we have a per-node nr_deferred counter for each shrinker. If
we add per-memcg reclaim, we have to make it per-memcg per-node, don't we?
Thanks.
next prev parent reply other threads:[~2013-12-04 6:31 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-02 11:19 [PATCH v12 00/18] kmemcg shrinkers Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 01/18] memcg: make cache index determination more robust Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 02/18] memcg: consolidate callers of memcg_cache_id Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 03/18] memcg: move initialization to memcg creation Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 04/18] memcg: move several kmemcg functions upper Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 05/18] fs: do not use destroy_super() in alloc_super() fail path Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-03 9:00 ` Dave Chinner
2013-12-03 9:00 ` Dave Chinner
2013-12-03 9:23 ` Vladimir Davydov
2013-12-03 9:23 ` Vladimir Davydov
2013-12-03 9:23 ` Vladimir Davydov
2013-12-03 13:37 ` Al Viro
2013-12-03 13:37 ` Al Viro
2013-12-03 13:48 ` Vladimir Davydov
2013-12-03 13:48 ` Vladimir Davydov
2013-12-03 13:48 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 06/18] vmscan: rename shrink_slab() args to make it more generic Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-03 9:33 ` Dave Chinner
2013-12-03 9:33 ` Dave Chinner
2013-12-03 9:44 ` Vladimir Davydov
2013-12-03 9:44 ` Vladimir Davydov
2013-12-03 9:44 ` Vladimir Davydov
2013-12-03 10:04 ` Dave Chinner
2013-12-03 10:04 ` Dave Chinner
2013-12-02 11:19 ` [PATCH v12 07/18] vmscan: move call to shrink_slab() to shrink_zones() Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 08/18] vmscan: do_try_to_free_pages(): remove shrink_control argument Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 09/18] vmscan: shrink slab on memcg pressure Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-03 10:48 ` Dave Chinner
2013-12-03 10:48 ` Dave Chinner
2013-12-03 12:15 ` Vladimir Davydov
2013-12-03 12:15 ` Vladimir Davydov
2013-12-03 12:15 ` Vladimir Davydov
2013-12-04 4:51 ` Dave Chinner
2013-12-04 4:51 ` Dave Chinner
2013-12-04 6:31 ` Vladimir Davydov [this message]
2013-12-04 6:31 ` Vladimir Davydov
2013-12-04 6:31 ` Vladimir Davydov
2013-12-05 5:01 ` Dave Chinner
2013-12-05 5:01 ` Dave Chinner
2013-12-05 6:57 ` Vladimir Davydov
2013-12-05 6:57 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 10/18] memcg,list_lru: add per-memcg LRU list infrastructure Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
[not found] ` <73d7942f31ac80dfa53bbdd0f957ce5e9a301958.1385974612.git.vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2013-12-03 11:18 ` Dave Chinner
2013-12-03 11:18 ` Dave Chinner
2013-12-03 11:18 ` Dave Chinner
2013-12-03 12:29 ` Vladimir Davydov
2013-12-03 12:29 ` Vladimir Davydov
2013-12-03 12:29 ` Vladimir Davydov
2013-12-05 21:19 ` Dave Chinner
2013-12-05 21:19 ` Dave Chinner
2013-12-02 11:19 ` [PATCH v12 11/18] memcg,list_lru: add function walking over all lists of a per-memcg LRU Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 12/18] fs: make icache, dcache shrinkers memcg-aware Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-03 11:45 ` Dave Chinner
2013-12-03 11:45 ` Dave Chinner
2013-12-03 12:34 ` Vladimir Davydov
2013-12-03 12:34 ` Vladimir Davydov
2013-12-03 12:34 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 13/18] memcg: per-memcg kmem shrinking Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 14/18] vmscan: take at least one pass with shrinkers Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 15/18] memcg: allow kmem limit to be resized down Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 16/18] vmpressure: in-kernel notifications Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 17/18] memcg: reap dead memcgs upon global memory pressure Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:19 ` [PATCH v12 18/18] memcg: flush memcg items upon memcg destruction Vladimir Davydov
2013-12-02 11:19 ` Vladimir Davydov
2013-12-02 11:22 ` [PATCH v12 00/18] kmemcg shrinkers Vladimir Davydov
2013-12-02 11:22 ` 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=529ECC44.8040508@parallels.com \
--to=vdavydov-bzqdu9zft3wakbo8gow8eq@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org \
--cc=dchinner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
--cc=glommer-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=mgorman-l3A5Bk7waGM@public.gmane.org \
--cc=mhocko-AlSwsSmVLrQ@public.gmane.org \
--cc=riel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.