Skip to content

Commit a520110

Browse files
Christoph Hellwigjgunthorpe
authored andcommitted
mm: split out a new pagewalk.h header from mm.h
Add a new header for the two handful of users of the walk_page_range / walk_page_vma interface instead of polluting all users of mm.h with it. Link: https://lore.kernel.org/r/20190828141955.22210-2-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 810e24e commit a520110

14 files changed

Lines changed: 66 additions & 55 deletions

File tree

‎arch/openrisc/kernel/dma.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include <linux/dma-noncoherent.h>
19+
#include <linux/pagewalk.h>
1920

2021
#include <asm/cpuinfo.h>
2122
#include <asm/spr_defs.h>

‎arch/powerpc/mm/book3s64/subpage_prot.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/kernel.h>
88
#include <linux/gfp.h>
99
#include <linux/types.h>
10-
#include <linux/mm.h>
10+
#include <linux/pagewalk.h>
1111
#include <linux/hugetlb.h>
1212
#include <linux/syscalls.h>
1313

‎arch/s390/mm/gmap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
#include <linux/kernel.h>
12-
#include <linux/mm.h>
12+
#include <linux/pagewalk.h>
1313
#include <linux/swap.h>
1414
#include <linux/smp.h>
1515
#include <linux/spinlock.h>

‎fs/proc/task_mmu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include <linux/mm.h>
2+
#include <linux/pagewalk.h>
33
#include <linux/vmacache.h>
44
#include <linux/hugetlb.h>
55
#include <linux/huge_mm.h>

‎include/linux/mm.h‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,54 +1430,8 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long address,
14301430
void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
14311431
unsigned long start, unsigned long end);
14321432

1433-
/**
1434-
* mm_walk - callbacks for walk_page_range
1435-
* @pud_entry: if set, called for each non-empty PUD (2nd-level) entry
1436-
* this handler should only handle pud_trans_huge() puds.
1437-
* the pmd_entry or pte_entry callbacks will be used for
1438-
* regular PUDs.
1439-
* @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry
1440-
* this handler is required to be able to handle
1441-
* pmd_trans_huge() pmds. They may simply choose to
1442-
* split_huge_page() instead of handling it explicitly.
1443-
* @pte_entry: if set, called for each non-empty PTE (4th-level) entry
1444-
* @pte_hole: if set, called for each hole at all levels
1445-
* @hugetlb_entry: if set, called for each hugetlb entry
1446-
* @test_walk: caller specific callback function to determine whether
1447-
* we walk over the current vma or not. Returning 0
1448-
* value means "do page table walk over the current vma,"
1449-
* and a negative one means "abort current page table walk
1450-
* right now." 1 means "skip the current vma."
1451-
* @mm: mm_struct representing the target process of page table walk
1452-
* @vma: vma currently walked (NULL if walking outside vmas)
1453-
* @private: private data for callbacks' usage
1454-
*
1455-
* (see the comment on walk_page_range() for more details)
1456-
*/
1457-
struct mm_walk {
1458-
int (*pud_entry)(pud_t *pud, unsigned long addr,
1459-
unsigned long next, struct mm_walk *walk);
1460-
int (*pmd_entry)(pmd_t *pmd, unsigned long addr,
1461-
unsigned long next, struct mm_walk *walk);
1462-
int (*pte_entry)(pte_t *pte, unsigned long addr,
1463-
unsigned long next, struct mm_walk *walk);
1464-
int (*pte_hole)(unsigned long addr, unsigned long next,
1465-
struct mm_walk *walk);
1466-
int (*hugetlb_entry)(pte_t *pte, unsigned long hmask,
1467-
unsigned long addr, unsigned long next,
1468-
struct mm_walk *walk);
1469-
int (*test_walk)(unsigned long addr, unsigned long next,
1470-
struct mm_walk *walk);
1471-
struct mm_struct *mm;
1472-
struct vm_area_struct *vma;
1473-
void *private;
1474-
};
1475-
14761433
struct mmu_notifier_range;
14771434

