History

mm/rmap: remove do_page_add_anon_rmap()

... and instead convert page_add_anon_rmap() to accept flags. Passing flags instead of bools is usually nicer either way, and we want to more often also pass RMAP_EXCLUSIVE in follow up patches when detecting that an anonymous page is exclusive: for example, when restoring an anonymous page from a writable migration entry. This is a preparation for marking an anonymous page inside page_add_anon_rmap() as exclusive when RMAP_EXCLUSIVE is passed.

David Hildenbrand committed 4 years ago

Commit f1e2db11 parent 14f91357 files · +8 −21Browse files

Unified · Split

7 files
  1. include/linux/rmap.h +0 −2
  2. mm/huge_memory.c +1 −1
  3. mm/ksm.c +1 −1
  4. mm/memory.c +2 −2
  5. mm/migrate.c +2 −1
  6. mm/rmap.c +1 −13
  7. mm/swapfile.c +1 −1
include/linux/rmap.h+0−2
@@ -183,8 +183,6 @@ typedef int __bitwise rmap_t; · 182 unmodified lines
183183 */
184184 void page_move_anon_rmap(struct page *, struct vm_area_struct *);
185185 void page_add_anon_rmap(struct page *, struct vm_area_struct *,
186− unsigned long address, bool compound);
187−void do_page_add_anon_rmap(struct page *, struct vm_area_struct *,
188186 unsigned long address, rmap_t flags);
189187 void page_add_new_anon_rmap(struct page *, struct vm_area_struct *,
190188 unsigned long address, bool compound);
mm/huge_memory.c+1−1
@@ -3072,7 +3072,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) · 3071 unmodified lines
30723072 pmde = pmd_wrprotect(pmd_mkuffd_wp(pmde));
30733073
30743074 if (PageAnon(new))
3075− page_add_anon_rmap(new, vma, mmun_start, true);
3075+ page_add_anon_rmap(new, vma, mmun_start, RMAP_COMPOUND);
30763076 else
30773077 page_add_file_rmap(new, vma, true);
30783078 set_pmd_at(mm, mmun_start, pvmw->pmd, pmde);
mm/ksm.c+1−1
@@ -1156,7 +1156,7 @@ static int replace_page(struct vm_area_struct *vma, struct page *page, · 1155 unmodified lines
11561156 */
11571157 if (!is_zero_pfn(page_to_pfn(kpage))) {
11581158 get_page(kpage);
1159− page_add_anon_rmap(kpage, vma, addr, false);
1159+ page_add_anon_rmap(kpage, vma, addr, RMAP_NONE);
11601160 newpte = mk_pte(kpage, vma->vm_page_prot);
11611161 } else {
11621162 newpte = pte_mkspecial(pfn_pte(page_to_pfn(kpage),
mm/memory.c+2−2
@@ -725,7 +725,7 @@ static void restore_exclusive_pte(struct vm_area_struct *vma, · 724 unmodified lines
725725 * created when the swap entry was made.
726726 */
727727 if (PageAnon(page))
728− page_add_anon_rmap(page, vma, address, false);
728+ page_add_anon_rmap(page, vma, address, RMAP_NONE);
729729 else
730730 /*
731731 * Currently device exclusive access only supports anonymous
@@ -3705,7 +3705,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) · 2973 unmodified lines
37053705 page_add_new_anon_rmap(page, vma, vmf->address, false);
37063706 lru_cache_add_inactive_or_unevictable(page, vma);
37073707 } else {
3708− do_page_add_anon_rmap(page, vma, vmf->address, rmap_flags);
3708+ page_add_anon_rmap(page, vma, vmf->address, rmap_flags);
37093709 }
37103710
37113711 set_pte_at(vma->vm_mm, vmf->address, vmf->pte, pte);
mm/migrate.c+2−1
@@ -240,7 +240,8 @@ static bool remove_migration_pte(struct folio *folio, · 239 unmodified lines
240240 #endif
241241 {
242242 if (folio_test_anon(folio))
243− page_add_anon_rmap(new, vma, pvmw.address, false);
243+ page_add_anon_rmap(new, vma, pvmw.address,
244+ RMAP_NONE);
244245 else
245246 page_add_file_rmap(new, vma, false);
246247 set_pte_at(vma->vm_mm, pvmw.address, pvmw.pte, pte);
mm/rmap.c+1−13
@@ -1171,7 +1171,7 @@ static void __page_check_anon_rmap(struct page *page, · 1170 unmodified lines
11711171 * @page: the page to add the mapping to
11721172 * @vma: the vm area in which the mapping is added
11731173 * @address: the user virtual address mapped
1174− * @compound: charge the page as compound or small page
1174+ * @flags: the rmap flags
11751175 *
11761176 * The caller needs to hold the pte lock, and the page must be locked in
11771177 * the anon_vma case: to serialize mapping,index checking after setting,
@@ -1179,18 +1179,6 @@ static void __page_check_anon_rmap(struct page *page, · 1 unmodified line
11791179 * (but PageKsm is never downgraded to PageAnon).
11801180 */
11811181 void page_add_anon_rmap(struct page *page,
1182− struct vm_area_struct *vma, unsigned long address, bool compound)
1183−{
1184− do_page_add_anon_rmap(page, vma, address,
1185− compound ? RMAP_COMPOUND : RMAP_NONE);
1186−}
1187−
1188−/*
1189− * Special version of the above for do_swap_page, which often runs
1190− * into pages that are exclusively owned by the current process.
1191− * Everybody else should continue to use page_add_anon_rmap above.
1192− */
1193−void do_page_add_anon_rmap(struct page *page,
11941182 struct vm_area_struct *vma, unsigned long address, rmap_t flags)
11951183 {
11961184 bool compound = flags & RMAP_COMPOUND;
mm/swapfile.c+1−1
@@ -1800,7 +1800,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, · 1799 unmodified lines
18001800 inc_mm_counter(vma->vm_mm, MM_ANONPAGES);
18011801 get_page(page);
18021802 if (page == swapcache) {
1803− page_add_anon_rmap(page, vma, addr, false);
1803+ page_add_anon_rmap(page, vma, addr, RMAP_NONE);
18041804 } else { /* ksm created a completely new copy */
18051805 page_add_new_anon_rmap(page, vma, addr, false);
18061806 lru_cache_add_inactive_or_unevictable(page, vma);