[PATCH 06/10] mm: mincore: clean up hugetlbfs handler (part 2)

From: Dave Hansen
Date: Mon Jun 02 2014 - 17:36:58 EST



From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>

The walk_page_range() code calls in to the ->hugetlbfs_entry
handler once for each huge page table entry. This means that
addr and end are always within the same huge page. (Well, end is
not technically _within_ it, because it is exclusive.)

The outer while() loop in mincore_hugetlb_page_range() appears to
be designed to work if we crossed a huge page boundary to a new
huge pte and 'present' changed. However, that is impossible for
two reasons:

1. The above-mentioned walk_page_range() restriction
2. We never move ptep

So the outer while() along with the check for crossing the end of
the huge page boundary (which is impossible) make no sense. Once
we peel it off, it's clear that we can just make the 'return' in
to the loop condition.

Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
---

b/mm/mincore.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff -puN mm/mincore.c~cleanup-hugetlbfs-mincore-2 mm/mincore.c
--- a/mm/mincore.c~cleanup-hugetlbfs-mincore-2 2014-06-02 14:20:20.426858178 -0700
+++ b/mm/mincore.c 2014-06-02 14:20:20.430858359 -0700
@@ -24,23 +24,17 @@ static int mincore_hugetlb_page_range(pt
struct mm_walk *walk)
{
unsigned char *vec = walk->private;
+ int present;

/* This is as good as an explicit ifdef */
if (!is_vm_hugetlb_page(walk->vma))
return 0;

- while (1) {
- int present = !huge_pte_none(huge_ptep_get(ptep));
- while (1) {
- *vec = present;
- vec++;
- addr += PAGE_SIZE;
- if (addr == end)
- return 0;
- /* check hugepage border */
- if (!(addr & hmask))
- break;
- }
+ present = !huge_pte_none(huge_ptep_get(ptep));
+ while (addr < end) {
+ *vec = present;
+ vec++;
+ addr += PAGE_SIZE;
}
return 0;
}
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/