1478-
int walk_page_range(unsigned long addr, unsigned long end,
1479-
struct mm_walk *walk);
1480-
int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk);
14811435
void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
14821436
unsigned long end, unsigned long floor, unsigned long ceiling);
14831437
int copy_page_range(struct mm_struct *dst, struct mm_struct *src,

‎include/linux/pagewalk.h‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _LINUX_PAGEWALK_H
3+
#define _LINUX_PAGEWALK_H
4+
5+
#include <linux/mm.h>
6+
7+
/**
8+
* mm_walk - callbacks for walk_page_range
9+
* @pud_entry: if set, called for each non-empty PUD (2nd-level) entry
10+
* this handler should only handle pud_trans_huge() puds.
11+
* the pmd_entry or pte_entry callbacks will be used for
12+
* regular PUDs.
13+
* @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry
14+
* this handler is required to be able to handle
15+
* pmd_trans_huge() pmds. They may simply choose to
16+
* split_huge_page() instead of handling it explicitly.
17+
* @pte_entry: if set, called for each non-empty PTE (4th-level) entry
18+
* @pte_hole: if set, called for each hole at all levels
19+
* @hugetlb_entry: if set, called for each hugetlb entry
20+
* @test_walk: caller specific callback function to determine whether
21+
* we walk over the current vma or not. Returning 0
22+
* value means "do page table walk over the current vma,"
23+
* and a negative one means "abort current page table walk
24+
* right now." 1 means "skip the current vma."
25+
* @mm: mm_struct representing the target process of page table walk
26+
* @vma: vma currently walked (NULL if walking outside vmas)
27+
* @private: private data for callbacks' usage
28+
*
29+
* (see the comment on walk_page_range() for more details)
30+
*/
31+
struct mm_walk {
32+
int (*pud_entry)(pud_t *pud, unsigned long addr,
33+
unsigned long next, struct mm_walk *walk);
34+
int (*pmd_entry)(pmd_t *pmd, unsigned long addr,
35+
unsigned long next, struct mm_walk *walk);
36+
int (*pte_entry)(pte_t *pte, unsigned long addr,
37+
unsigned long next, struct mm_walk *walk);
38+
int (*pte_hole)(unsigned long addr, unsigned long next,
39+
struct mm_walk *walk);
40+
int (*hugetlb_entry)(pte_t *pte, unsigned long hmask,
41+
unsigned long addr, unsigned long next,
42+
struct mm_walk *walk);
43+
int (*test_walk)(unsigned long addr, unsigned long next,
44+
struct mm_walk *walk);
45+
struct mm_struct *mm;
46+
struct vm_area_struct *vma;
47+
void *private;
48+
};
49+
50+
int walk_page_range(unsigned long addr, unsigned long end,
51+
struct mm_walk *walk);
52+
int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk);
53+
54+
#endif /* _LINUX_PAGEWALK_H */

‎mm/hmm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Refer to include/linux/hmm.h for information about heterogeneous memory
99
* management or HMM for short.
1010
*/
11-
#include <linux/mm.h>
11+
#include <linux/pagewalk.h>
1212
#include <linux/hmm.h>
1313
#include <linux/init.h>
1414
#include <linux/rmap.h>

‎mm/madvise.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/file.h>
2121
#include <linux/blkdev.h>
2222
#include <linux/backing-dev.h>
23+
#include <linux/pagewalk.h>
2324
#include <linux/swap.h>
2425
#include <linux/swapops.h>
2526
#include <linux/shmem_fs.h>

‎mm/memcontrol.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <linux/page_counter.h>
2626
#include <linux/memcontrol.h>
2727
#include <linux/cgroup.h>
28-
#include <linux/mm.h>
28+
#include <linux/pagewalk.h>
2929
#include <linux/sched/mm.h>
3030
#include <linux/shmem_fs.h>
3131
#include <linux/hugetlb.h>

‎mm/mempolicy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
6969

7070
#include <linux/mempolicy.h>
71-
#include <linux/mm.h>
71+
#include <linux/pagewalk.h>
7272
#include <linux/highmem.h>
7373
#include <linux/hugetlb.h>
7474
#include <linux/kernel.h>

0 commit comments

Comments
 (0)