Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: numa: avoid unnecessary TLB flushes when setting NUMA hinting entries

If a PTE or PMD is already marked NUMA when scanning to mark entries for
NUMA hinting then it is not necessary to update the entry and incur a TLB
flush penalty. Avoid the avoidhead where possible.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Dave Jones <davej@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kirill Shutemov <kirill.shutemov@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mel Gorman and committed by
Linus Torvalds
10c1045f c0e7cad9

+12 -6
+8 -6
mm/huge_memory.c
··· 1493 1493 return 0; 1494 1494 } 1495 1495 1496 - ret = 1; 1497 - entry = pmdp_get_and_clear_notify(mm, addr, pmd); 1498 - entry = pmd_modify(entry, newprot); 1499 - ret = HPAGE_PMD_NR; 1500 - set_pmd_at(mm, addr, pmd, entry); 1501 - BUG_ON(pmd_write(entry)); 1496 + if (!prot_numa || !pmd_protnone(*pmd)) { 1497 + ret = 1; 1498 + entry = pmdp_get_and_clear_notify(mm, addr, pmd); 1499 + entry = pmd_modify(entry, newprot); 1500 + ret = HPAGE_PMD_NR; 1501 + set_pmd_at(mm, addr, pmd, entry); 1502 + BUG_ON(pmd_write(entry)); 1503 + } 1502 1504 spin_unlock(ptl); 1503 1505 } 1504 1506
+4
mm/mprotect.c
··· 86 86 page = vm_normal_page(vma, addr, oldpte); 87 87 if (!page || PageKsm(page)) 88 88 continue; 89 + 90 + /* Avoid TLB flush if possible */ 91 + if (pte_protnone(oldpte)) 92 + continue; 89 93 } 90 94 91 95 ptent = ptep_modify_prot_start(mm, addr, pte);