1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_PAGEWALK_H
3 #define _LINUX_PAGEWALK_H
10 * mm_walk_ops - callbacks for walk_page_range
11 * @pgd_entry: if set, called for each non-empty PGD (top-level) entry
12 * @p4d_entry: if set, called for each non-empty P4D entry
13 * @pud_entry: if set, called for each non-empty PUD entry
14 * @pmd_entry: if set, called for each non-empty PMD entry
15 * this handler is required to be able to handle
16 * pmd_trans_huge() pmds. They may simply choose to
17 * split_huge_page() instead of handling it explicitly.
18 * @pte_entry: if set, called for each non-empty PTE (lowest-level)
20 * @pte_hole: if set, called for each hole at all levels
21 * @hugetlb_entry: if set, called for each hugetlb entry
22 * @test_walk: caller specific callback function to determine whether
23 * we walk over the current vma or not. Returning 0 means
24 * "do page table walk over the current vma", returning
25 * a negative value means "abort current page table walk
26 * right now" and returning 1 means "skip the current vma"
28 * p?d_entry callbacks are called even if those levels are folded on a
29 * particular architecture/configuration.
32 int (*pgd_entry)(pgd_t *pgd, unsigned long addr,
33 unsigned long next, struct mm_walk *walk);
34 int (*p4d_entry)(p4d_t *p4d, unsigned long addr,
35 unsigned long next, struct mm_walk *walk);
36 int (*pud_entry)(pud_t *pud, unsigned long addr,
37 unsigned long next, struct mm_walk *walk);
38 int (*pmd_entry)(pmd_t *pmd, unsigned long addr,
39 unsigned long next, struct mm_walk *walk);
40 int (*pte_entry)(pte_t *pte, unsigned long addr,
41 unsigned long next, struct mm_walk *walk);
42 int (*pte_hole)(unsigned long addr, unsigned long next,
43 struct mm_walk *walk);
44 int (*hugetlb_entry)(pte_t *pte, unsigned long hmask,
45 unsigned long addr, unsigned long next,
46 struct mm_walk *walk);
47 int (*test_walk)(unsigned long addr, unsigned long next,
48 struct mm_walk *walk);
52 * Action for pud_entry / pmd_entry callbacks.
53 * ACTION_SUBTREE is the default
55 enum page_walk_action {
56 /* Descend to next level, splitting huge pages if needed and possible */
58 /* Continue to next entry at this level (ignoring any subtree) */
60 /* Call again for this entry */
65 * mm_walk - walk_page_range data
66 * @ops: operation to call during the walk
67 * @mm: mm_struct representing the target process of page table walk
68 * @vma: vma currently walked (NULL if walking outside vmas)
69 * @action: next action to perform (see enum page_walk_action)
70 * @private: private data for callbacks' usage
72 * (see the comment on walk_page_range() for more details)
75 const struct mm_walk_ops *ops;
77 struct vm_area_struct *vma;
78 enum page_walk_action action;
82 int walk_page_range(struct mm_struct *mm, unsigned long start,
83 unsigned long end, const struct mm_walk_ops *ops,
85 int walk_page_vma(struct vm_area_struct *vma, const struct mm_walk_ops *ops,
88 #endif /* _LINUX_PAGEWALK_H */