Skip to content

Commit eed05e5

Browse files
author
Matthew Wilcox (Oracle)
committed
mm: Add DEFINE_PAGE_VMA_WALK and DEFINE_FOLIO_VMA_WALK
Instead of declaring a struct page_vma_mapped_walk directly, use these helpers to allow us to transition to a PFN approach in the following patches. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
1 parent f087b90 commit eed05e5

File tree

7 files changed

+27
-56
lines changed

7 files changed

+27
-56
lines changed

include/linux/rmap.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,22 @@ struct page_vma_mapped_walk {
214214
unsigned int flags;
215215
};
216216

217+
#define DEFINE_PAGE_VMA_WALK(name, _page, _vma, _address, _flags) \
218+
struct page_vma_mapped_walk name = { \
219+
.page = _page, \
220+
.vma = _vma, \
221+
.address = _address, \
222+
.flags = _flags, \
223+
}
224+
225+
#define DEFINE_FOLIO_VMA_WALK(name, _folio, _vma, _address, _flags) \
226+
struct page_vma_mapped_walk name = { \
227+
.page = &_folio->page, \
228+
.vma = _vma, \
229+
.address = _address, \
230+
.flags = _flags, \
231+
}
232+
217233
static inline void page_vma_mapped_walk_done(struct page_vma_mapped_walk *pvmw)
218234
{
219235
/* HugeTLB pte is set to the relevant page table entry without pte_mapped. */

kernel/events/uprobes.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
155155
struct page *old_page, struct page *new_page)
156156
{
157157
struct mm_struct *mm = vma->vm_mm;
158-
struct page_vma_mapped_walk pvmw = {
159-
.page = compound_head(old_page),
160-
.vma = vma,
161-
.address = addr,
162-
};
158+
DEFINE_FOLIO_VMA_WALK(pvmw, page_folio(old_page), vma, addr, 0);
163159
int err;
164160
struct mmu_notifier_range range;
165161

mm/damon/paddr.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
static bool __damon_pa_mkold(struct page *page, struct vm_area_struct *vma,
2020
unsigned long addr, void *arg)
2121
{
22-
struct page_vma_mapped_walk pvmw = {
23-
.page = page,
24-
.vma = vma,
25-
.address = addr,
26-
};
22+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, addr, 0);
2723

2824
while (page_vma_mapped_walk(&pvmw)) {
2925
addr = pvmw.address;
@@ -93,11 +89,7 @@ static bool __damon_pa_young(struct page *page, struct vm_area_struct *vma,
9389
unsigned long addr, void *arg)
9490
{
9591
struct damon_pa_access_chk_result *result = arg;
96-
struct page_vma_mapped_walk pvmw = {
97-
.page = page,
98-
.vma = vma,
99-
.address = addr,
100-
};
92+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, addr, 0);
10193

10294
result->accessed = false;
10395
result->page_sz = PAGE_SIZE;

mm/ksm.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,10 +1034,7 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page,
10341034
pte_t *orig_pte)
10351035
{
10361036
struct mm_struct *mm = vma->vm_mm;
1037-
struct page_vma_mapped_walk pvmw = {
1038-
.page = page,
1039-
.vma = vma,
1040-
};
1037+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, 0, 0);
10411038
int swapped;
10421039
int err = -EFAULT;
10431040
struct mmu_notifier_range range;

mm/migrate.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,7 @@ void putback_movable_pages(struct list_head *l)
174174
static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
175175
unsigned long addr, void *old)
176176
{
177-
struct page_vma_mapped_walk pvmw = {
178-
.page = old,
179-
.vma = vma,
180-
.address = addr,
181-
.flags = PVMW_SYNC | PVMW_MIGRATION,
182-
};
177+
DEFINE_PAGE_VMA_WALK(pvmw, old, vma, addr, PVMW_SYNC | PVMW_MIGRATION);
183178
struct page *new;
184179
pte_t pte;
185180
swp_entry_t entry;

mm/page_idle.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ static bool page_idle_clear_pte_refs_one(struct page *page,
4848
struct vm_area_struct *vma,
4949
unsigned long addr, void *arg)
5050
{
51-
struct page_vma_mapped_walk pvmw = {
52-
.page = page,
53-
.vma = vma,
54-
.address = addr,
55-
};
51+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, addr, 0);
5652
bool referenced = false;
5753

5854
while (page_vma_mapped_walk(&pvmw)) {

mm/rmap.c

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,7 @@ static bool page_referenced_one(struct page *page, struct vm_area_struct *vma,
802802
unsigned long address, void *arg)
803803
{
804804
struct page_referenced_arg *pra = arg;
805-
struct page_vma_mapped_walk pvmw = {
806-
.page = page,
807-
.vma = vma,
808-
.address = address,
809-
};
805+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, address, 0);
810806
int referenced = 0;
811807

812808
while (page_vma_mapped_walk(&pvmw)) {
@@ -934,12 +930,7 @@ int page_referenced(struct page *page,
934930
static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
935931
unsigned long address, void *arg)
936932
{
937-
struct page_vma_mapped_walk pvmw = {
938-
.page = page,
939-
.vma = vma,
940-
.address = address,
941-
.flags = PVMW_SYNC,
942-
};
933+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, address, PVMW_SYNC);
943934
struct mmu_notifier_range range;
944935
int *cleaned = arg;
945936

@@ -1419,11 +1410,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
14191410
unsigned long address, void *arg)
14201411
{
14211412
struct mm_struct *mm = vma->vm_mm;
1422-
struct page_vma_mapped_walk pvmw = {
1423-
.page = page,
1424-
.vma = vma,
1425-
.address = address,
1426-
};
1413+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, address, 0);
14271414
pte_t pteval;
14281415
struct page *subpage;
14291416
bool ret = true;
@@ -1714,11 +1701,7 @@ static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma,
17141701
unsigned long address, void *arg)
17151702
{
17161703
struct mm_struct *mm = vma->vm_mm;
1717-
struct page_vma_mapped_walk pvmw = {
1718-
.page = page,
1719-
.vma = vma,
1720-
.address = address,
1721-
};
1704+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, address, 0);
17221705
pte_t pteval;
17231706
struct page *subpage;
17241707
bool ret = true;
@@ -2001,11 +1984,7 @@ static bool page_make_device_exclusive_one(struct page *page,
20011984
struct vm_area_struct *vma, unsigned long address, void *priv)
20021985
{
20031986
struct mm_struct *mm = vma->vm_mm;
2004-
struct page_vma_mapped_walk pvmw = {
2005-
.page = page,
2006-
.vma = vma,
2007-
.address = address,
2008-
};
1987+
DEFINE_PAGE_VMA_WALK(pvmw, page, vma, address, 0);
20091988
struct make_exclusive_args *args = priv;
20101989
pte_t pteval;
20111990
struct page *subpage;

0 commit comments

Comments
 (0)