Skip to contentSkip to conversation

cleanup the walk_page_range interface

PATCH In review Christoph Hellwig 10 participants 29 messages Aug 8, 2019 – Aug 28, 2019

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

Hi all,

this series is based on a patch from Linus to split the callbacks passed to walk_page_range and walk_page_vma into a separate structure that can be marked const, with various cleanups from me on top.

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

This series is also available as a git tre here:

git://git.infradead.org/users/hch/misc.git pagewalk-cleanup

Gitweb:

http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/pagewalk-cleanup

Diffstat:

    14 files changed, 285 insertions(+), 278 deletions(-)
#1 lore raw

PATCH 1/3 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.

---
 arch/openrisc/kernel/dma.c              |  1 +
 arch/powerpc/mm/book3s64/subpage_prot.c |  2 +-
 arch/s390/mm/gmap.c                     |  2 +-
 fs/proc/task_mmu.c                      |  2 +-
 include/linux/mm.h                      | 46 ---------------------
 include/linux/pagewalk.h                | 54 +++++++++++++++++++++++++
 mm/hmm.c                                |  2 +-
 mm/madvise.c                            |  1 +
 mm/memcontrol.c                         |  2 +-
 mm/mempolicy.c                          |  2 +-
 mm/migrate.c                            |  1 +
 mm/mincore.c                            |  2 +-
 mm/mprotect.c                           |  2 +-
 mm/pagewalk.c                           |  2 +-
 14 files changed, 66 insertions(+), 55 deletions(-)
 create mode 100644 include/linux/pagewalk.h
arch/openrisc/kernel/dma.c +1 -0
index b41a79fcdbd9..c7812e6effa2 100644
@@ -16,6 +16,7 @@
  */
 
 #include <linux/dma-noncoherent.h>
+#include <linux/pagewalk.h>
 
 #include <asm/cpuinfo.h>
 #include <asm/spr_defs.h>
arch/powerpc/mm/book3s64/subpage_prot.c +1 -1
index 9ba07e55c489..236f0a861ecc 100644
@@ -7,7 +7,7 @@
 #include <linux/kernel.h>
 #include <linux/gfp.h>
 #include <linux/types.h>
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/hugetlb.h>
 #include <linux/syscalls.h>
 
arch/s390/mm/gmap.c +1 -1
index 39c3a6e3d262..cf80feae970d 100644
@@ -9,7 +9,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/swap.h>
 #include <linux/smp.h>
 #include <linux/spinlock.h>
fs/proc/task_mmu.c +1 -1
index 731642e0f5a0..8857da830b86 100644
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/vmacache.h>
 #include <linux/hugetlb.h>
 #include <linux/huge_mm.h>
include/linux/mm.h +0 -46

54 lines not on this page · raw message

include/linux/pagewalk.h new file +54 -0

54 lines not on this page · raw message

mm/hmm.c +1 -1
index 16b6731a34db..909b846c11d4 100644
@@ -8,7 +8,7 @@
  * Refer to include/linux/hmm.h for information about heterogeneous memory
  * management or HMM for short.
  */
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/hmm.h>
 #include <linux/init.h>
 #include <linux/rmap.h>
mm/madvise.c +1 -0
index 968df3aa069f..80a78bb16782 100644
@@ -20,6 +20,7 @@
 #include <linux/file.h>
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
+#include <linux/pagewalk.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <linux/shmem_fs.h>
mm/memcontrol.c +1 -1
index cdbb7a84cb6e..ee01175e56d4 100644
@@ -25,7 +25,7 @@
 #include <linux/page_counter.h>
 #include <linux/memcontrol.h>
 #include <linux/cgroup.h>
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/sched/mm.h>
 #include <linux/shmem_fs.h>
 #include <linux/hugetlb.h>
mm/mempolicy.c +1 -1
index f48693f75b37..1ee6b6f49431 100644
@@ -68,7 +68,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/mempolicy.h>
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/highmem.h>
 #include <linux/hugetlb.h>
 #include <linux/kernel.h>
mm/migrate.c +1 -0
index a42858d8e00b..019c426c6ef7 100644
@@ -38,6 +38,7 @@
 #include <linux/hugetlb.h>
 #include <linux/hugetlb_cgroup.h>
 #include <linux/gfp.h>
+#include <linux/pagewalk.h>
 #include <linux/pfn_t.h>
 #include <linux/memremap.h>
 #include <linux/userfaultfd_k.h>
mm/mincore.c +1 -1
index 4fe91d497436..3b051b6ab3fe 100644
@@ -10,7 +10,7 @@
  */
 #include <linux/pagemap.h>
 #include <linux/gfp.h>
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/mman.h>
 #include <linux/syscalls.h>
 #include <linux/swap.h>
mm/mprotect.c +1 -1
index bf38dfbbb4b4..cc73318dbc25 100644
@@ -9,7 +9,7 @@
  *  (C) Copyright 2002 Red Hat Inc, All Rights Reserved
  */
 
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/hugetlb.h>
 #include <linux/shm.h>
 #include <linux/mman.h>
mm/pagewalk.c +1 -1
index c3084ff2569d..8a92a961a2ee 100644
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <linux/mm.h>
+#include <linux/pagewalk.h>
 #include <linux/highmem.h>
 #include <linux/sched.h>
 #include <linux/hugetlb.h>
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/3 pagewalk: seperate function pointers from iterator data

In reply to Christoph Hellwig

The mm_walk structure currently mixed data and code. Split out the operations vectors into a new mm_walk_ops structure, and while we are changing the API also declare the mm_walk structure inside the walk_page_range and walk_page_vma functions.

Based on patch from Linus Torvalds.

---
 arch/openrisc/kernel/dma.c              |  22 +++--
 arch/powerpc/mm/book3s64/subpage_prot.c |  10 +-
 arch/s390/mm/gmap.c                     |  33 +++----
 fs/proc/task_mmu.c                      |  74 +++++++--------
 include/linux/pagewalk.h                |  64 +++++++------
 mm/hmm.c                                |  40 +++-----
 mm/madvise.c                            |  41 +++-----
 mm/memcontrol.c                         |  23 +++--
 mm/mempolicy.c                          |  15 ++-
 mm/migrate.c                            |  15 ++-
 mm/mincore.c                            |  15 ++-
 mm/mprotect.c                           |  24 ++---
 mm/pagewalk.c                           | 118 ++++++++++++++----------
 13 files changed, 245 insertions(+), 249 deletions(-)
arch/openrisc/kernel/dma.c +12 -10
index c7812e6effa2..4d5b8bd1d795 100644
@@ -44,6 +44,10 @@ page_set_nocache(pte_t *pte, unsigned long addr,
 	return 0;
 }
 
+static const struct mm_walk_ops set_nocache_walk_ops = {
+	.pte_entry		= page_set_nocache,
+};
+
 static int
 page_clear_nocache(pte_t *pte, unsigned long addr,
 		   unsigned long next, struct mm_walk *walk)
