From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx115.postini.com [74.125.245.115]) by kanga.kvack.org (Postfix) with SMTP id B55DF6B0005 for ; Thu, 31 Jan 2013 18:29:43 -0500 (EST) Date: Fri, 1 Feb 2013 08:29:41 +0900 From: Minchan Kim Subject: Re: [patch 2/3 v2]swap: make each swap partition have one address_space Message-ID: <20130131232941.GA6262@blaptop> References: <20130122022951.GB12293@kernel.org> <20130123061645.GF2723@blaptop> <20130123073655.GA31672@kernel.org> <20130123080420.GI2723@blaptop> <1358991596.3351.9.camel@kernel> <20130124022241.GB22654@blaptop> <20130124024311.GA26602@kernel.org> <20130124051910.GD22654@blaptop> <20130124102414.GA10025@kernel.org> <20130131135042.ae633246.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130131135042.ae633246.akpm@linux-foundation.org> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Shaohua Li , Simon Jeons , linux-mm@kvack.org, hughd@google.com, riel@redhat.com 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 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: email@kvack.org