Commit 9057c212b93709fa54e62d434502a64591cfa5e6

Authored by Mel Gorman
Committed by Jiri Slaby
1 parent d618a27c78

mm: avoid unnecessary atomic operations during end_page_writeback()

commit 888cf2db475a256fb0cda042140f73d7881f81fe upstream.

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>
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 1 changed file with 10 additions and 1 deletions Side-by-side Diff

... ... @@ -644,8 +644,17 @@
644 644 */
645 645 void end_page_writeback(struct page *page)
646 646 {
647   - if (TestClearPageReclaim(page))
  647 + /*
  648 + * TestClearPageReclaim could be used here but it is an atomic
  649 + * operation and overkill in this particular case. Failing to
  650 + * shuffle a page marked for immediate reclaim is too mild to
  651 + * justify taking an atomic operation penalty at the end of
  652 + * ever page writeback.
  653 + */
  654 + if (PageReclaim(page)) {
  655 + ClearPageReclaim(page);
648 656 rotate_reclaimable_page(page);
  657 + }
649 658  
650 659 if (!test_clear_page_writeback(page))
651 660 BUG();