@@ -59,6 +63,10 @@ page_clear_nocache(pte_t *pte, unsigned long addr,
 	return 0;
 }
 
+static const struct mm_walk_ops clear_nocache_walk_ops = {
+	.pte_entry		= page_clear_nocache,
+};
+
 /*
  * Alloc "coherent" memory, which for OpenRISC means simply uncached.
  *
@@ -81,10 +89,6 @@ arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
 {
 	unsigned long va;
 	void *page;
-	struct mm_walk walk = {
-		.pte_entry = page_set_nocache,
-		.mm = &init_mm
-	};
 
 	page = alloc_pages_exact(size, gfp | __GFP_ZERO);
 	if (!page)
@@ -99,7 +103,8 @@ arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
 	 * We need to iterate through the pages, clearing the dcache for
 	 * them and setting the cache-inhibit bit.
 	 */
-	if (walk_page_range(va, va + size, &walk)) {
+	if (walk_page_range(&init_mm, va, va + size, &set_nocache_walk_ops,
+			NULL)) {
 		free_pages_exact(page, size);
 		return NULL;
 	}
@@ -112,13 +117,10 @@ arch_dma_free(struct device *dev, size_t size, void *vaddr,
 		dma_addr_t dma_handle, unsigned long attrs)
 {
 	unsigned long va = (unsigned long)vaddr;
-	struct mm_walk walk = {
-		.pte_entry = page_clear_nocache,
-		.mm = &init_mm
-	};
 
 	/* walk_page_range shouldn't be able to fail here */
-	WARN_ON(walk_page_range(va, va + size, &walk));
+	WARN_ON(walk_page_range(&init_mm, va, va + size,
+			&clear_nocache_walk_ops, NULL));
 
 	free_pages_exact(vaddr, size);
 }
arch/powerpc/mm/book3s64/subpage_prot.c +5 -5
index 236f0a861ecc..2ef24a53f4c9 100644
@@ -139,14 +139,14 @@ static int subpage_walk_pmd_entry(pmd_t *pmd, unsigned long addr,
 	return 0;
 }
 
+static const struct mm_walk_ops subpage_walk_ops = {
+	.pmd_entry	= subpage_walk_pmd_entry,
+};
+
 static void subpage_mark_vma_nohuge(struct mm_struct *mm, unsigned long addr,
 				    unsigned long len)
 {
 	struct vm_area_struct *vma;
-	struct mm_walk subpage_proto_walk = {
-		.mm = mm,
-		.pmd_entry = subpage_walk_pmd_entry,
-	};
 
 	/*
 	 * We don't try too hard, we just mark all the vma in that range
@@ -163,7 +163,7 @@ static void subpage_mark_vma_nohuge(struct mm_struct *mm, unsigned long addr,
 		if (vma->vm_start >= (addr + len))
 			break;
 		vma->vm_flags |= VM_NOHUGEPAGE;
-		walk_page_vma(vma, &subpage_proto_walk);
+		walk_page_vma(vma, &subpage_walk_ops, NULL);
 		vma = vma->vm_next;
 	}
 }
arch/s390/mm/gmap.c +15 -18
index cf80feae970d..bd78d504fdad 100644
@@ -2521,13 +2521,9 @@ static int __zap_zero_pages(pmd_t *pmd, unsigned long start,
 	return 0;
 }
 
-static inline void zap_zero_pages(struct mm_struct *mm)
-{
-	struct mm_walk walk = { .pmd_entry = __zap_zero_pages };
-
-	walk.mm = mm;
-	walk_page_range(0, TASK_SIZE, &walk);
-}
+static const struct mm_walk_ops zap_zero_walk_ops = {
+	.pmd_entry	= __zap_zero_pages,
+};
 
 /*
  * switch on pgstes for its userspace process (for kvm)
@@ -2546,7 +2542,7 @@ int s390_enable_sie(void)
 	mm->context.has_pgste = 1;
 	/* split thp mappings and disable thp for future mappings */
 	thp_split_mm(mm);
-	zap_zero_pages(mm);
+	walk_page_range(mm, 0, TASK_SIZE, &zap_zero_walk_ops, NULL);
 	up_write(&mm->mmap_sem);
 	return 0;
 }
@@ -2589,12 +2585,13 @@ static int __s390_enable_skey_hugetlb(pte_t *pte, unsigned long addr,
 	return 0;
 }
 
+static const struct mm_walk_ops enable_skey_walk_ops = {
+	.hugetlb_entry		= __s390_enable_skey_hugetlb,
+	.pte_entry		= __s390_enable_skey_pte,
+};
+
 int s390_enable_skey(void)
 {
-	struct mm_walk walk = {
-		.hugetlb_entry = __s390_enable_skey_hugetlb,
-		.pte_entry = __s390_enable_skey_pte,
-	};
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma;
 	int rc = 0;
@@ -2614,8 +2611,7 @@ int s390_enable_skey(void)
 	}
 	mm->def_flags &= ~VM_MERGEABLE;
 
-	walk.mm = mm;
-	walk_page_range(0, TASK_SIZE, &walk);
+	walk_page_range(mm, 0, TASK_SIZE, &enable_skey_walk_ops, NULL);
 
 out_up:
 	up_write(&mm->mmap_sem);
@@ -2633,13 +2629,14 @@ static int __s390_reset_cmma(pte_t *pte, unsigned long addr,
 	return 0;
 }
 
+static const struct mm_walk_ops reset_cmma_walk_ops = {
+	.pte_entry		= __s390_reset_cmma,
+};
+
 void s390_reset_cmma(struct mm_struct *mm)
 {
-	struct mm_walk walk = { .pte_entry = __s390_reset_cmma };
-
 	down_write(&mm->mmap_sem);
-	walk.mm = mm;
-	walk_page_range(0, TASK_SIZE, &walk);
+	walk_page_range(mm, 0, TASK_SIZE, &reset_cmma_walk_ops, NULL);
 	up_write(&mm->mmap_sem);
 }
 EXPORT_SYMBOL_GPL(s390_reset_cmma);
fs/proc/task_mmu.c +38 -36

157 lines not on this page · raw message

include/linux/pagewalk.h +38 -26

82 lines not on this page · raw message

mm/hmm.c +14 -26
index 909b846c11d4..37933f886dbe 100644
@@ -941,6 +941,13 @@ void hmm_range_unregister(struct hmm_range *range)
 }
 EXPORT_SYMBOL(hmm_range_unregister);
 
