From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: kosaki.motohiro@jp.fujitsu.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Hugh Dickins <hugh.dickins@tiscali.co.uk>,
Mel Gorman <mel@csn.ul.ie>,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [rfc patch 3/3] mm: munlock COW pages on truncation unmap
Date: Tue, 6 Oct 2009 10:11:13 +0900 (JST) [thread overview]
Message-ID: <20091006100724.5F97.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20091005193200.GA13040@cmpxchg.org>
> ---
> From: Johannes Weiner <hannes@cmpxchg.org>
> Subject: mm: order evictable rescue in LRU putback
>
> Isolators putting a page back to the LRU do not hold the page lock,
> and if the page is mlocked, another thread might munlock it
> concurrently.
>
> Expecting this, the putback code re-checks the evictability of a page
> when it just moved it to the unevictable list in order to correct its
> decision.
>
> The problem, however, is that ordering is not garuanteed between
> setting PG_lru when moving the page to the list and checking
> PG_mlocked afterwards:
>
> #0 putback #1 munlock
>
> spin_lock()
> if (TestClearPageMlocked())
> if (PageLRU())
> move to evictable list
> SetPageLRU()
> spin_unlock()
> if (!PageMlocked())
> move to evictable list
>
> The PageMlocked() reading may get reordered before SetPageLRU() in #0,
> resulting in #0 not moving the still mlocked page, and in #1 failing
> to isolate and move the page as well. The evictable page is now
> stranded on the unevictable list.
>
> TestClearPageMlocked() in #1 already provides full memory barrier
> semantics.
>
> This patch adds an explicit full barrier to force ordering between
> SetPageLRU() and PageMlocked() in #0 so that either one of the
> competitors rescues the page.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
> Cc: Mel Gorman <mel@csn.ul.ie>
> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
> mm/vmscan.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -544,6 +544,16 @@ redo:
> */
> lru = LRU_UNEVICTABLE;
> add_page_to_unevictable_list(page);
> + /*
> + * When racing with an mlock clearing (page is
> + * unlocked), make sure that if the other thread does
> + * not observe our setting of PG_lru and fails
> + * isolation, we see PG_mlocked cleared below and move
> + * the page back to the evictable list.
> + *
> + * The other side is TestClearPageMlocked().
> + */
> + smp_mb();
> }
IA64 is most relax cpu reorder architecture. I'm usually test on it
and my test found no problem.
Then, I don't think this issue occur in the real world. but I think
this patch is right.
Hannes, you are great.
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
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>
next prev parent reply other threads:[~2009-10-06 1:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-30 21:09 [rfc patch 1/3] mm: always pass mapping in zap_details Johannes Weiner
2009-09-30 21:09 ` [rfc patch 2/3] mm: serialize truncation unmap against try_to_unmap() Johannes Weiner
2009-09-30 21:09 ` [rfc patch 3/3] mm: munlock COW pages on truncation unmap Johannes Weiner
2009-10-02 2:40 ` KOSAKI Motohiro
2009-10-02 23:38 ` Johannes Weiner
2009-10-03 13:56 ` KOSAKI Motohiro
2009-10-05 19:32 ` Johannes Weiner
2009-10-06 1:11 ` KOSAKI Motohiro [this message]
2009-10-06 7:44 ` KOSAKI Motohiro
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=20091006100724.5F97.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=Lee.Schermerhorn@hp.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hugh.dickins@tiscali.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
/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