]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm: avoid unnecessary atomic operations during end_page_writeback()
authorMel Gorman <mgorman@suse.de>
Thu, 22 May 2014 00:43:23 +0000 (10:43 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:43:23 +0000 (10:43 +1000)
If a page is marked for immediate reclaim then it is moved to the tail of
the LRU list.  This occurs when the system is under enough memory pressure
for pages under writeback to reach the end of the LRU but we test for this
using atomic operations on every writeback.  This patch uses an optimistic
non-atomic test first.  It'll miss some pages in rare cases but the
consequences are not severe enough to warrant such a penalty.

While the function does not dominate profiles during a simple dd test the
cost of it is reduced.

73048     0.7428  vmlinux-3.15.0-rc5-mmotm-20140513 end_page_writeback
23740     0.2409  vmlinux-3.15.0-rc5-lessatomic     end_page_writeback

Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/filemap.c

index 20da2acb16118f718f895dfdebea463ac8206540..edfdf94617c7a05b71370931cdfe879bc143ae47 100644 (file)
@@ -753,8 +753,17 @@ EXPORT_SYMBOL(unlock_page);
  */
 void end_page_writeback(struct page *page)
 {
-       if (TestClearPageReclaim(page))
+       /*
+        * TestClearPageReclaim could be used here but it is an atomic
+        * operation and overkill in this particular case. Failing to
+        * shuffle a page marked for immediate reclaim is too mild to
+        * justify taking an atomic operation penalty at the end of
+        * ever page writeback.
+        */
+       if (PageReclaim(page)) {
+               ClearPageReclaim(page);
                rotate_reclaimable_page(page);
+       }
 
        if (!test_clear_page_writeback(page))
                BUG();