mm: numa: Do not migrate or account for hinting faults on the zero page
authorMel Gorman <mgorman@suse.de>
Mon, 7 Oct 2013 10:28:50 +0000 (11:28 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 9 Oct 2013 10:39:50 +0000 (12:39 +0200)
The zero page is not replicated between nodes and is often shared between
processes. The data is read-only and likely to be cached in local CPUs
if heavily accessed meaning that the remote memory access cost is less
of a concern. This patch prevents trapping faults on the zero pages. For
tasks using the zero page this will reduce the number of PTE updates,
TLB flushes and hinting faults.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
[ Correct use of is_huge_zero_page]
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1381141781-10992-13-git-send-email-mgorman@suse.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
mm/huge_memory.c
mm/memory.c

index de8d5cfc2bf2f9dffd873a4aef44fa69d4ba76a8..8677dbf31c2efd0c29a9c655b03ba5527f4bdf95 100644 (file)
@@ -1291,6 +1291,7 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
                goto out_unlock;
 
        page = pmd_page(pmd);
+       BUG_ON(is_huge_zero_page(page));
        page_nid = page_to_nid(page);
        count_vm_numa_event(NUMA_HINT_FAULTS);
        if (page_nid == this_nid)
@@ -1481,8 +1482,15 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
                } else {
                        struct page *page = pmd_page(*pmd);
 
-                       /* only check non-shared pages */
+                       /*
+                        * Only check non-shared pages. Do not trap faults
+                        * against the zero page. The read-only data is likely
+                        * to be read-cached on the local CPU cache and it is
+                        * less useful to know about local vs remote hits on
+                        * the zero page.
+                        */
                        if (page_mapcount(page) == 1 &&
+                           !is_huge_zero_page(page) &&
                            !pmd_numa(*pmd)) {
                                entry = pmdp_get_and_clear(mm, addr, pmd);
                                entry = pmd_mknuma(entry);
index 42ae82ee04c1ebde53ec2c50abe42b614e966527..ed51f15136ee9638e4cb9ffe51a3b35b57e15732 100644 (file)
@@ -3564,6 +3564,7 @@ int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
                pte_unmap_unlock(ptep, ptl);
                return 0;
        }
+       BUG_ON(is_zero_pfn(page_to_pfn(page)));
 
        page_nid = page_to_nid(page);
        target_nid = numa_migrate_prep(page, vma, addr, page_nid);