Commit 0c5f83c23ca703d32f930393825487257a5cde6d

Authored by Mel Gorman
Committed by Linus Torvalds
1 parent 5a6dac3ec5

mm: numa: do not clear PTE for pte_numa update

The TLB must be flushed if the PTE is updated but change_pte_range is
clearing the PTE while marking PTEs pte_numa without necessarily
flushing the TLB if it reinserts the same entry.  Without the flush,
it's conceivable that two processors have different TLBs for the same
virtual address and at the very least it would generate spurious faults.

This patch only unmaps the pages in change_pte_range for a full
protection change.

[riel@redhat.com: write pte_numa pte back to the page tables]
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Rik van Riel <riel@redhat.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Alex Thorlton <athorlton@sgi.com>
Cc: Chegu Vinod <chegu_vinod@hp.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 7 additions and 2 deletions Side-by-side Diff

... ... @@ -52,17 +52,19 @@
52 52 pte_t ptent;
53 53 bool updated = false;
54 54  
55   - ptent = ptep_modify_prot_start(mm, addr, pte);
56 55 if (!prot_numa) {
  56 + ptent = ptep_modify_prot_start(mm, addr, pte);
57 57 ptent = pte_modify(ptent, newprot);
58 58 updated = true;
59 59 } else {
60 60 struct page *page;
61 61  
  62 + ptent = *pte;
62 63 page = vm_normal_page(vma, addr, oldpte);
63 64 if (page) {
64 65 if (!pte_numa(oldpte)) {
65 66 ptent = pte_mknuma(ptent);
  67 + set_pte_at(mm, addr, pte, ptent);
66 68 updated = true;
67 69 }
68 70 }
... ... @@ -79,7 +81,10 @@
79 81  
80 82 if (updated)
81 83 pages++;
82   - ptep_modify_prot_commit(mm, addr, pte, ptent);
  84 +
  85 + /* Only !prot_numa always clears the pte */
  86 + if (!prot_numa)
  87 + ptep_modify_prot_commit(mm, addr, pte, ptent);
83 88 } else if (IS_ENABLED(CONFIG_MIGRATION) && !pte_file(oldpte)) {
84 89 swp_entry_t entry = pte_to_swp_entry(oldpte);
85 90