Skip to contentSkip to conversation

+ mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Jun 11, 2014

Subsystems (6)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Wed, 11 Jun 2014 16:21:29 -0700

The patch titled

     Subject: mm/pagewalk: replace mm_walk->skip with more general mm_walk->control

has been added to the -mm tree. Its filename is
mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Naoya Horiguchi <[email protected]>
Subject: mm/pagewalk: replace mm_walk->skip with more general mm_walk->control

Originally mm_walk->skip is used to determine whether we walk over a vma or not. But this is not enough because one of the page table walker's caller subpage_mark_vma_nohuge(), will need another behavior PTWALK_BREAK, which let us break current loop and continue from the beginning of the next loop.

To implement this behavior and make it extensible for future users, this patch replaces mm_walk->skip with more flexible mm_walk->control, and changes its default value to PTWALK_NEXT (which is equivalent to present walk->skip == 1.) This is because PTWALK_NEXT provides the behavior which is most likely to be used globally.

Cc Dave Hansen <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Michal Hocko <[email protected]>
Cc KOSAKI Motohiro <[email protected]>
Cc KAMEZAWA Hiroyuki <[email protected]>
Cc "Aneesh Kumar K.V" <[email protected]>
Cc Pavel Emelyanov <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>

---

 fs/proc/task_mmu.c |   20 ++++------
 include/linux/mm.h |   13 +++++--
 mm/memcontrol.c    |    5 +-
 mm/mempolicy.c     |    3 -
 mm/pagewalk.c      |   79 ++++++++++++++++++++++++++-----------------
 5 files changed, 71 insertions(+), 49 deletions(-)
fs/proc/task_mmu.c renamed from fs/proc/task_mmu.c~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control +9 -11
diff -puN fs/proc/task_mmu.c~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control fs/proc/task_mmu.c
@@ -508,9 +508,8 @@ static int smaps_pmd(pmd_t *pmd, unsigne
 		smaps_pte((pte_t *)pmd, addr, addr + HPAGE_PMD_SIZE, walk);
 		spin_unlock(ptl);
 		mss->anonymous_thp += HPAGE_PMD_SIZE;
-		/* don't call smaps_pte() */
-		walk->skip = 1;
-	}
+	} else
+		walk->control = PTWALK_DOWN;
 	return 0;
 }
 
@@ -821,13 +820,14 @@ static int clear_refs_test_walk(unsigned
 	 * Writing 4 to /proc/pid/clear_refs affects all pages.
 	 */
 	if (cp->type == CLEAR_REFS_ANON && vma->vm_file)
-		walk->skip = 1;
+		return 0;
 	if (cp->type == CLEAR_REFS_MAPPED && !vma->vm_file)
-		walk->skip = 1;
+		return 0;
 	if (cp->type == CLEAR_REFS_SOFT_DIRTY) {
 		if (vma->vm_flags & VM_SOFTDIRTY)
 			vma->vm_flags &= ~VM_SOFTDIRTY;
 	}
+	walk->control = PTWALK_DOWN;
 	return 0;
 }
 
@@ -1066,9 +1066,8 @@ static int pagemap_pmd(pmd_t *pmd, unsig
 				break;
 		}
 		spin_unlock(ptl);
-		/* don't call pagemap_pte() */
-		walk->skip = 1;
-	}
+	} else
+		walk->control = PTWALK_DOWN;
 	return err;
 }
 
@@ -1348,9 +1347,8 @@ static int gather_pmd_stats(pmd_t *pmd,
 			gather_stats(page, md, pte_dirty(huge_pte),
 				     HPAGE_PMD_SIZE/PAGE_SIZE);
 		spin_unlock(ptl);
-		/* don't call gather_pte_stats() */
-		walk->skip = 1;
-	}
+	} else
+		walk->control = PTWALK_DOWN;
 	return 0;
 }
 #ifdef CONFIG_HUGETLB_PAGE
include/linux/mm.h renamed from include/linux/mm.h~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control +10 -3
diff -puN include/linux/mm.h~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control include/linux/mm.h
@@ -1112,8 +1112,7 @@ void unmap_vmas(struct mmu_gather *tlb,
  *             walk_page_test() for how the skip control works.
  * @mm:        mm_struct representing the target process of page table walk
  * @vma:       vma currently walked
- * @skip:      internal control flag which is set when we skip the lower
- *             level entries.
+ * @control:   walk control flag
  * @private:   private data for callbacks' use
  *
  * (see the comment on walk_page_range() for more details)
@@ -1131,10 +1130,18 @@ struct mm_walk {
 			struct mm_walk *walk);
 	struct mm_struct *mm;
 	struct vm_area_struct *vma;
-	int skip;
+	int control;
 	void *private;
 };
 
