Skip to content

Commit b36f5b0

Browse files
hnaztorvalds
authored andcommitted
thp: mprotect: pass vma down to page table walkers
Flushing the tlb for huge pmds requires the vma's anon_vma, so pass along the vma instead of the mm, we can always get the latter when we need it. Signed-off-by: Johannes Weiner <[email protected]> Signed-off-by: Andrea Arcangeli <[email protected]> Reviewed-by: Rik van Riel <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c489f12 commit b36f5b0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mm/mprotect.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void change_pte_range(struct mm_struct *mm, pmd_t *pmd,
7878
pte_unmap_unlock(pte - 1, ptl);
7979
}
8080

81-
static inline void change_pmd_range(struct mm_struct *mm, pud_t *pud,
81+
static inline void change_pmd_range(struct vm_area_struct *vma, pud_t *pud,
8282
unsigned long addr, unsigned long end, pgprot_t newprot,
8383
int dirty_accountable)
8484
{
@@ -88,14 +88,15 @@ static inline void change_pmd_range(struct mm_struct *mm, pud_t *pud,
8888
pmd = pmd_offset(pud, addr);
8989
do {
9090
next = pmd_addr_end(addr, end);
91-
split_huge_page_pmd(mm, pmd);
91+
split_huge_page_pmd(vma->vm_mm, pmd);
9292
if (pmd_none_or_clear_bad(pmd))
9393
continue;
94-
change_pte_range(mm, pmd, addr, next, newprot, dirty_accountable);
94+
change_pte_range(vma->vm_mm, pmd, addr, next, newprot,
95+
dirty_accountable);
9596
} while (pmd++, addr = next, addr != end);
9697
}
9798

98-
static inline void change_pud_range(struct mm_struct *mm, pgd_t *pgd,
99+
static inline void change_pud_range(struct vm_area_struct *vma, pgd_t *pgd,
99100
unsigned long addr, unsigned long end, pgprot_t newprot,
100101
int dirty_accountable)
101102
{
@@ -107,7 +108,8 @@ static inline void change_pud_range(struct mm_struct *mm, pgd_t *pgd,
107108
next = pud_addr_end(addr, end);
108109
if (pud_none_or_clear_bad(pud))
109110
continue;
110-
change_pmd_range(mm, pud, addr, next, newprot, dirty_accountable);
111+
change_pmd_range(vma, pud, addr, next, newprot,
112+
dirty_accountable);
111113
} while (pud++, addr = next, addr != end);
112114
}
113115

@@ -127,7 +129,8 @@ static void change_protection(struct vm_area_struct *vma,
127129
next = pgd_addr_end(addr, end);
128130
if (pgd_none_or_clear_bad(pgd))
129131
continue;
130-
change_pud_range(mm, pgd, addr, next, newprot, dirty_accountable);
132+
change_pud_range(vma, pgd, addr, next, newprot,
133+
dirty_accountable);
131134
} while (pgd++, addr = next, addr != end);
132135
flush_tlb_range(vma, start, end);
133136
}

0 commit comments

Comments
 (0)