From: Hugh Dickins <hughd@google.com>
To: "zhaowuyun@wingtech.com" <zhaowuyun@wingtech.com>
Cc: Hugh Dickins <hughd@google.com>, akpm <akpm@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>,
mgorman <mgorman@techsingularity.net>,
minchan <minchan@kernel.org>, vinmenon <vinmenon@codeaurora.org>,
hannes <hannes@cmpxchg.org>,
"hillf.zj" <hillf.zj@alibaba-inc.com>,
linux-mm <linux-mm@kvack.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Re: [PATCH] [PATCH] mm: disable preemption before swapcache_free
Date: Mon, 6 Aug 2018 20:23:02 -0700 (PDT) [thread overview]
Message-ID: <alpine.LSU.2.11.1808061936080.1570@eggly.anvils> (raw)
In-Reply-To: <20180807101540612373235@wingtech.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1700 bytes --]
On Tue, 7 Aug 2018, zhaowuyun@wingtech.com wrote:
>
> Thanks for affirming the modification of disabling preemption and
> pointing out the incompleteness, delete_from_swap_cache() needs the same protection.
> I'm curious about that why don't put swapcache_free(swap) under protection of mapping->tree_lock ??
That would violate the long-established lock ordering (see not-always-
kept-up-to-date comments at the head of mm/rmap.c). In particular,
swap_lock (and its more recent descendants, such as swap_info->lock)
can be held with interrupts enabled, whereas taking tree_lock (later
called i_pages lock) involves disabling interrupts. So: there would
be quite a lot of modifications required to do swapcache_free(swap)
under mapping->tree_lock.
Generally easier would be to take tree_lock under swap lock: that fits
the establishd lock ordering, and is already done in just a few places
- or am I thinking of free_swap_and_cache() in the old days before
find_get_page() did lockless lookup? But you didn't suggest that way,
because it's more awkward in the __remove_mapping() case: I expect
that could be worked around with an initial PageSwapCache check,
taking swap locks there first (not inside swapcache_free()) -
__remove_mapping()'s BUG_ON(!PageLocked) implies that won't be racy.
But either way round, why? What would be the advantage in doing so?
A more conventional nesting of locks, easier to describe and understand,
yes. But from a performance point of view, thinking of lock contention,
nothing but disadvantage. And don't forget the get_swap_page() end:
there it would be harder to deal with both locks together (at least
in the shmem case).
Hugh
prev parent reply other threads:[~2018-08-07 3:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 6:37 [PATCH] [PATCH] mm: disable preemption before swapcache_free zhaowuyun
2018-07-25 6:40 ` zhaowuyun
2018-07-25 7:40 ` Michal Hocko
2018-07-25 7:57 ` zhaowuyun
2018-07-25 8:21 ` Michal Hocko
2018-07-25 9:53 ` zhaowuyun
2018-07-25 10:34 ` Michal Hocko
2018-07-25 11:17 ` zhaowuyun
2018-07-25 10:32 ` Michal Hocko
2018-07-25 21:16 ` Andrew Morton
2018-07-26 2:21 ` zhaowuyun
2018-07-26 6:06 ` Michal Hocko
2018-07-26 7:03 ` zhaowuyun
2018-07-26 7:44 ` Michal Hocko
2018-07-26 22:11 ` Andrew Morton
2018-07-27 6:07 ` zhaowuyun
2018-08-04 23:07 ` Hugh Dickins
2018-08-07 2:15 ` zhaowuyun
2018-08-07 3:23 ` Hugh Dickins [this message]
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=alpine.LSU.2.11.1808061936080.1570@eggly.anvils \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hillf.zj@alibaba-inc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=minchan@kernel.org \
--cc=vinmenon@codeaurora.org \
--cc=zhaowuyun@wingtech.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).