From: Shakeel Butt <shakeelb@google.com>
To: Yang Shi <shy828301@gmail.com>
Cc: Roman Gushchin <guro@fb.com>, Kirill Tkhai <ktkhai@virtuozzo.com>,
Vlastimil Babka <vbabka@suse.cz>,
Dave Chinner <david@fromorbit.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux MM <linux-mm@kvack.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [v8 PATCH 03/13] mm: vmscan: use shrinker_rwsem to protect shrinker_maps allocation
Date: Sun, 7 Mar 2021 22:40:08 -0800 [thread overview]
Message-ID: <CALvZod7Z6A=qFHOy2BODiTcK-fz=Yid5-LhbzofQBa8aemt1Lw@mail.gmail.com> (raw)
In-Reply-To: <20210217001322.2226796-4-shy828301@gmail.com>
On Tue, Feb 16, 2021 at 4:13 PM Yang Shi <shy828301@gmail.com> wrote:
>
> Since memcg_shrinker_map_size just can be changed under holding shrinker_rwsem
> exclusively, the read side can be protected by holding read lock, so it sounds
> superfluous to have a dedicated mutex.
>
> Kirill Tkhai suggested use write lock since:
>
> * We want the assignment to shrinker_maps is visible for shrink_slab_memcg().
> * The rcu_dereference_protected() dereferrencing in shrink_slab_memcg(), but
> in case of we use READ lock in alloc_shrinker_maps(), the dereferrencing
> is not actually protected.
> * READ lock makes alloc_shrinker_info() racy against memory allocation fail.
> alloc_shrinker_info()->free_shrinker_info() may free memory right after
> shrink_slab_memcg() dereferenced it. You may say
> shrink_slab_memcg()->mem_cgroup_online() protects us from it? Yes, sure,
> but this is not the thing we want to remember in the future, since this
> spreads modularity.
>
> And a test with heavy paging workload didn't show write lock makes things worse.
>
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> Acked-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> Acked-by: Roman Gushchin <guro@fb.com>
> Signed-off-by: Yang Shi <shy828301@gmail.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
next prev parent reply other threads:[~2021-03-08 6:41 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-17 0:13 [v8 PATCH 00/13] Make shrinker's nr_deferred memcg aware Yang Shi
2021-02-17 0:13 ` [v8 PATCH 01/13] mm: vmscan: use nid from shrink_control for tracepoint Yang Shi
2021-02-17 0:13 ` [v8 PATCH 02/13] mm: vmscan: consolidate shrinker_maps handling code Yang Shi
2021-02-17 0:13 ` [v8 PATCH 03/13] mm: vmscan: use shrinker_rwsem to protect shrinker_maps allocation Yang Shi
2021-03-08 6:40 ` Shakeel Butt [this message]
2021-02-17 0:13 ` [v8 PATCH 04/13] mm: vmscan: remove memcg_shrinker_map_size Yang Shi
2021-03-08 6:49 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 05/13] mm: vmscan: use kvfree_rcu instead of call_rcu Yang Shi
2021-02-17 1:59 ` Roman Gushchin
2021-02-17 6:25 ` Kirill Tkhai
2021-03-08 6:13 ` Shakeel Butt
2021-03-08 14:54 ` Paul E. McKenney
2021-03-08 18:15 ` Yang Shi
2021-03-08 16:49 ` Roman Gushchin
2021-03-08 20:22 ` Yang Shi
2021-03-08 21:11 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 06/13] mm: memcontrol: rename shrinker_map to shrinker_info Yang Shi
2021-03-08 6:50 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 07/13] mm: vmscan: add shrinker_info_protected() helper Yang Shi
2021-03-08 6:52 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 08/13] mm: vmscan: use a new flag to indicate shrinker is registered Yang Shi
2021-02-17 2:00 ` Roman Gushchin
2021-03-08 17:48 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 09/13] mm: vmscan: add per memcg shrinker nr_deferred Yang Shi
2021-02-17 2:09 ` Roman Gushchin
2021-02-17 6:34 ` Kirill Tkhai
2021-03-08 19:12 ` Shakeel Butt
2021-03-08 20:30 ` Yang Shi
2021-03-08 21:11 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 10/13] mm: vmscan: use per memcg nr_deferred of shrinker Yang Shi
2021-02-17 2:10 ` Roman Gushchin
2021-02-17 6:39 ` Kirill Tkhai
2021-03-08 19:14 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 11/13] mm: vmscan: don't need allocate shrinker->nr_deferred for memcg aware shrinkers Yang Shi
2021-03-08 21:57 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 12/13] mm: memcontrol: reparent nr_deferred when memcg offline Yang Shi
2021-03-08 23:42 ` Shakeel Butt
2021-02-17 0:13 ` [v8 PATCH 13/13] mm: vmscan: shrink deferred objects proportional to priority Yang Shi
2021-02-25 17:00 ` [v8 PATCH 00/13] Make shrinker's nr_deferred memcg aware Yang Shi
2021-03-01 15:05 ` Johannes Weiner
2021-03-01 17:03 ` Yang Shi
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='CALvZod7Z6A=qFHOy2BODiTcK-fz=Yid5-LhbzofQBa8aemt1Lw@mail.gmail.com' \
--to=shakeelb@google.com \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=ktkhai@virtuozzo.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=shy828301@gmail.com \
--cc=vbabka@suse.cz \
/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).