+static const struct mm_walk_ops hmm_walk_ops = {
+	.pud_entry	= hmm_vma_walk_pud,
+	.pmd_entry	= hmm_vma_walk_pmd,
+	.pte_hole	= hmm_vma_walk_hole,
+	.hugetlb_entry	= hmm_vma_walk_hugetlb_entry,
+};
+
 /*
  * hmm_range_snapshot() - snapshot CPU page table for a range
  * @range: range
@@ -961,7 +968,6 @@ long hmm_range_snapshot(struct hmm_range *range)
 	struct hmm_vma_walk hmm_vma_walk;
 	struct hmm *hmm = range->hmm;
 	struct vm_area_struct *vma;
-	struct mm_walk mm_walk;
 
 	lockdep_assert_held(&hmm->mm->mmap_sem);
 	do {
@@ -999,20 +1005,10 @@ long hmm_range_snapshot(struct hmm_range *range)
 		hmm_vma_walk.last = start;
 		hmm_vma_walk.fault = false;
 		hmm_vma_walk.range = range;
-		mm_walk.private = &hmm_vma_walk;
-		end = min(range->end, vma->vm_end);
 
-		mm_walk.vma = vma;
-		mm_walk.mm = vma->vm_mm;
-		mm_walk.pte_entry = NULL;
-		mm_walk.test_walk = NULL;
-		mm_walk.hugetlb_entry = NULL;
-		mm_walk.pud_entry = hmm_vma_walk_pud;
-		mm_walk.pmd_entry = hmm_vma_walk_pmd;
-		mm_walk.pte_hole = hmm_vma_walk_hole;
-		mm_walk.hugetlb_entry = hmm_vma_walk_hugetlb_entry;
-
-		walk_page_range(start, end, &mm_walk);
+		end = min(range->end, vma->vm_end);
+		walk_page_range(vma->vm_mm, start, end, &hmm_walk_ops,
+				&hmm_vma_walk);
 		start = end;
 	} while (start < range->end);
 
@@ -1055,7 +1051,6 @@ long hmm_range_fault(struct hmm_range *range, bool block)
 	struct hmm_vma_walk hmm_vma_walk;
 	struct hmm *hmm = range->hmm;
 	struct vm_area_struct *vma;
-	struct mm_walk mm_walk;
 	int ret;
 
 	lockdep_assert_held(&hmm->mm->mmap_sem);
@@ -1096,21 +1091,14 @@ long hmm_range_fault(struct hmm_range *range, bool block)
 		hmm_vma_walk.fault = true;
 		hmm_vma_walk.block = block;
 		hmm_vma_walk.range = range;
-		mm_walk.private = &hmm_vma_walk;
 		end = min(range->end, vma->vm_end);
 
-		mm_walk.vma = vma;
-		mm_walk.mm = vma->vm_mm;
-		mm_walk.pte_entry = NULL;
-		mm_walk.test_walk = NULL;
-		mm_walk.hugetlb_entry = NULL;
-		mm_walk.pud_entry = hmm_vma_walk_pud;
-		mm_walk.pmd_entry = hmm_vma_walk_pmd;
-		mm_walk.pte_hole = hmm_vma_walk_hole;
-		mm_walk.hugetlb_entry = hmm_vma_walk_hugetlb_entry;
+		walk_page_range(vma->vm_mm, start, end, &hmm_walk_ops,
+				&hmm_vma_walk);
 
 		do {
-			ret = walk_page_range(start, end, &mm_walk);
+			ret = walk_page_range(vma->vm_mm, start, end,
+					&hmm_walk_ops, &hmm_vma_walk);
 			start = hmm_vma_walk.last;
 
 			/* Keep trying while the range is valid. */
mm/madvise.c +12 -29

65 lines not on this page · raw message

mm/memcontrol.c +11 -12
index ee01175e56d4..5d159f9391ff 100644
@@ -5244,17 +5244,16 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
 	return 0;
 }
 
+static const struct mm_walk_ops precharge_walk_ops = {
+	.pmd_entry	= mem_cgroup_count_precharge_pte_range,
+};
+
 static unsigned long mem_cgroup_count_precharge(struct mm_struct *mm)
 {
 	unsigned long precharge;
 
-	struct mm_walk mem_cgroup_count_precharge_walk = {
-		.pmd_entry = mem_cgroup_count_precharge_pte_range,
-		.mm = mm,
-	};
 	down_read(&mm->mmap_sem);
-	walk_page_range(0, mm->highest_vm_end,
-			&mem_cgroup_count_precharge_walk);
+	walk_page_range(mm, 0, mm->highest_vm_end, &precharge_walk_ops, NULL);
 	up_read(&mm->mmap_sem);
 
 	precharge = mc.precharge;
@@ -5523,13 +5522,12 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
 	return ret;
 }
 
+static const struct mm_walk_ops charge_walk_ops = {
+	.pmd_entry	= mem_cgroup_move_charge_pte_range,
+};
+
 static void mem_cgroup_move_charge(void)
 {
-	struct mm_walk mem_cgroup_move_charge_walk = {
-		.pmd_entry = mem_cgroup_move_charge_pte_range,
-		.mm = mc.mm,
-	};
-
 	lru_add_drain_all();
 	/*
 	 * Signal lock_page_memcg() to take the memcg's move_lock
@@ -5555,7 +5553,8 @@ static void mem_cgroup_move_charge(void)
 	 * When we have consumed all precharges and failed in doing
 	 * additional charge, the page walk just aborts.
 	 */
-	walk_page_range(0, mc.mm->highest_vm_end, &mem_cgroup_move_charge_walk);
+	walk_page_range(mc.mm, 0, mc.mm->highest_vm_end, &charge_walk_ops,
+			NULL);
 
 	up_read(&mc.mm->mmap_sem);
 	atomic_dec(&mc.from->moving_account);
mm/mempolicy.c +7 -8
index 1ee6b6f49431..6712bceae213 100644
@@ -634,6 +634,12 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
 	return 1;
 }
 
