vma.h (723e1e8b7756a552f4d6ddc8047bffe452187617) vma.h (2f1c6611b0a89afcb8641471af5f223c9caa01e0)
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * vma.h
4 *
5 * Core VMA manipulation API implemented in vma.c.
6 */
7#ifndef __MM_VMA_H
8#define __MM_VMA_H

--- 38 unchanged lines hidden (view full) ---

47 unsigned long nr_pages; /* Number of pages being removed */
48 unsigned long locked_vm; /* Number of locked pages */
49 unsigned long nr_accounted; /* Number of VM_ACCOUNT pages */
50 unsigned long exec_vm;
51 unsigned long stack_vm;
52 unsigned long data_vm;
53};
54
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * vma.h
4 *
5 * Core VMA manipulation API implemented in vma.c.
6 */
7#ifndef __MM_VMA_H
8#define __MM_VMA_H

--- 38 unchanged lines hidden (view full) ---

47 unsigned long nr_pages; /* Number of pages being removed */
48 unsigned long locked_vm; /* Number of locked pages */
49 unsigned long nr_accounted; /* Number of VM_ACCOUNT pages */
50 unsigned long exec_vm;
51 unsigned long stack_vm;
52 unsigned long data_vm;
53};
54
55/* Represents a VMA merge operation. */
56struct vma_merge_struct {
57 struct mm_struct *mm;
58 struct vma_iterator *vmi;
59 pgoff_t pgoff;
60 struct vm_area_struct *prev;
61 struct vm_area_struct *next; /* Modified by vma_merge(). */
62 struct vm_area_struct *vma; /* Either a new VMA or the one being modified. */
63 unsigned long start;
64 unsigned long end;
65 unsigned long flags;
66 struct file *file;
67 struct anon_vma *anon_vma;
68 struct mempolicy *policy;
69 struct vm_userfaultfd_ctx uffd_ctx;
70 struct anon_vma_name *anon_name;
71};
72
73/* Assumes addr >= vma->vm_start. */
74static inline pgoff_t vma_pgoff_offset(struct vm_area_struct *vma,
75 unsigned long addr)
76{
77 return vma->vm_pgoff + PHYS_PFN(addr - vma->vm_start);
78}
79
80#define VMG_STATE(name, mm_, vmi_, start_, end_, flags_, pgoff_) \
81 struct vma_merge_struct name = { \
82 .mm = mm_, \
83 .vmi = vmi_, \
84 .start = start_, \
85 .end = end_, \
86 .flags = flags_, \
87 .pgoff = pgoff_, \
88 }
89
90#define VMG_VMA_STATE(name, vmi_, prev_, vma_, start_, end_) \
91 struct vma_merge_struct name = { \
92 .mm = vma_->vm_mm, \
93 .vmi = vmi_, \
94 .prev = prev_, \
95 .next = NULL, \
96 .vma = vma_, \
97 .start = start_, \
98 .end = end_, \
99 .flags = vma_->vm_flags, \
100 .pgoff = vma_pgoff_offset(vma_, start_), \
101 .file = vma_->vm_file, \
102 .anon_vma = vma_->anon_vma, \
103 .policy = vma_policy(vma_), \
104 .uffd_ctx = vma_->vm_userfaultfd_ctx, \
105 .anon_name = anon_vma_name(vma_), \
106 }
107
55#ifdef CONFIG_DEBUG_VM_MAPLE_TREE
56void validate_mm(struct mm_struct *mm);
57#else
58#define validate_mm(mm) do { } while (0)
59#endif
60
61/* Required for expand_downwards(). */
62void anon_vma_interval_tree_pre_update_vma(struct vm_area_struct *vma);

--- 144 unchanged lines hidden (view full) ---

207 unsigned long start, size_t len, struct list_head *uf,
208 bool unlock);
209
210void remove_vma(struct vm_area_struct *vma, bool unreachable, bool closed);
211
212void unmap_region(struct ma_state *mas, struct vm_area_struct *vma,
213 struct vm_area_struct *prev, struct vm_area_struct *next);
214
108#ifdef CONFIG_DEBUG_VM_MAPLE_TREE
109void validate_mm(struct mm_struct *mm);
110#else
111#define validate_mm(mm) do { } while (0)
112#endif
113
114/* Required for expand_downwards(). */
115void anon_vma_interval_tree_pre_update_vma(struct vm_area_struct *vma);

--- 144 unchanged lines hidden (view full) ---

