]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mm: do not use unnecessary atomic operations when adding pages to the LRU
authorMel Gorman <mgorman@suse.de>
Thu, 22 May 2014 00:43:21 +0000 (10:43 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:43:21 +0000 (10:43 +1000)
commitae6f1dea7a6b33c107d8b479c05cf31173389374
treef09244fc9dbb9efbc3e7b24a39773827e70ca970
parent0028308f36071628b0c553959fa6f03f302fa5fc
mm: do not use unnecessary atomic operations when adding pages to the LRU

When adding pages to the LRU we clear the active bit unconditionally.  As
the page could be reachable from other paths we cannot use unlocked
operations without risk of corruption such as a parallel
mark_page_accessed.  This patch tests if is necessary to clear the active
flag before using an atomic operation.  This potentially opens a tiny race
when PageActive is checked as mark_page_accessed could be called after
PageActive was checked.  The race already exists but this patch changes it
slightly.  The consequence is that that the page may be promoted to the
active list that might have been left on the inactive list before the
patch.  It's too tiny a race and too marginal a consequence to always use
atomic operations for.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Jan Kara <jack@suse.cz>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/swap.c