+static const struct mm_walk_ops queue_pages_walk_ops = {
+	.hugetlb_entry		= queue_pages_hugetlb,
+	.pmd_entry		= queue_pages_pte_range,
+	.test_walk		= queue_pages_test_walk,
+};
+
 /*
  * Walk through page tables and collect pages to be migrated.
  *
@@ -652,15 +658,8 @@ queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end,
 		.nmask = nodes,
 		.prev = NULL,
 	};
-	struct mm_walk queue_pages_walk = {
-		.hugetlb_entry = queue_pages_hugetlb,
-		.pmd_entry = queue_pages_pte_range,
-		.test_walk = queue_pages_test_walk,
-		.mm = mm,
-		.private = &qp,
-	};
 
-	return walk_page_range(start, end, &queue_pages_walk);
+	return walk_page_range(mm, start, end, &queue_pages_walk_ops, &qp);
 }
 
 /*
mm/migrate.c +7 -8
index 019c426c6ef7..75de4378dfcd 100644
@@ -2330,6 +2330,11 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
 	return 0;
 }
 
+static const struct mm_walk_ops migrate_vma_walk_ops = {
+	.pmd_entry		= migrate_vma_collect_pmd,
+	.pte_hole		= migrate_vma_collect_hole,
+};
+
 /*
  * migrate_vma_collect() - collect pages over a range of virtual addresses
  * @migrate: migrate struct containing all migration information
@@ -2341,19 +2346,13 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
 static void migrate_vma_collect(struct migrate_vma *migrate)
 {
 	struct mmu_notifier_range range;
-	struct mm_walk mm_walk = {
-		.pmd_entry = migrate_vma_collect_pmd,
-		.pte_hole = migrate_vma_collect_hole,
-		.vma = migrate->vma,
-		.mm = migrate->vma->vm_mm,
-		.private = migrate,
-	};
 
 	mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm_walk.mm,
 				migrate->start,
 				migrate->end);
 	mmu_notifier_invalidate_range_start(&range);
-	walk_page_range(migrate->start, migrate->end, &mm_walk);
+	walk_page_range(migrate->vma->vm_mm, migrate->start, migrate->end,
+			&migrate_vma_walk_ops, migrate);
 	mmu_notifier_invalidate_range_end(&range);
 
 	migrate->end = migrate->start + (migrate->npages << PAGE_SHIFT);
mm/mincore.c +7 -8
index 3b051b6ab3fe..f9a9dbe8cd33 100644
@@ -193,6 +193,12 @@ static inline bool can_do_mincore(struct vm_area_struct *vma)
 		inode_permission(file_inode(vma->vm_file), MAY_WRITE) == 0;
 }
 
+static const struct mm_walk_ops mincore_walk_ops = {
+	.pmd_entry		= mincore_pte_range,
+	.pte_hole		= mincore_unmapped_range,
+	.hugetlb_entry		= mincore_hugetlb,
+};
+
 /*
  * Do a chunk of "sys_mincore()". We've already checked
  * all the arguments, we hold the mmap semaphore: we should
@@ -203,12 +209,6 @@ static long do_mincore(unsigned long addr, unsigned long pages, unsigned char *v
 	struct vm_area_struct *vma;
 	unsigned long end;
 	int err;
-	struct mm_walk mincore_walk = {
-		.pmd_entry = mincore_pte_range,
-		.pte_hole = mincore_unmapped_range,
-		.hugetlb_entry = mincore_hugetlb,
-		.private = vec,
-	};
 
 	vma = find_vma(current->mm, addr);
 	if (!vma || addr < vma->vm_start)
@@ -219,8 +219,7 @@ static long do_mincore(unsigned long addr, unsigned long pages, unsigned char *v
 		memset(vec, 1, pages);
 		return pages;
 	}
-	mincore_walk.mm = vma->vm_mm;
-	err = walk_page_range(addr, end, &mincore_walk);
+	err = walk_page_range(vma->vm_mm, addr, end, &mincore_walk_ops, vec);
 	if (err < 0)
 		return err;
 	return (end - addr) >> PAGE_SHIFT;
mm/mprotect.c +9 -15
index cc73318dbc25..675e5d34a507 100644
@@ -329,20 +329,11 @@ static int prot_none_test(unsigned long addr, unsigned long next,
 	return 0;
 }
 
-static int prot_none_walk(struct vm_area_struct *vma, unsigned long start,
-			   unsigned long end, unsigned long newflags)
-{
-	pgprot_t new_pgprot = vm_get_page_prot(newflags);
-	struct mm_walk prot_none_walk = {
-		.pte_entry = prot_none_pte_entry,
-		.hugetlb_entry = prot_none_hugetlb_entry,
-		.test_walk = prot_none_test,
-		.mm = current->mm,
-		.private = &new_pgprot,
-	};
-
-	return walk_page_range(start, end, &prot_none_walk);
-}
+static const struct mm_walk_ops prot_none_walk_ops = {
+	.pte_entry		= prot_none_pte_entry,
+	.hugetlb_entry		= prot_none_hugetlb_entry,
+	.test_walk		= prot_none_test,
+};
 
 int
 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
@@ -369,7 +360,10 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
 	if (arch_has_pfn_modify_check() &&
 	    (vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) &&
 	    (newflags & (VM_READ|VM_WRITE|VM_EXEC)) == 0) {
-		error = prot_none_walk(vma, start, end, newflags);
+		pgprot_t new_pgprot = vm_get_page_prot(newflags);
+
+		error = walk_page_range(current->mm, start, end,
+				&prot_none_walk_ops, &new_pgprot);
 		if (error)
 			return error;
 	}
mm/pagewalk.c +70 -48

298 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v1 2/3
#3 lore raw

Re: [PATCH 2/3] pagewalk: seperate function pointers from iterator data

Quoted 9 lines · Christoph Hellwig

The mm_walk structure currently mixed data and code. Split out the operations vectors into a new mm_walk_ops structure, and while we are changing the API also declare the mm_walk structure inside the walk_page_range and walk_page_vma functions.

Based on patch from Linus Torvalds.

---

Typo: For the patch title s/seperate/separate/

Otherwise for the series

/Thomas

Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] pagewalk: seperate function pointers from iterator data

In reply to Christoph Hellwig

Subject: s/seperate/separate/

Quoted 24 lines · Christoph Hellwig

The mm_walk structure currently mixed data and code. Split out the operations vectors into a new mm_walk_ops structure, and while we are changing the API also declare the mm_walk structure inside the walk_page_range and walk_page_vma functions.

Based on patch from Linus Torvalds.

---
 arch/openrisc/kernel/dma.c              |  22 +++--
 arch/powerpc/mm/book3s64/subpage_prot.c |  10 +-
 arch/s390/mm/gmap.c                     |  33 +++----
 fs/proc/task_mmu.c                      |  74 +++++++--------
 include/linux/pagewalk.h                |  64 +++++++------
 mm/hmm.c                                |  40 +++-----
 mm/madvise.c                            |  41 +++-----
 mm/memcontrol.c                         |  23 +++--
 mm/mempolicy.c                          |  15 ++-
 mm/migrate.c                            |  15 ++-
 mm/mincore.c                            |  15 ++-
 mm/mprotect.c                           |  24 ++---
 mm/pagewalk.c                           | 118 ++++++++++++++----------
 13 files changed, 245 insertions(+), 249 deletions(-)

[...]

Quoted 190 lines
mm/pagewalk.c +31 -24
index 8a92a961a2ee..28510fc0dde1 100644
@@ -9,10 +9,11 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
 {
 	pte_t *pte;
 	int err = 0;
+	const struct mm_walk_ops *ops = walk->ops;
 
 	pte = pte_offset_map(pmd, addr);
 	for (;;) {
-		err = walk->pte_entry(pte, addr, addr + PAGE_SIZE, walk);
+		err = ops->pte_entry(pte, addr, addr + PAGE_SIZE, walk);
 		if (err)
 		       break;
 		addr += PAGE_SIZE;
@@ -30,6 +31,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
 {
 	pmd_t *pmd;
 	unsigned long next;
+	const struct mm_walk_ops *ops = walk->ops;
 	int err = 0;
 
 	pmd = pmd_offset(pud, addr);
@@ -37,8 +39,8 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
 again:
 		next = pmd_addr_end(addr, end);
 		if (pmd_none(*pmd) || !walk->vma) {
-			if (walk->pte_hole)
-				err = walk->pte_hole(addr, next, walk);
+			if (ops->pte_hole)
+				err = ops->pte_hole(addr, next, walk);
 			if (err)
 				break;
 			continue;
@@ -47,8 +49,8 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
 		 * This implies that each ->pmd_entry() handler
 		 * needs to know about pmd_trans_huge() pmds
 		 */
