Skip to content

Commit c4986f1

Browse files
davidhildenbrandakpm00
authored andcommitted
mm/rmap: move SetPageAnonExclusive() out of page_move_anon_rmap()
Patch series "mm/rmap: convert page_move_anon_rmap() to folio_move_anon_rmap()". Convert page_move_anon_rmap() to folio_move_anon_rmap(), letting the callers handle PageAnonExclusive. I'm including cleanup patch #3 because it fits into the picture and can be done cleaner by the conversion. This patch (of 3): Let's move it into the caller: there is a difference between whether an anon folio can only be mapped by one process (e.g., into one VMA), and whether it is truly exclusive (e.g., no references -- including GUP -- from other processes). Further, for large folios the page might not actually be pointing at the head page of the folio, so it better be handled in the caller. This is a preparation for converting page_move_anon_rmap() to consume a folio. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Suren Baghdasaryan <[email protected]> Reviewed-by: Vishal Moola (Oracle) <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Muchun Song <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 03f93c1 commit c4986f1

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

mm/huge_memory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf)
13771377
pmd_t entry;
13781378

13791379
page_move_anon_rmap(page, vma);
1380+
SetPageAnonExclusive(page);
13801381
folio_unlock(folio);
13811382
reuse:
13821383
if (unlikely(unshare)) {

mm/hugetlb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5646,8 +5646,10 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, struct vm_area_struct *vma,
56465646
* owner and can reuse this page.
56475647
*/
56485648
if (folio_mapcount(old_folio) == 1 && folio_test_anon(old_folio)) {
5649-
if (!PageAnonExclusive(&old_folio->page))
5649+
if (!PageAnonExclusive(&old_folio->page)) {
56505650
page_move_anon_rmap(&old_folio->page, vma);
5651+
SetPageAnonExclusive(&old_folio->page);
5652+
}
56515653
if (likely(!unshare))
56525654
set_huge_ptep_writable(vma, haddr, ptep);
56535655

mm/memory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,6 +3484,7 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf)
34843484
* sunglasses. Hit it.
34853485
*/
34863486
page_move_anon_rmap(vmf->page, vma);
3487+
SetPageAnonExclusive(vmf->page);
34873488
folio_unlock(folio);
34883489
reuse:
34893490
if (unlikely(unshare)) {

mm/rmap.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,6 @@ void page_move_anon_rmap(struct page *page, struct vm_area_struct *vma)
11521152
* folio_test_anon()) will not see one without the other.
11531153
*/
11541154
WRITE_ONCE(folio->mapping, anon_vma);
1155-
SetPageAnonExclusive(page);
11561155
}
11571156

11581157
/**

0 commit comments

Comments
 (0)