Re: [PATCH 16/30] mm/vma: use vma_start_pgoff(), linear_page_index() in mm code
Lorenzo Stoakes <[email protected]> Thu, 2 Jul 2026 11:49:27 +0100
| Newsgroups | org.kernel.vger.linux-sgx,dev.linux.lists.damon,dev.linux.lists.iommu,dev.linux.lists.nvdimm,org.freedesktop.lists.dri-devel,org.kernel.vger.kvm,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-parisc,org.kernel.vger.linux-perf-users,org.kernel.vger.linux-tegra,org.kernel.vger.linux-trace-kernel |
|---|---|
| Message-ID | <akZCKKOiXBaHrbya@lucifer> |
On Thu, Jul 02, 2026 at 11:47:10AM +0100, Pedro Falcato wrote: > small nit: perhaps the subject should simply have mm: as it hits mm in general > > On Mon, Jun 29, 2026 at 01:23:27PM +0100, Lorenzo Stoakes wrote: > > There are many instances in which linear_page_index() (as well as > > linear_page_delta()) is open-coded, which is confusing and inconsistent. > > > > Additionally, vma->vm_pgoff doesn't necessarily make it clear that this is > > the page offset of the start of the VMA range. > > > > Doing so also aids greppability. > > > > So use vma_start_pgoff() in favour of directly accessing vma->vm_pgoff, and > > linear_page_index() where we can. > > > > This also lays the ground for future changes which will add an anonymous > > page offset in order to be able to index MAP_PRIVATE-file backed anon > > folios in terms of their virtual page offset. > > > > No functional change intended. > > > > Signed-off-by: Lorenzo Stoakes <[email protected]> > > --- > > include/linux/huge_mm.h | 1 + > > include/linux/hugetlb.h | 3 +-- > > include/linux/pagemap.h | 2 +- > > mm/damon/vaddr.c | 5 +++-- > > mm/debug.c | 2 +- > > mm/filemap.c | 7 ++++--- > > mm/huge_memory.c | 2 +- > > mm/hugetlb.c | 11 ++++------- > > mm/internal.h | 24 ++++++++++++++---------- > > mm/khugepaged.c | 3 ++- > > mm/madvise.c | 6 +++--- > > mm/mapping_dirty_helpers.c | 2 +- > > mm/memory.c | 25 +++++++++++++------------ > > mm/mempolicy.c | 13 +++++++------ > > mm/mremap.c | 12 ++++-------- > > mm/msync.c | 4 ++-- > > mm/nommu.c | 7 ++++--- > > mm/pagewalk.c | 2 +- > > mm/shmem.c | 9 +++++---- > > mm/userfaultfd.c | 4 ++-- > > mm/util.c | 4 ++-- > > mm/vma.c | 15 +++++++-------- > > mm/vma_exec.c | 4 ++-- > > mm/vma_init.c | 2 +- > > 24 files changed, 86 insertions(+), 83 deletions(-) > > > > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > > index ad20f7f8c179..653b81d08fe7 100644 > > --- a/include/linux/huge_mm.h > > +++ b/include/linux/huge_mm.h > > @@ -230,6 +230,7 @@ static inline bool thp_vma_suitable_order(struct vm_area_struct *vma, > > > > /* Don't have to check pgoff for anonymous vma */ > > if (!vma_is_anonymous(vma)) { > > + /* vma_start_pgoff() in mm.h so not available. */ > > Yay for gigaheaders... Yup C headers are a constant pain :) > > > if (!IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff, > > hpage_size >> PAGE_SHIFT)) > > return false; > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > > index 2abaf99321e9..8390f50604d6 100644 > > --- a/include/linux/hugetlb.h > > +++ b/include/linux/hugetlb.h > > @@ -792,8 +792,7 @@ static inline pgoff_t hugetlb_linear_page_index(struct vm_area_struct *vma, > > { > > struct hstate *h = hstate_vma(vma); > > > > - return ((address - vma->vm_start) >> huge_page_shift(h)) + > > - (vma->vm_pgoff >> huge_page_order(h)); > > + return linear_page_index(vma, address) >> huge_page_order(h); > > } > > > > Anyway, nothing jumped out at me. > > Reviewed-by: Pedro Falcato <[email protected]> Thanks! > > > -- > Pedro Cheers, Lorenzo