[PATCH] mm, hugetlb: optimize zeroing hugepage
From: Joonsoo Kim
Date: Sun Dec 22 2013 - 20:32:04 EST
When parallel faults occur, someone would be failed. In this case,
cpu cycles for zeroing failed hugepage is wasted. To reduce this overhead,
mark the hugepage as zeroed hugepage after zeroing hugepage and unmark
it as non-zeroed hugepage after it is really used. If it isn't used with
any reason, it returns back to the hugepage pool and it will be used
sometime ago. At this time, we would see zeroed page marker and skip to
do zeroing.
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 6edf423..b90b792 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -582,6 +582,7 @@ static void update_and_free_page(struct hstate *h, struct page *page)
1 << PG_private | 1 << PG_writeback);
}
VM_BUG_ON(hugetlb_cgroup_from_page(page));
+ ClearPageActive(page);
set_compound_page_dtor(page, NULL);
set_page_refcounted(page);
arch_release_hugepage(page);
@@ -2715,6 +2716,7 @@ retry_avoidcopy:
spin_lock(ptl);
ptep = huge_pte_offset(mm, address & huge_page_mask(h));
if (likely(pte_same(huge_ptep_get(ptep), pte))) {
+ ClearPageActive(new_page);
ClearPagePrivate(new_page);
/* Break COW */
@@ -2834,7 +2836,10 @@ retry:
}
goto out;
}
- clear_huge_page(page, address, pages_per_huge_page(h));
+ if (!PageActive(page)) {
+ clear_huge_page(page, address, pages_per_huge_page(h));
+ SetPageActive(page);
+ }
__SetPageUptodate(page);
if (vma->vm_flags & VM_MAYSHARE) {
@@ -2850,6 +2855,7 @@ retry:
goto retry;
goto out;
}
+ ClearPageActive(page);
ClearPagePrivate(page);
if (do_dequeue)
commit_dequeued_huge_page(vma);
@@ -2901,6 +2907,7 @@ retry:
goto backout;
if (anon_rmap) {
+ ClearPageActive(page);
ClearPagePrivate(page);
hugepage_add_new_anon_rmap(page, vma, address);
}
--
1.7.9.5
--
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/