Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10c1045f authored by Mel Gorman's avatar Mel Gorman Committed by Linus Torvalds
Browse files

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: default avatarMel 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c0e7cad9
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -1493,12 +1493,14 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
			return 0;
			return 0;
		}
		}


		if (!prot_numa || !pmd_protnone(*pmd)) {
			ret = 1;
			ret = 1;
			entry = pmdp_get_and_clear_notify(mm, addr, pmd);
			entry = pmdp_get_and_clear_notify(mm, addr, pmd);
			entry = pmd_modify(entry, newprot);
			entry = pmd_modify(entry, newprot);
			ret = HPAGE_PMD_NR;
			ret = HPAGE_PMD_NR;
			set_pmd_at(mm, addr, pmd, entry);
			set_pmd_at(mm, addr, pmd, entry);
			BUG_ON(pmd_write(entry));
			BUG_ON(pmd_write(entry));
		}
		spin_unlock(ptl);
		spin_unlock(ptl);
	}
	}


+4 −0
Original line number Original line Diff line number Diff line
@@ -86,6 +86,10 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
				page = vm_normal_page(vma, addr, oldpte);
				page = vm_normal_page(vma, addr, oldpte);
				if (!page || PageKsm(page))
				if (!page || PageKsm(page))
					continue;
					continue;

				/* Avoid TLB flush if possible */
				if (pte_protnone(oldpte))
					continue;
			}
			}


			ptent = ptep_modify_prot_start(mm, addr, pte);
			ptent = ptep_modify_prot_start(mm, addr, pte);