lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 20 Apr 2011 17:00:29 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Andrea Arcangeli <aarcange@...hat.com>,
	Avi Kivity <avi@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Rik van Riel <riel@...hat.com>, Ingo Molnar <mingo@...e.hu>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
	linux-mm@...ck.org,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>,
	David Miller <davem@...emloft.net>,
	Hugh Dickins <hugh.dickins@...cali.co.uk>,
	Mel Gorman <mel@....ul.ie>, Nick Piggin <npiggin@...nel.dk>,
	Paul McKenney <paulmck@...ux.vnet.ibm.com>,
	Yanmin Zhang <yanmin_zhang@...ux.intel.com>
Subject: Re: [PATCH 20/20] mm: Optimize page_lock_anon_vma() fast-path

On Wed, 2011-04-20 at 14:38 +0200, Peter Zijlstra wrote:
> > > +   if (!page_mapped(page)) {
> > > +           put_anon_vma(anon_vma);
> > > +           anon_vma = NULL;
> > > +           goto out;
> > > +   }
> > 
> > Also quite opaque, needs decent commentary.
> > 
> > I'd have expected this test to occur after the lock was acquired.
> 
> Right, so I think we could drop that test from both here and
> page_get_anon_vma() and nothing would break, its simply avoiding some
> work in case we do detect the race with page_remove_rmap().
> 
> So yes, I think I'll move it down because that'll widen the scope of
> this optimization. 

OK, so I went trawling through the linux-mm logs and actually found why
this is needed under rcu_read_lock(), sadly I cannot seem to find a web
reference to 2006 linux-mm emails.

It was Hugh who noted that page_remove_rmap() only decrements
page->_mapcount but does not clear page->mapping, therefore we must test
page_mapped() after reading page->mapping while under the
rcu_read_lock() in order to determine if the pointer obtained is still
valid.

The comment that exists today in __page_lock_anon_vma() actually tries
to explain this


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