If we also mark the struct folio argument to folio_anon_vma(), we can make page_address_in_vma() take a const struct page pointer. Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> --- include/linux/rmap.h | 2 +- mm/internal.h | 2 +- mm/rmap.c | 5 +++-- mm/util.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 0978c64f49d8..d1fca5b76039 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -732,7 +732,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw); /* * Used by swapoff to help locate where page is expected in vma. */ -unsigned long page_address_in_vma(struct page *, struct vm_area_struct *); +unsigned long page_address_in_vma(const struct page *, struct vm_area_struct *); /* * Cleans the PTEs of shared mappings. diff --git a/mm/internal.h b/mm/internal.h index b4d86436565b..e511708b2be0 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -810,7 +810,7 @@ static inline bool is_data_mapping(vm_flags_t flags) } /* mm/util.c */ -struct anon_vma *folio_anon_vma(struct folio *folio); +struct anon_vma *folio_anon_vma(const struct folio *folio); #ifdef CONFIG_MMU void unmap_mapping_folio(struct folio *folio); diff --git a/mm/rmap.c b/mm/rmap.c index 8616308610b9..886bf67ba382 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -771,9 +771,10 @@ static bool should_defer_flush(struct mm_struct *mm, enum ttu_flags flags) * At what user virtual address is page expected in vma? * Caller should check the page is actually part of the vma. */ -unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma) +unsigned long page_address_in_vma(const struct page *page, + struct vm_area_struct *vma) { - struct folio *folio = page_folio(page); + const struct folio *folio = page_folio(page); pgoff_t pgoff; if (folio_test_anon(folio)) { diff --git a/mm/util.c b/mm/util.c index bc488f0121a7..8afe3b90d650 100644 --- a/mm/util.c +++ b/mm/util.c @@ -780,7 +780,7 @@ void *vcalloc_noprof(size_t n, size_t size) } EXPORT_SYMBOL(vcalloc_noprof); -struct anon_vma *folio_anon_vma(struct folio *folio) +struct anon_vma *folio_anon_vma(const struct folio *folio) { unsigned long mapping = (unsigned long)folio->mapping; -- 2.43.0