Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: convert page_get_anon_vma() to folio_get_anon_vma()

With all callers now passing in a folio, rename the function and convert
all callers. Removes a couple of calls to compound_head() and a reference
to page->mapping.

Link: https://lkml.kernel.org/r/20220902194653.1739778-55-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
29eea9b5 684555aa

+12 -12
+1 -1
include/linux/rmap.h
··· 163 163 unlink_anon_vmas(next); 164 164 } 165 165 166 - struct anon_vma *page_get_anon_vma(struct page *page); 166 + struct anon_vma *folio_get_anon_vma(struct folio *folio); 167 167 168 168 /* RMAP flags, currently only relevant for some anon rmap operations. */ 169 169 typedef int __bitwise rmap_t;
+1 -1
mm/huge_memory.c
··· 2649 2649 * is taken to serialise against parallel split or collapse 2650 2650 * operations. 2651 2651 */ 2652 - anon_vma = page_get_anon_vma(&folio->page); 2652 + anon_vma = folio_get_anon_vma(folio); 2653 2653 if (!anon_vma) { 2654 2654 ret = -EBUSY; 2655 2655 goto out;
+3 -3
mm/migrate.c
··· 1052 1052 * File Caches may use write_page() or lock_page() in migration, then, 1053 1053 * just care Anon page here. 1054 1054 * 1055 - * Only page_get_anon_vma() understands the subtleties of 1055 + * Only folio_get_anon_vma() understands the subtleties of 1056 1056 * getting a hold on an anon_vma from outside one of its mms. 1057 1057 * But if we cannot get anon_vma, then we won't need it anyway, 1058 1058 * because that implies that the anon page is no longer mapped 1059 1059 * (and cannot be remapped so long as we hold the page lock). 1060 1060 */ 1061 1061 if (folio_test_anon(src) && !folio_test_ksm(src)) 1062 - anon_vma = page_get_anon_vma(&src->page); 1062 + anon_vma = folio_get_anon_vma(src); 1063 1063 1064 1064 /* 1065 1065 * Block others from accessing the new page when we get around to ··· 1298 1298 } 1299 1299 1300 1300 if (folio_test_anon(src)) 1301 - anon_vma = page_get_anon_vma(&src->page); 1301 + anon_vma = folio_get_anon_vma(src); 1302 1302 1303 1303 if (unlikely(!folio_trylock(dst))) 1304 1304 goto put_anon;
+7 -7
mm/rmap.c
··· 486 486 * if there is a mapcount, we can dereference the anon_vma after observing 487 487 * those. 488 488 */ 489 - struct anon_vma *page_get_anon_vma(struct page *page) 489 + struct anon_vma *folio_get_anon_vma(struct folio *folio) 490 490 { 491 491 struct anon_vma *anon_vma = NULL; 492 492 unsigned long anon_mapping; 493 493 494 494 rcu_read_lock(); 495 - anon_mapping = (unsigned long)READ_ONCE(page->mapping); 495 + anon_mapping = (unsigned long)READ_ONCE(folio->mapping); 496 496 if ((anon_mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON) 497 497 goto out; 498 - if (!page_mapped(page)) 498 + if (!folio_mapped(folio)) 499 499 goto out; 500 500 501 501 anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON); ··· 505 505 } 506 506 507 507 /* 508 - * If this page is still mapped, then its anon_vma cannot have been 508 + * If this folio is still mapped, then its anon_vma cannot have been 509 509 * freed. But if it has been unmapped, we have no security against the 510 510 * anon_vma structure being freed and reused (for another anon_vma: 511 511 * SLAB_TYPESAFE_BY_RCU guarantees that - so the atomic_inc_not_zero() 512 512 * above cannot corrupt). 513 513 */ 514 - if (!page_mapped(page)) { 514 + if (!folio_mapped(folio)) { 515 515 rcu_read_unlock(); 516 516 put_anon_vma(anon_vma); 517 517 return NULL; ··· 523 523 } 524 524 525 525 /* 526 - * Similar to page_get_anon_vma() except it locks the anon_vma. 526 + * Similar to folio_get_anon_vma() except it locks the anon_vma. 527 527 * 528 528 * Its a little more complex as it tries to keep the fast path to a single 529 529 * atomic op -- the trylock. If we fail the trylock, we fall back to getting a 530 - * reference like with page_get_anon_vma() and then block on the mutex 530 + * reference like with folio_get_anon_vma() and then block on the mutex 531 531 * on !rwc->try_lock case. 532 532 */ 533 533 struct anon_vma *folio_lock_anon_vma_read(struct folio *folio,