Commit 16f8c5b2e64dec7faa5d3c7e9bdf0765e864e481

Authored by Hugh Dickins
Committed by Linus Torvalds
1 parent d0fd93781c

mm: page_remove_rmap comments on PageAnon

Add a comment to s390's page_test_dirty/page_clear_dirty/page_set_dirty
dance in page_remove_rmap(): I was wrong to think the PageSwapCache test
could be avoided, and would like a comment in there to remind me.  And
mention s390, to help us remember that this block is not really common.

Also move down the "It would be tidy to reset PageAnon" comment: it does
not belong to s390's block, and it would be unwise to reset PageAnon
before we're done with testing it.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 16 additions and 9 deletions Side-by-side Diff

... ... @@ -659,23 +659,30 @@
659 659 }
660 660  
661 661 /*
662   - * It would be tidy to reset the PageAnon mapping here,
663   - * but that might overwrite a racing page_add_anon_rmap
664   - * which increments mapcount after us but sets mapping
665   - * before us: so leave the reset to free_hot_cold_page,
666   - * and remember that it's only reliable while mapped.
667   - * Leaving it set also helps swapoff to reinstate ptes
668   - * faster for those pages still in swapcache.
  662 + * Now that the last pte has gone, s390 must transfer dirty
  663 + * flag from storage key to struct page. We can usually skip
  664 + * this if the page is anon, so about to be freed; but perhaps
  665 + * not if it's in swapcache - there might be another pte slot
  666 + * containing the swap entry, but page not yet written to swap.
669 667 */
670 668 if ((!PageAnon(page) || PageSwapCache(page)) &&
671 669 page_test_dirty(page)) {
672 670 page_clear_dirty(page);
673 671 set_page_dirty(page);
674 672 }
675   - mem_cgroup_uncharge_page(page);
676 673  
  674 + mem_cgroup_uncharge_page(page);
677 675 __dec_zone_page_state(page,
678   - PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
  676 + PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
  677 + /*
  678 + * It would be tidy to reset the PageAnon mapping here,
  679 + * but that might overwrite a racing page_add_anon_rmap
  680 + * which increments mapcount after us but sets mapping
  681 + * before us: so leave the reset to free_hot_cold_page,
  682 + * and remember that it's only reliable while mapped.
  683 + * Leaving it set also helps swapoff to reinstate ptes
  684 + * faster for those pages still in swapcache.
  685 + */
679 686 }
680 687 }
681 688