Commit 6d3e133532cd49fa925fe5c2a949c5900afd601c

Authored by Mel Gorman
Committed by Jiri Slaby
1 parent f161eedc71

mm: shmem: avoid atomic operation during shmem_getpage_gfp

commit 07a427884348d38a6fd56fa4d78249c407196650 upstream.

shmem_getpage_gfp uses an atomic operation to set the SwapBacked field
before it's even added to the LRU or visible.  This is unnecessary as what
could it possible race against?  Use an unlocked variant.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Rik van Riel <riel@redhat.com>
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: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>

Showing 2 changed files with 2 additions and 1 deletions Side-by-side Diff

include/linux/page-flags.h
... ... @@ -208,6 +208,7 @@
208 208 PAGEFLAG(SavePinned, savepinned); /* Xen */
209 209 PAGEFLAG(Reserved, reserved) __CLEARPAGEFLAG(Reserved, reserved)
210 210 PAGEFLAG(SwapBacked, swapbacked) __CLEARPAGEFLAG(SwapBacked, swapbacked)
  211 + __SETPAGEFLAG(SwapBacked, swapbacked)
211 212  
212 213 __PAGEFLAG(SlobFree, slob_free)
213 214  
... ... @@ -1142,7 +1142,7 @@
1142 1142 goto decused;
1143 1143 }
1144 1144  
1145   - SetPageSwapBacked(page);
  1145 + __SetPageSwapBacked(page);
1146 1146 __set_page_locked(page);
1147 1147 error = mem_cgroup_cache_charge(page, current->mm,
1148 1148 gfp & GFP_RECLAIM_MASK);