+enum mm_walk_control {
+	PTWALK_NEXT = 0,	/* Go to the next entry in the same level or
+				 * the next vma. This is default behavior. */
+	PTWALK_DOWN,		/* Go down to lower level */
+	PTWALK_BREAK,		/* Break current loop and continue from the
+				 * next loop */
+};
+
 int walk_page_range(unsigned long addr, unsigned long end,
 		struct mm_walk *walk);
 int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk);
mm/memcontrol.c renamed from mm/memcontrol.c~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control +2 -3
diff -puN mm/memcontrol.c~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control mm/memcontrol.c
@@ -6670,9 +6670,8 @@ static int mem_cgroup_count_precharge_pm
 		if (get_mctgt_type_thp(vma, addr, *pmd, NULL) == MC_TARGET_PAGE)
 			mc.precharge += HPAGE_PMD_NR;
 		spin_unlock(ptl);
-		/* don't call mem_cgroup_count_precharge_pte() */
-		walk->skip = 1;
-	}
+	} else
+		skip->control = PTWALK_DOWN;
 	return 0;
 }
 
mm/mempolicy.c renamed from mm/mempolicy.c~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control +1 -2
diff -puN mm/mempolicy.c~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control mm/mempolicy.c
@@ -596,7 +596,6 @@ static int queue_pages_test_walk(unsigne
 	}
 
 	qp->prev = vma;
-	walk->skip = 1;
 
 	if (vma->vm_flags & VM_PFNMAP)
 		return 0;
@@ -610,7 +609,7 @@ static int queue_pages_test_walk(unsigne
 	    ((flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) &&
 	     vma_migratable(vma)))
 		/* queue pages from current vma */
-		walk->skip = 0;
+		walk->control = PTWALK_DOWN;
 	return 0;
 }
 
mm/pagewalk.c renamed from mm/pagewalk.c~mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control +49 -30

135 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are

origin.patch hwpoison-fix-the-handling-path-of-the-victimized-page-frame-that-belong-to-non-lur.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v2.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v3.patch mm-hugetlbfs-fix-rmapping-for-anonymous-hugepages-with-page_pgoff-v3-fix.patch pagewalk-update-page-table-walker-core.patch pagewalk-update-page-table-walker-core-fix-end-address-calculation-in-walk_page_range.patch pagewalk-update-page-table-walker-core-fix-end-address-calculation-in-walk_page_range-fix.patch pagewalk-update-page-table-walker-core-fix.patch pagewalk-add-walk_page_vma.patch smaps-redefine-callback-functions-for-page-table-walker.patch clear_refs-redefine-callback-functions-for-page-table-walker.patch pagemap-redefine-callback-functions-for-page-table-walker.patch pagemap-redefine-callback-functions-for-page-table-walker-fix.patch numa_maps-redefine-callback-functions-for-page-table-walker.patch memcg-redefine-callback-functions-for-page-table-walker.patch arch-powerpc-mm-subpage-protc-use-walk_page_vma-instead-of-walk_page_range.patch pagewalk-remove-argument-hmask-from-hugetlb_entry.patch pagewalk-remove-argument-hmask-from-hugetlb_entry-fix.patch pagewalk-remove-argument-hmask-from-hugetlb_entry-fix-fix.patch mempolicy-apply-page-table-walker-on-queue_pages_range.patch mm-pagewalkc-move-pte-null-check.patch mm-prom-pid-clear_refs-avoid-split_huge_page.patch mm-pagewalk-remove-pgd_entry-and-pud_entry.patch mm-pagewalk-replace-mm_walk-skip-with-more-general-mm_walk-control.patch madvise-cleanup-swapin_walk_pmd_entry.patch memcg-separate-mem_cgroup_move_charge_pte_range.patch arch-powerpc-mm-subpage-protc-cleanup-subpage_walk_pmd_entry.patch mm-pagewalk-move-pmd_trans_huge_lock-from-callbacks-to-common-code.patch mincore-apply-page-table-walker-on-do_mincore.patch mm-introduce-do_shared_fault-and-drop-do_fault-fix-fix.patch do_shared_fault-check-that-mmap_sem-is-held.patch