260 unsigned long start, size_t len, struct list_head *uf,
261 bool unlock);
262
263void remove_vma(struct vm_area_struct *vma, bool unreachable, bool closed);
264
265void unmap_region(struct ma_state *mas, struct vm_area_struct *vma,
266 struct vm_area_struct *prev, struct vm_area_struct *next);
267
215/* Required by mmap_region(). */
216bool
217can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
218 struct anon_vma *anon_vma, struct file *file,
219 pgoff_t vm_pgoff, struct vm_userfaultfd_ctx vm_userfaultfd_ctx,
220 struct anon_vma_name *anon_name);
268/*
269 * Can we merge the VMA described by vmg into the following VMA vmg->next?
270 *
271 * Required by mmap_region().
272 */
273bool can_vma_merge_before(struct vma_merge_struct *vmg);
221
274
222/* Required by mmap_region() and do_brk_flags(). */
223bool
224can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
225 struct anon_vma *anon_vma, struct file *file,
226 pgoff_t vm_pgoff, struct vm_userfaultfd_ctx vm_userfaultfd_ctx,
227 struct anon_vma_name *anon_name);
275/*
276 * Can we merge the VMA described by vmg into the preceding VMA vmg->prev?
277 *
278 * Required by mmap_region() and do_brk_flags().
279 */
280bool can_vma_merge_after(struct vma_merge_struct *vmg);
228
281
229struct vm_area_struct *vma_modify(struct vma_iterator *vmi,
230 struct vm_area_struct *prev,
231 struct vm_area_struct *vma,
232 unsigned long start, unsigned long end,
233 unsigned long vm_flags,
234 struct mempolicy *policy,
235 struct vm_userfaultfd_ctx uffd_ctx,
236 struct anon_vma_name *anon_name);
237
238/* We are about to modify the VMA's flags. */
282/* We are about to modify the VMA's flags. */
239static inline struct vm_area_struct
240*vma_modify_flags(struct vma_iterator *vmi,
241 struct vm_area_struct *prev,
242 struct vm_area_struct *vma,
243 unsigned long start, unsigned long end,
244 unsigned long new_flags)
245{
246 return vma_modify(vmi, prev, vma, start, end, new_flags,
247 vma_policy(vma), vma->vm_userfaultfd_ctx,
248 anon_vma_name(vma));
249}
283struct vm_area_struct *vma_modify_flags(struct vma_iterator *vmi,
284 struct vm_area_struct *prev, struct vm_area_struct *vma,
285 unsigned long start, unsigned long end,
286 unsigned long new_flags);
250
251/* We are about to modify the VMA's flags and/or anon_name. */
287
288/* We are about to modify the VMA's flags and/or anon_name. */
252static inline struct vm_area_struct
289struct vm_area_struct
253*vma_modify_flags_name(struct vma_iterator *vmi,
254 struct vm_area_struct *prev,
255 struct vm_area_struct *vma,
256 unsigned long start,
257 unsigned long end,
258 unsigned long new_flags,
290*vma_modify_flags_name(struct vma_iterator *vmi,
291 struct vm_area_struct *prev,
292 struct vm_area_struct *vma,
293 unsigned long start,
294 unsigned long end,
295 unsigned long new_flags,
259 struct anon_vma_name *new_name)
260{
261 return vma_modify(vmi, prev, vma, start, end, new_flags,
262 vma_policy(vma), vma->vm_userfaultfd_ctx, new_name);
263}
296 struct anon_vma_name *new_name);
264
265/* We are about to modify the VMA's memory policy. */
297
298/* We are about to modify the VMA's memory policy. */
266static inline struct vm_area_struct
299struct vm_area_struct
267*vma_modify_policy(struct vma_iterator *vmi,
268 struct vm_area_struct *prev,
269 struct vm_area_struct *vma,
270 unsigned long start, unsigned long end,
300*vma_modify_policy(struct vma_iterator *vmi,
301 struct vm_area_struct *prev,
302 struct vm_area_struct *vma,
303 unsigned long start, unsigned long end,
271 struct mempolicy *new_pol)
272{
273 return vma_modify(vmi, prev, vma, start, end, vma->vm_flags,
274 new_pol, vma->vm_userfaultfd_ctx, anon_vma_name(vma));
275}
304 struct mempolicy *new_pol);
276
277/* We are about to modify the VMA's flags and/or uffd context. */
305
306/* We are about to modify the VMA's flags and/or uffd context. */
278static inline struct vm_area_struct
307struct vm_area_struct
279*vma_modify_flags_uffd(struct vma_iterator *vmi,
280 struct vm_area_struct *prev,
281 struct vm_area_struct *vma,
282 unsigned long start, unsigned long end,
283 unsigned long new_flags,
308*vma_modify_flags_uffd(struct vma_iterator *vmi,
309 struct vm_area_struct *prev,
310 struct vm_area_struct *vma,
311 unsigned long start, unsigned long end,
312 unsigned long new_flags,
284 struct vm_userfaultfd_ctx new_ctx)
285{
286 return vma_modify(vmi, prev, vma, start, end, new_flags,
287 vma_policy(vma), new_ctx, anon_vma_name(vma));
288}
313 struct vm_userfaultfd_ctx new_ctx);
289
290struct vm_area_struct
291*vma_merge_new_vma(struct vma_iterator *vmi, struct vm_area_struct *prev,
292 struct vm_area_struct *vma, unsigned long start,
293 unsigned long end, pgoff_t pgoff);
294
295struct vm_area_struct *vma_merge_extend(struct vma_iterator *vmi,
296 struct vm_area_struct *vma,

--- 225 unchanged lines hidden ---
314
315struct vm_area_struct
316*vma_merge_new_vma(struct vma_iterator *vmi, struct vm_area_struct *prev,
317 struct vm_area_struct *vma, unsigned long start,
318 unsigned long end, pgoff_t pgoff);
319
320struct vm_area_struct *vma_merge_extend(struct vma_iterator *vmi,
321 struct vm_area_struct *vma,

--- 225 unchanged lines hidden ---