extern struct vm_area_struct *find_vma_intersection(struct mm_struct *mm,
unsigned long start_addr, unsigned long end_addr);
+static inline struct vm_area_struct *vma_next(struct mm_struct *mm,
+ const struct vm_area_struct *vma)
+{
+ MA_STATE(mas, &mm->mm_mt, 0, 0);
+
+ mas_set(&mas, vma->vm_end);
+ return mas_next(&mas, ULONG_MAX);
+}
+
+static inline struct vm_area_struct *vma_prev(struct mm_struct *mm,
+ const struct vm_area_struct *vma)
+{
+ MA_STATE(mas, &mm->mm_mt, 0, 0);
+
+ mas_set(&mas, vma->vm_start);
+ return mas_prev(&mas, 0);
+}
+
static inline unsigned long vm_start_gap(struct vm_area_struct *vma)
{
unsigned long vm_start = vma->vm_start;
return vma;
}
+static inline struct vm_area_struct *vma_mas_next(struct ma_state *mas)
+{
+ struct ma_state tmp;
+
+ memcpy(&tmp, mas, sizeof(tmp));
+ return mas_next(&tmp, ULONG_MAX);
+}
+
+static inline struct vm_area_struct *vma_mas_prev(struct ma_state *mas)
+{
+ struct ma_state tmp;
+
+ memcpy(&tmp, mas, sizeof(tmp));
+ return mas_prev(&tmp, 0);
+}
static inline bool range_in_vma(struct vm_area_struct *vma,
unsigned long start, unsigned long end)
{
}
/*
- * vma_next() - Get the next VMA.
+ * _vma_next() - Get the next VMA or the first.
* @mm: The mm_struct.
* @vma: The current vma.
*
*
* Returns: The next VMA after @vma.
*/
-static inline struct vm_area_struct *vma_next(struct mm_struct *mm,
+static inline struct vm_area_struct *_vma_next(struct mm_struct *mm,
struct vm_area_struct *vma)
{
if (!vma)
if (vm_flags & VM_SPECIAL)
return NULL;
- next = vma_next(mm, prev);
+ next = _vma_next(mm, prev);
area = next;
if (area && area->vm_end == end) /* cases 6, 7, 8 */
next = next->vm_next;
struct vm_area_struct *vma, struct vm_area_struct *prev,
unsigned long start, unsigned long end)
{
- struct vm_area_struct *next = vma_next(mm, prev);
+ struct vm_area_struct *next = _vma_next(mm, prev);
struct mmu_gather tlb;
lru_add_drain();
if (error)
return error;
prev = vma;
- vma = vma_next(mm, prev);
+ vma = _vma_next(mm, prev);
mas->index = start;
mas_reset(mas);
} else {
int error = __split_vma(mm, last, end, 1);
if (error)
return error;
- vma = vma_next(mm, prev);
+ vma = _vma_next(mm, prev);
mas_reset(mas);
}