return (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
}
+static inline unsigned long vma_last_pgoff(struct vm_area_struct *vma)
+{
+ return vma->vm_pgoff + vma_pages(vma) - 1;
+}
+
static inline unsigned long vma_desc_size(const struct vm_area_desc *desc)
{
return desc->end - desc->start;
return v->vm_pgoff;
}
-static inline unsigned long vma_last_pgoff(struct vm_area_struct *v)
-{
- return v->vm_pgoff + vma_pages(v) - 1;
-}
-
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)
struct zap_details *details)
{
struct vm_area_struct *vma;
- pgoff_t vba, vea, zba, zea;
unsigned long start, size;
struct mmu_gather tlb;
vma_interval_tree_foreach(vma, root, first_index, last_index) {
- vba = vma->vm_pgoff;
- vea = vba + vma_pages(vma) - 1;
- zba = max(first_index, vba);
- zea = min(last_index, vea);
- start = ((zba - vba) << PAGE_SHIFT) + vma->vm_start;
- size = (zea - zba + 1) << PAGE_SHIFT;
+ const pgoff_t start_idx = max(first_index, vma->vm_pgoff);
+ const pgoff_t end_idx = min(last_index, vma_last_pgoff(vma)) + 1;
+
+ start = vma->vm_start + ((start_idx - vma->vm_pgoff) << PAGE_SHIFT);
+ size = (end_idx - start_idx) << PAGE_SHIFT;
tlb_gather_mmu(&tlb, vma->vm_mm);
zap_page_range_single_batched(&tlb, vma, start, size, details);