-		if (walk->pmd_entry)
-			err = walk->pmd_entry(pmd, addr, next, walk);
+		if (ops->pmd_entry)
+			err = ops->pmd_entry(pmd, addr, next, walk);
 		if (err)
 			break;
 
@@ -56,7 +58,7 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
 		 * Check this here so we only break down trans_huge
 		 * pages when we _need_ to
 		 */
-		if (!walk->pte_entry)
+		if (!ops->pte_entry)
 			continue;
 
 		split_huge_pmd(walk->vma, pmd, addr);
@@ -75,6 +77,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
 {
 	pud_t *pud;
 	unsigned long next;
+	const struct mm_walk_ops *ops = walk->ops;
 	int err = 0;
 
 	pud = pud_offset(p4d, addr);
@@ -82,18 +85,18 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
  again:
 		next = pud_addr_end(addr, end);
 		if (pud_none(*pud) || !walk->vma) {
-			if (walk->pte_hole)
-				err = walk->pte_hole(addr, next, walk);
+			if (ops->pte_hole)
+				err = ops->pte_hole(addr, next, walk);
 			if (err)
 				break;
 			continue;
 		}
 
-		if (walk->pud_entry) {
+		if (ops->pud_entry) {
 			spinlock_t *ptl = pud_trans_huge_lock(pud, walk->vma);
 
 			if (ptl) {
-				err = walk->pud_entry(pud, addr, next, walk);
+				err = ops->pud_entry(pud, addr, next, walk);
 				spin_unlock(ptl);
 				if (err)
 					break;
@@ -105,7 +108,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end,
 		if (pud_none(*pud))
 			goto again;
 
-		if (walk->pmd_entry || walk->pte_entry)
+		if (ops->pmd_entry || ops->pte_entry)
 			err = walk_pmd_range(pud, addr, next, walk);
 		if (err)
 			break;
@@ -119,19 +122,20 @@ static int walk_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end,
 {
 	p4d_t *p4d;
 	unsigned long next;
+	const struct mm_walk_ops *ops = walk->ops;
 	int err = 0;
 
 	p4d = p4d_offset(pgd, addr);
 	do {
 		next = p4d_addr_end(addr, end);
 		if (p4d_none_or_clear_bad(p4d)) {
-			if (walk->pte_hole)
-				err = walk->pte_hole(addr, next, walk);
+			if (ops->pte_hole)
+				err = ops->pte_hole(addr, next, walk);
 			if (err)
 				break;
 			continue;
 		}
-		if (walk->pmd_entry || walk->pte_entry)
+		if (ops->pmd_entry || ops->pte_entry)
 			err = walk_pud_range(p4d, addr, next, walk);
 		if (err)
 			break;
@@ -145,19 +149,20 @@ static int walk_pgd_range(unsigned long addr, unsigned long end,
 {
 	pgd_t *pgd;
 	unsigned long next;
+	const struct mm_walk_ops *ops = walk->ops;
 	int err = 0;
 
 	pgd = pgd_offset(walk->mm, addr);
 	do {
 		next = pgd_addr_end(addr, end);
 		if (pgd_none_or_clear_bad(pgd)) {
-			if (walk->pte_hole)
-				err = walk->pte_hole(addr, next, walk);
+			if (ops->pte_hole)
+				err = ops->pte_hole(addr, next, walk);
 			if (err)
 				break;
 			continue;
 		}
-		if (walk->pmd_entry || walk->pte_entry)
+		if (ops->pmd_entry || ops->pte_entry)
 			err = walk_p4d_range(pgd, addr, next, walk);
 		if (err)
 			break;
@@ -183,6 +188,7 @@ static int walk_hugetlb_range(unsigned long addr, unsigned long end,
 	unsigned long hmask = huge_page_mask(h);
 	unsigned long sz = huge_page_size(h);
 	pte_t *pte;
+	const struct mm_walk_ops *ops = walk->ops;
 	int err = 0;
 
 	do {
@@ -190,9 +196,9 @@ static int walk_hugetlb_range(unsigned long addr, unsigned long end,
 		pte = huge_pte_offset(walk->mm, addr & hmask, sz);
 
 		if (pte)
-			err = walk->hugetlb_entry(pte, hmask, addr, next, walk);
-		else if (walk->pte_hole)
-			err = walk->pte_hole(addr, next, walk);
+			err = ops->hugetlb_entry(pte, hmask, addr, next, walk);
+		else if (ops->pte_hole)
+			err = ops->pte_hole(addr, next, walk);
 
 		if (err)
 			break;
@@ -220,9 +226,10 @@ static int walk_page_test(unsigned long start, unsigned long end,
 			struct mm_walk *walk)
 {
 	struct vm_area_struct *vma = walk->vma;
+	const struct mm_walk_ops *ops = walk->ops;
 
-	if (walk->test_walk)
-		return walk->test_walk(start, end, walk);
+	if (ops->test_walk)
+		return ops->test_walk(start, end, walk);
 
 	/*
 	 * vma(VM_PFNMAP) doesn't have any valid struct pages behind VM_PFNMAP
@@ -234,8 +241,8 @@ static int walk_page_test(unsigned long start, unsigned long end,
 	 */
 	if (vma->vm_flags & VM_PFNMAP) {
 		int err = 1;
-		if (walk->pte_hole)
-			err = walk->pte_hole(start, end, walk);
+		if (ops->pte_hole)
+			err = ops->pte_hole(start, end, walk);
 		return err ? err : 1;
 	}
 	return 0;

mm/pagewalk.c static int __walk_page_range(unsigned long start, unsigned long end, · line 258

Quoted 5 lines
mm/pagewalk.c +1 -1
@@ -248,7 +255,8 @@ static int __walk_page_range(unsigned long start, unsigned long end,
 	struct vm_area_struct *vma = walk->vma;
 
 	if (vma && is_vm_hugetlb_page(vma)) {
-		if (walk->hugetlb_entry)
+		const struct mm_walk_ops *ops = walk->ops;

NIT: checkpatch would like a blank line here

Quoted 12 lines
mm/pagewalk.c +2 -3
+		if (ops->hugetlb_entry)
 			err = walk_hugetlb_range(start, end, walk);
 	} else
 		err = walk_pgd_range(start, end, walk);
@@ -258,11 +266,13 @@ static int __walk_page_range(unsigned long start, unsigned long end,
 
 /**
  * walk_page_range - walk page table with caller specific callbacks
- * @start: start address of the virtual address range
- * @end: end address of the virtual address range
- * @walk: mm_walk structure defining the callbacks and the target address space
+ * @mm:		mm_struct representing the target process of page table walk

mm/pagewalk.c static int __walk_page_range(unsigned long start, unsigned long end, · line 278

Quoted 10 lines
mm/pagewalk.c +5 -1
+ * @start:	start address of the virtual address range
+ * @end:	end address of the virtual address range
+ * @ops:	operation to call during the walk
+ * @private:	private data for callbacks' usage
  *
- * Recursively walk the page table tree of the process represented by @walk->mm
+ * Recursively walk the page table tree of the process represented by @mm
  * within the virtual address range [@start, @end). During walking, we can do
  * some caller-specific works for each entry, by setting up pmd_entry(),
  * pte_entry(), and/or hugetlb_entry(). If you don't set up for some of these

Missing context:

Quoted 5 lines

*
* Before starting to walk page table, some callers want to check whether
* they really want to walk over the current vma, typically by checking
* its vm_flags. walk_page_test() and @walk->test_walk() are used for this
* purpose.

@walk->test_walk() should now be @ops->test_walk()

mm/pagewalk.c static int __walk_page_range(unsigned long start, unsigned long end, · line 300

Quoted 10 lines
mm/pagewalk.c +1 -1
@@ -283,42 +293,48 @@ static int __walk_page_range(unsigned long start, unsigned long end,
  *
  * struct mm_walk keeps current values of some common data like vma and pmd,
  * which are useful for the access from callbacks. If you want to pass some
- * caller-specific data to callbacks, @walk->private should be helpful.
+ * caller-specific data to callbacks, @private should be helpful.
  *
  * Locking:
  *   Callers of walk_page_range() and walk_page_vma() should hold
  *   @walk->mm->mmap_sem, because these function traverse vma list and/or

s/walk->//

Otherwise looks good - I've rebased my series on it and the initial testing is fine. So for the series:

Thanks,

Steve

#5 lore raw

PATCH 3/3 pagewalk: use lockdep_assert_held for locking validation

In reply to Christoph Hellwig

Use lockdep to check for held locks instead of using home grown asserts.

---
 mm/pagewalk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/pagewalk.c +2 -2
index 28510fc0dde1..9ec1885ceed7 100644
@@ -319,7 +319,7 @@ int walk_page_range(struct mm_struct *mm, unsigned long start,
 	if (!walk.mm)
 		return -EINVAL;
 
-	VM_BUG_ON_MM(!rwsem_is_locked(&walk.mm->mmap_sem), walk.mm);
+	lockdep_assert_held(&walk.mm->mmap_sem);
 
 	vma = find_vma(walk.mm, start);
 	do {
@@ -369,7 +369,7 @@ int walk_page_vma(struct vm_area_struct *vma, const struct mm_walk_ops *ops,
 	if (!walk.mm)
 		return -EINVAL;
 
-	VM_BUG_ON(!rwsem_is_locked(&vma->vm_mm->mmap_sem));
+	lockdep_assert_held(&walk.mm->mmap_sem);
 
 	err = walk_page_test(vma->vm_start, vma->vm_end, &walk);
 	if (err > 0)
Signature · 1 line
2.20.1
#6 lore raw

Re: [PATCH 3/3] pagewalk: use lockdep_assert_held for locking validation

mm/pagewalk.c int walk_page_range(struct mm_struct *mm, unsigned long start, · line 322

Quoted 9 lines · Christoph Hellwig

Use lockdep to check for held locks instead of using home grown asserts.

mm/pagewalk.c +1 -1
@@ -319,7 +319,7 @@ int walk_page_range(struct mm_struct *mm, unsigned long start,
 	if (!walk.mm)
 		return -EINVAL;
 
-	VM_BUG_ON_MM(!rwsem_is_locked(&walk.mm->mmap_sem), walk.mm);
+	lockdep_assert_held(&walk.mm->mmap_sem);

It occurs to me that this is exactly the pattern that lockdep_pin_lock() was designed for. I'm pretty sure things will go badly if any callee unlocks then relocks the lock.

#7 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

this series is based on a patch from Linus to split the callbacks passed to walk_page_range and walk_page_vma into a separate structure that can be marked const, with various cleanups from me on top.

The whole series looks good to me. Ack.

Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

Linus

#8 lore raw
Quoted 6 lines · Linus Torvalds
Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

Quoted 8 lines

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

I did cross compile the s390 and powerpc bits, but I do not have an openrisc compiler.

Quoted 2 lines

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

That would help with this series vs the others, but not with the other series vs each other.

#9 lore raw
Quoted 14 lines · Christoph Hellwig
Quoted 5 lines · Linus Torvalds
Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

Quoted 8 lines

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

Quoted 7 lines

I did cross compile the s390 and powerpc bits, but I do not have an openrisc compiler.

Quoted 2 lines

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

That would help with this series vs the others, but not with the other series vs each other.

Although my series doesn't touch the pagewalk code, it rather borrowed some concepts from it and used for the apply_to_page_range() interface.

The reason being that the pagewalk code requires the mmap_sem to be held (mainly for trans-huge pages and reading the vma->vm_flags if I understand the code correctly). That is fine when you scan the vmas of a process, but the helpers I wrote need to instead scan all vmas pointing into a struct address_space, and taking the mmap_sem for each vma will create lock inversion problems.

/Thomas

#10 lore raw
Quoted 26 lines · Thomas Hellstrom
Quoted 14 lines · Christoph Hellwig
Quoted 5 lines · Linus Torvalds
Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

Quoted 8 lines

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

Quoted 7 lines

I did cross compile the s390 and powerpc bits, but I do not have an openrisc compiler.

Quoted 2 lines

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

That would help with this series vs the others, but not with the other series vs each other.

Although my series doesn't touch the pagewalk code, it rather borrowed some concepts from it and used for the apply_to_page_range() interface.

Quoted 6 lines

The reason being that the pagewalk code requires the mmap_sem to be held (mainly for trans-huge pages and reading the vma->vm_flags if I understand the code correctly). That is fine when you scan the vmas of a process, but the helpers I wrote need to instead scan all vmas pointing into a struct address_space, and taking the mmap_sem for each vma will create lock inversion problems.

True. So you'll just need to apply the same lessons there, and we should probably fine with this series going into 5.3-rc.

#11 lore raw
In reply to Christoph Hellwig
Quoted 16 lines · Christoph Hellwig
Quoted 6 lines · Linus Torvalds
Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

Quoted 8 lines

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

Quoted 2 lines

I did cross compile the s390 and powerpc bits, but I do not have an openrisc compiler.

The openrisc defconfig builds fine.

Quoted 6 lines
Quoted 2 lines

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

That would help with this series vs the others, but not with the other series vs each other.

Signature · 2 lines
Sincerely yours,
Mike.
#12 lore raw
In reply to Linus Torvalds
Quoted 23 lines · Linus Torvalds
Quoted 4 lines · Christoph Hellwig

this series is based on a patch from Linus to split the callbacks passed to walk_page_range and walk_page_vma into a separate structure that can be marked const, with various cleanups from me on top.

The whole series looks good to me. Ack.

Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

Quoted 2 lines

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

#13 lore raw
Quoted 24 lines · Christoph Hellwig
Quoted 23 lines · Linus Torvalds
Quoted 4 lines · Christoph Hellwig

this series is based on a patch from Linus to split the callbacks passed to walk_page_range and walk_page_vma into a separate structure that can be marked const, with various cleanups from me on top.

The whole series looks good to me. Ack.

Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

Quoted 6 lines
Quoted 2 lines

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Are there conflicts with trees other than hmm?

We can put it on a topic branch and merge to hmm to resolve. If hmm has problems then send the topic on its own?

Jason

#14 lore raw
Quoted 4 lines · Jason Gunthorpe

Are there conflicts with trees other than hmm?

We can put it on a topic branch and merge to hmm to resolve. If hmm has problems then send the topic on its own?

I see two new walk_page_range user in linux-next related to MADV_COLD support (which probably really should use walk_range_vma), and then there is the series from Steven, which hasn't been merged yet.

#15 lore raw
Quoted 4 lines · Christoph Hellwig

I see two new walk_page_range user in linux-next related to MADV_COLD support (which probably really should use walk_range_vma), and then there is the series from Steven, which hasn't been merged yet.

It does sound like this might as well just be handled in linux-next, and there's no big advantage in me pulling the walker cleanups early.

Honestly, even if it ends up being handled as a conflict resolution issue (rather than some shared branch), it probably simply isn't all that painful. We have those kinds of semantic conflicts all the time, it doesn't worry me too much.

So I'm not worried about new _users_ of the page walker concurrently with the page walker interface itself being cleaned up. Those kinds of conflicts end up being "just make sure to update the new users to the new interface when they get pulled". Happens all the time.

I'd be more worried about two different branches wanting to change the internal implementation of the page walker itself, and the actual *code* itself getting conflicts (as opposed to the interface vs users kind of conflicts). Those kinds of conflicts can be messy. But it sounds like Thomas Hellström's changes aren't that kind of thing.

I'm still willing to do the early merge if it turns out to be hugely helpful, but from the discussion so far it does sound like "just merge during 5.4 merge window" is perfectly fine.

Linus

maintainer
#16 lore raw
In reply to Christoph Hellwig
Quoted 9 lines · On Fri, 16 Aug 2019 14:32:58 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 4 lines · Jason Gunthorpe

Are there conflicts with trees other than hmm?

We can put it on a topic branch and merge to hmm to resolve. If hmm has problems then send the topic on its own?

I see two new walk_page_range user in linux-next related to MADV_COLD support (which probably really should use walk_range_vma), and then there is the series from Steven, which hasn't been merged yet.

Would it be practical to create a brand new interface with different functions names all in new source files? Once all callers are migrated over and tested, remove the old code?

#17 lore raw

Hi all,

Quoted 9 lines · On Fri, 16 Aug 2019 14:06:23 -0700 Andrew Morton <[email protected]>…
Quoted 6 lines · On Fri, 16 Aug 2019 14:32:58 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 4 lines · Jason Gunthorpe

Are there conflicts with trees other than hmm?

We can put it on a topic branch and merge to hmm to resolve. If hmm has problems then send the topic on its own?

Quoted 7 lines
Quoted 3 lines

I see two new walk_page_range user in linux-next related to MADV_COLD support (which probably really should use walk_range_vma), and then there is the series from Steven, which hasn't been merged yet.

Would it be practical to create a brand new interface with different functions names all in new source files? Once all callers are migrated over and tested, remove the old code?

I certainly prefer that method of API change :-)
(see the current "keys: Replace uid/gid/perm permissions checking with an ACL" in linux-next and the (currently) three merge fixup patches I am carrying. Its not bad when people provide the fixes, but I am no expert in most areas of the kernel ...)

Signature · 2 lines
Cheers,
Stephen Rothwell
#18 lore raw
Quoted 5 lines · Stephen Rothwell

I certainly prefer that method of API change :-)
(see the current "keys: Replace uid/gid/perm permissions checking with an ACL" in linux-next and the (currently) three merge fixup patches I am carrying. Its not bad when people provide the fixes, but I am no expert in most areas of the kernel ...)

It would mean pretty much duplicating all the code. And then never finish the migration because new users of the old interfaces keep popping up. Compared to that I'd much much prefer either Linus taking it now or a branch.

#19 lore raw

Hi Christoph,

Quoted 8 lines · On Sat, 17 Aug 2019 08:43:01 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 5 lines · Stephen Rothwell

I certainly prefer that method of API change :-)
(see the current "keys: Replace uid/gid/perm permissions checking with an ACL" in linux-next and the (currently) three merge fixup patches I am carrying. Its not bad when people provide the fixes, but I am no expert in most areas of the kernel ...)

Quoted 4 lines

It would mean pretty much duplicating all the code. And then never finish the migration because new users of the old interfaces keep popping up. Compared to that I'd much much prefer either Linus taking it now or a branch.

Sure, I have no problem with either of these two choices, or, at least, hints/resolutions when conflicts are expected. My time (each day) is already getting pretty short since we are almost up to -rc5 ...

Signature · 2 lines
Cheers,
Stephen Rothwell
#20 lore raw
In reply to Stephen Rothwell
Quoted 4 lines · Stephen Rothwell

I certainly prefer that method of API change :-)
(see the current "keys: Replace uid/gid/perm permissions checking with an ACL" in linux-next

Side note: I will *not* be pulling that again.

It was broken last time, and without more people reviewing the code, I' m not pulling it for 5.4 either even if David has an additional commit on top that might have fixed the original problem.

There's still a pending kernel test report on commit f771fde82051 ("keys: Simplify key description management") from another of David's pulls for 5.3 - one that didn't get reverted.

David, look in your inbox for a kernel test report about

kernel BUG at security/keys/keyring.c:1245!

(It's the

        BUG_ON(index_key->desc_len == 0);

line - the line numbers have since changed, and it's line 1304 in the current tree).

I'm not sure why _that_ BUG_ON() now triggers, but I wonder if it's because 'desc_len' went from a 'size_t' to an 'u8', and now a desc_len of 256 is 0. Or something. The point being that there have been too many bugs in the pulls and nobody but David apparently ever had anything to do with any of the development. This code needs more eyes, not more random changes.

So I won't be compounding on that workflow problem next merge window.

Linus

#21 lore raw
In reply to Christoph Hellwig
Quoted 24 lines · Christoph Hellwig
Quoted 23 lines · Linus Torvalds
Quoted 4 lines · Christoph Hellwig

this series is based on a patch from Linus to split the callbacks passed to walk_page_range and walk_page_vma into a separate structure that can be marked const, with various cleanups from me on top.

The whole series looks good to me. Ack.

Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

Quoted 6 lines
Quoted 2 lines

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Did we make a decision on this? Due to travel & LPC I'd like to finalize the hmm tree next week.

Thanks,
Jason

Acked-by
#22 lore raw
Quoted 28 lines · Jason Gunthorpe
Quoted 27 lines · Christoph Hellwig
Quoted 25 lines · Linus Torvalds
Quoted 4 lines · Christoph Hellwig

this series is based on a patch from Linus to split the callbacks passed to walk_page_range and walk_page_vma into a separate structure that can be marked const, with various cleanups from me on top.

The whole series looks good to me. Ack.

Quoted 5 lines

Note that both Thomas and Steven have series touching this area pending, and there are a couple consumer in flux too - the hmm tree already conflicts with this series, and I have potential dma changes on top of the consumers in Thomas and Steven's series, so we'll probably need a git tree similar to the hmm one to synchronize these updates.

I'd be willing to just merge this now, if that helps. The conversion is mechanical, and my only slight worry would be that at least for my original patch I didn't build-test the (few) non-x86 architecture-specific cases. But I did end up looking at them fairly closely (basically using some grep/sed scripts to see that the conversions I did matched the same patterns). And your changes look like obvious improvements too where any mistake would have been caught by the compiler.

So I'm not all that worried from a functionality standpoint, and if this will help the next merge window, I'll happily pull now.

Quoted 6 lines
Quoted 3 lines

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Did we make a decision on this? Due to travel & LPC I'd like to finalize the hmm tree next week.

I was planning on rebasing my series on this and posting it for 5.4 - I hadn't actually realised this hasn't been picked up yet. I haven't had much time to look at this recently.

FWIW you can add for the series:

Steve

#23 lore raw
In reply to Jason Gunthorpe
Quoted 6 lines · Jason Gunthorpe
Quoted 3 lines

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Did we make a decision on this? Due to travel & LPC I'd like to finalize the hmm tree next week.

I don't think we've made any decision. I'd still love to see this in hmm.git. It has a minor conflict, but I can resend a rebased version.

#24 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Jason Gunthorpe
Quoted 3 lines

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Did we make a decision on this? Due to travel & LPC I'd like to finalize the hmm tree next week.

I don't think we've made any decision. I'd still love to see this in hmm.git. It has a minor conflict, but I can resend a rebased version.

I'm looking at this.. The hmm conflict is easy enough to fix.

But the compile conflict with these two patches in -mm requires some action from Andrew:

commit 027b9b8fd9ee3be6b7440462102ec03a2d593213

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000

mm: introduce MADV_PAGEOUT

commit f227453a14cadd4727dd159782531d617f257001

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000

mm: introduce MADV_COLD

Patch series "Introduce MADV_COLD and MADV_PAGEOUT", v7.

I'm inclined to suggest you send this series in the 2nd half of the merge window after this MADV stuff lands for least disruption?

Thanks,
Jason

maintainer
#25 lore raw
Quoted 28 lines · On Tue, 27 Aug 2019 01:34:13 +0000 Jason Gunthorpe <[email protected]> wrote:
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Jason Gunthorpe
Quoted 3 lines

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Did we make a decision on this? Due to travel & LPC I'd like to finalize the hmm tree next week.

I don't think we've made any decision. I'd still love to see this in hmm.git. It has a minor conflict, but I can resend a rebased version.

I'm looking at this.. The hmm conflict is easy enough to fix.

But the compile conflict with these two patches in -mm requires some action from Andrew:

commit 027b9b8fd9ee3be6b7440462102ec03a2d593213

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000

mm: introduce MADV_PAGEOUT

commit f227453a14cadd4727dd159782531d617f257001

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000
Quoted 6 lines

mm: introduce MADV_COLD

Patch series "Introduce MADV_COLD and MADV_PAGEOUT", v7.

I'm inclined to suggest you send this series in the 2nd half of the merge window after this MADV stuff lands for least disruption?

Just merge it, I'll figure it out. Probably by staging Minchan's patches after linux-next.

#26 lore raw
Quoted 32 lines · Andrew Morton
Quoted 30 lines · On Tue, 27 Aug 2019 01:34:13 +0000 Jason Gunthorpe <[email protected]> wrote:
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Jason Gunthorpe
Quoted 3 lines

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Did we make a decision on this? Due to travel & LPC I'd like to finalize the hmm tree next week.

I don't think we've made any decision. I'd still love to see this in hmm.git. It has a minor conflict, but I can resend a rebased version.

I'm looking at this.. The hmm conflict is easy enough to fix.

But the compile conflict with these two patches in -mm requires some action from Andrew:

commit 027b9b8fd9ee3be6b7440462102ec03a2d593213

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000

mm: introduce MADV_PAGEOUT

commit f227453a14cadd4727dd159782531d617f257001

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000

mm: introduce MADV_COLD

Quoted 7 lines
Quoted 4 lines

Patch series "Introduce MADV_COLD and MADV_PAGEOUT", v7.

I'm inclined to suggest you send this series in the 2nd half of the merge window after this MADV stuff lands for least disruption?

Just merge it, I'll figure it out. Probably by staging Minchan's patches after linux-next.

Okay, I'll get it on a branch and merge it toward hmm.git tomorrow

Steven, do you need the branch as well for your patch series? Let me know

Thanks,
Jason

#27 lore raw
Quoted 1 line · Jason Gunthorpe

Okay, I'll get it on a branch and merge it toward hmm.git tomorrow

I was planning to resend it with the rebase, especially as the build bot picked a build error in task_mmu.c where we were missing a stub for an unusual configuration. I wish I'd remember which one that was..

#28 lore raw
In reply to Jason Gunthorpe
Quoted 38 lines · Jason Gunthorpe
Quoted 37 lines · Andrew Morton
Quoted 34 lines · On Tue, 27 Aug 2019 01:34:13 +0000 Jason Gunthorpe <[email protected]> wrote:
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Jason Gunthorpe
Quoted 3 lines

So what is the plan forward? Probably a little late for 5.3, so queue it up in -mm for 5.4 and deal with the conflicts in at least hmm? Queue it up in the hmm tree even if it doesn't 100% fit?

Did we make a decision on this? Due to travel & LPC I'd like to finalize the hmm tree next week.

I don't think we've made any decision. I'd still love to see this in hmm.git. It has a minor conflict, but I can resend a rebased version.

I'm looking at this.. The hmm conflict is easy enough to fix.

But the compile conflict with these two patches in -mm requires some action from Andrew:

commit 027b9b8fd9ee3be6b7440462102ec03a2d593213

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000

mm: introduce MADV_PAGEOUT

commit f227453a14cadd4727dd159782531d617f257001

Author: Minchan Kim <[email protected]>
Date:   Sun Aug 25 11:49:27 2019 +1000

mm: introduce MADV_COLD

Patch series "Introduce MADV_COLD and MADV_PAGEOUT", v7.

I'm inclined to suggest you send this series in the 2nd half of the merge window after this MADV stuff lands for least disruption?

Quoted 6 lines
Quoted 2 lines

Just merge it, I'll figure it out. Probably by staging Minchan's patches after linux-next.

Okay, I'll get it on a branch and merge it toward hmm.git tomorrow

Steven, do you need the branch as well for your patch series? Let me know

Since my series is (mostly) just refactoring I'm planning on rebasing it after -rc1 and aim for v5.4 - I don't really have the time just now to do that.

But please keep me in the loop because it'll reduce the surprises when I do do the rebase.

Thanks,

Steve