Re: [PATCH v2 01/33] mm: move vma_start_pgoff() into mm.h and clean up
From: "Liam R. Howlett" <liam@infradead.org>
Date: 2026-07-15 18:06:57
Also in:
damon, dri-devel, kvm, linux-arm-msm, linux-fsdevel, linux-iommu, linux-mm, linux-perf-users, linux-tegra, lkml, nvdimm
On 26/07/10 09:16PM, Lorenzo Stoakes wrote:
vma_last_pgoff() already lives there, so it's a bit odd to keep vma_start_pgoff() in mm/interval_tree.c. Move them together. These each return unsigned long, which pgoff_t is typedef'd to. Make this consistent and have these functions return pgoff_t instead. Additionally, express vma_last_pgoff() in terms of vma_start_pgoff(), since we wrap the vma->vm_pgoff access, we may as well use it here. Also while we're here, const-ify the VMA and cleanup a bit. Also update the VMA userland tests to reflect the change.
This patch could have been 01/35? Disappointing, but I will try to get over it.
No functional change intended. Reviewed-by: Gregory Price <gourry@gourry.net> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
Reviewed-by: Liam R. Howlett (Oracle) <liam@infradead.org>
quoted hunk ↗ jump to hunk
--- include/linux/mm.h | 9 +++++++-- mm/interval_tree.c | 5 ----- tools/testing/vma/include/dup.h | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-)diff --git a/include/linux/mm.h b/include/linux/mm.h index 25e669632d2c..09b06d8fea74 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h@@ -4307,9 +4307,14 @@ static inline unsigned long vma_pages(const struct vm_area_struct *vma) return (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; } -static inline unsigned long vma_last_pgoff(struct vm_area_struct *vma) +static inline pgoff_t vma_start_pgoff(const struct vm_area_struct *vma) { - return vma->vm_pgoff + vma_pages(vma) - 1; + return vma->vm_pgoff; +} + +static inline pgoff_t vma_last_pgoff(const struct vm_area_struct *vma) +{ + return vma_start_pgoff(vma) + vma_pages(vma) - 1; } static inline unsigned long vma_desc_size(const struct vm_area_desc *desc)diff --git a/mm/interval_tree.c b/mm/interval_tree.c index 32bcfbfcf15f..344d1f5946c7 100644 --- a/mm/interval_tree.c +++ b/mm/interval_tree.c@@ -10,11 +10,6 @@ #include <linux/rmap.h> #include <linux/interval_tree_generic.h> -static inline unsigned long vma_start_pgoff(struct vm_area_struct *v) -{ - return v->vm_pgoff; -} - INTERVAL_TREE_DEFINE(struct vm_area_struct, shared.rb, unsigned long, shared.rb_subtree_last, vma_start_pgoff, vma_last_pgoff, /* empty */, vma_interval_tree)diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h index bf26b3f48d3a..668650067c7c 100644 --- a/tools/testing/vma/include/dup.h +++ b/tools/testing/vma/include/dup.h@@ -1301,6 +1301,11 @@ static inline unsigned long vma_pages(const struct vm_area_struct *vma) return (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; } +static inline pgoff_t vma_start_pgoff(const struct vm_area_struct *vma) +{ + return vma->vm_pgoff; +} + static inline int vfs_mmap_prepare(struct file *file, struct vm_area_desc *desc) { return file->f_op->mmap_prepare(desc);-- 2.55.0