From: Minchan Kim <minchan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Shaohua Li <shli@kernel.org>, Simon Jeons <simon.jeons@gmail.com>,
linux-mm@kvack.org, hughd@google.com, riel@redhat.com
Subject: Re: [patch 2/3 v2]swap: make each swap partition have one address_space
Date: Fri, 1 Feb 2013 08:29:41 +0900 [thread overview]
Message-ID: <20130131232941.GA6262@blaptop> (raw)
In-Reply-To: <20130131135042.ae633246.akpm@linux-foundation.org>
Hi Andrew,
On Thu, Jan 31, 2013 at 01:50:42PM -0800, Andrew Morton wrote:
> On Thu, 24 Jan 2013 18:24:14 +0800
> Shaohua Li <shli@kernel.org> wrote:
>
> > Subject: mm: add memory barrier to prevent SwapCache bit and page private out of order
> >
> > page_mapping() checks SwapCache bit first and then read page private. Adding
> > memory barrier so page private has correct value before SwapCache bit set.
> >
> > In some cases, page_mapping() isn't called with page locked. Without doing
> > this, we might get a wrong swap address space with SwapCache bit set. Though I
> > didn't found a problem with this so far (such code typically only checks if the
> > page has mapping or the mapping can be dirty or migrated), this is too subtle
> > and error-prone, so we want to avoid it.
> >
> > ...
> >
> > --- linux.orig/mm/swap_state.c 2013-01-22 10:12:33.514490665 +0800
> > +++ linux/mm/swap_state.c 2013-01-24 18:08:05.149390977 +0800
> > @@ -89,6 +89,7 @@ static int __add_to_swap_cache(struct pa
> >
> > page_cache_get(page);
> > set_page_private(page, entry.val);
> > + smp_wmb();
> > SetPageSwapCache(page);
>
> SetPageSwapCache() uses set_bit() and arch/x86/include/asm/bitops.h
> says "This function is atomic and may not be reordered".
And says below.
* Note: there are no guarantees that this function will not be reordered
* on non x86 architectures, so if you are writing portable code,
* make sure not to rely on its reordering guarantees.
--
Kind regards,
Minchan Kim
--
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>
prev parent reply other threads:[~2013-01-31 23:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-22 2:29 [patch 2/3 v2]swap: make each swap partition have one address_space Shaohua Li
2013-01-22 19:49 ` Rik van Riel
2013-01-23 6:16 ` Minchan Kim
2013-01-23 7:36 ` Shaohua Li
2013-01-23 8:04 ` Minchan Kim
2013-01-24 1:39 ` Simon Jeons
2013-01-24 2:22 ` Minchan Kim
2013-01-24 2:43 ` Shaohua Li
2013-01-24 3:25 ` Simon Jeons
2013-01-24 10:35 ` Shaohua Li
2013-01-24 5:19 ` Minchan Kim
2013-01-24 6:14 ` Simon Jeons
2013-01-24 10:24 ` Shaohua Li
2013-01-31 21:50 ` Andrew Morton
2013-01-31 23:29 ` Minchan Kim [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=20130131232941.GA6262@blaptop \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.com \
--cc=shli@kernel.org \
--cc=simon.jeons@gmail.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 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.