Commit a72afd87 authored by Will Deacon's avatar Will Deacon Committed by Peter Zijlstra

tlb: mmu_gather: Remove start/end arguments from tlb_gather_mmu()

The 'start' and 'end' arguments to tlb_gather_mmu() are no longer
needed now that there is a separate function for 'fullmm' flushing.

Remove the unused arguments and update all callers.
Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarYu Zhao <yuzhao@google.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/CAHk-=wjQWa14_4UpfDf=fiineNP+RH74kZeDMo_f1D35xNzq9w@mail.gmail.com
parent d8b45053
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* unmapping a portion of the virtual address space, these hooks are called according to * unmapping a portion of the virtual address space, these hooks are called according to
* the following template: * the following template:
* *
* tlb <- tlb_gather_mmu(mm, start, end); // start unmap for address space MM * tlb <- tlb_gather_mmu(mm); // start unmap for address space MM
* { * {
* for each vma that needs a shootdown do { * for each vma that needs a shootdown do {
* tlb_start_vma(tlb, vma); * tlb_start_vma(tlb, vma);
......
...@@ -398,7 +398,7 @@ static void free_ldt_pgtables(struct mm_struct *mm) ...@@ -398,7 +398,7 @@ static void free_ldt_pgtables(struct mm_struct *mm)
if (!boot_cpu_has(X86_FEATURE_PTI)) if (!boot_cpu_has(X86_FEATURE_PTI))
return; return;
tlb_gather_mmu(&tlb, mm, start, end); tlb_gather_mmu(&tlb, mm);
free_pgd_range(&tlb, start, end, start, end); free_pgd_range(&tlb, start, end, start, end);
tlb_finish_mmu(&tlb); tlb_finish_mmu(&tlb);
#endif #endif
......
...@@ -708,7 +708,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift) ...@@ -708,7 +708,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
return -ENOMEM; return -ENOMEM;
lru_add_drain(); lru_add_drain();
tlb_gather_mmu(&tlb, mm, old_start, old_end); tlb_gather_mmu(&tlb, mm);
if (new_end > old_start) { if (new_end > old_start) {
/* /*
* when the old and new regions overlap clear from new_end. * when the old and new regions overlap clear from new_end.
......
...@@ -588,8 +588,7 @@ static inline cpumask_t *mm_cpumask(struct mm_struct *mm) ...@@ -588,8 +588,7 @@ static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
} }
struct mmu_gather; struct mmu_gather;
extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm);
unsigned long start, unsigned long end);
extern void tlb_gather_mmu_fullmm(struct mmu_gather *tlb, struct mm_struct *mm); extern void tlb_gather_mmu_fullmm(struct mmu_gather *tlb, struct mm_struct *mm);
extern void tlb_finish_mmu(struct mmu_gather *tlb); extern void tlb_finish_mmu(struct mmu_gather *tlb);
......
...@@ -3967,23 +3967,9 @@ void __unmap_hugepage_range_final(struct mmu_gather *tlb, ...@@ -3967,23 +3967,9 @@ void __unmap_hugepage_range_final(struct mmu_gather *tlb,
void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end, struct page *ref_page) unsigned long end, struct page *ref_page)
{ {
struct mm_struct *mm;
struct mmu_gather tlb; struct mmu_gather tlb;
unsigned long tlb_start = start;
unsigned long tlb_end = end;
/* tlb_gather_mmu(&tlb, vma->vm_mm);
* If shared PMDs were possibly used within this vma range, adjust
* start/end for worst case tlb flushing.
* Note that we can not be sure if PMDs are shared until we try to
* unmap pages. However, we want to make sure TLB flushing covers
* the largest possible range.
*/
adjust_range_if_pmd_sharing_possible(vma, &tlb_start, &tlb_end);
mm = vma->vm_mm;
tlb_gather_mmu(&tlb, mm, tlb_start, tlb_end);
__unmap_hugepage_range(&tlb, vma, start, end, ref_page); __unmap_hugepage_range(&tlb, vma, start, end, ref_page);
tlb_finish_mmu(&tlb); tlb_finish_mmu(&tlb);
} }
......
...@@ -506,7 +506,7 @@ static long madvise_cold(struct vm_area_struct *vma, ...@@ -506,7 +506,7 @@ static long madvise_cold(struct vm_area_struct *vma,
return -EINVAL; return -EINVAL;
lru_add_drain(); lru_add_drain();
tlb_gather_mmu(&tlb, mm, start_addr, end_addr); tlb_gather_mmu(&tlb, mm);
madvise_cold_page_range(&tlb, vma, start_addr, end_addr); madvise_cold_page_range(&tlb, vma, start_addr, end_addr);
tlb_finish_mmu(&tlb); tlb_finish_mmu(&tlb);
...@@ -558,7 +558,7 @@ static long madvise_pageout(struct vm_area_struct *vma, ...@@ -558,7 +558,7 @@ static long madvise_pageout(struct vm_area_struct *vma,
return 0; return 0;
lru_add_drain(); lru_add_drain();
tlb_gather_mmu(&tlb, mm, start_addr, end_addr); tlb_gather_mmu(&tlb, mm);
madvise_pageout_page_range(&tlb, vma, start_addr, end_addr); madvise_pageout_page_range(&tlb, vma, start_addr, end_addr);
tlb_finish_mmu(&tlb); tlb_finish_mmu(&tlb);
...@@ -723,7 +723,7 @@ static int madvise_free_single_vma(struct vm_area_struct *vma, ...@@ -723,7 +723,7 @@ static int madvise_free_single_vma(struct vm_area_struct *vma,
range.start, range.end); range.start, range.end);
lru_add_drain(); lru_add_drain();
tlb_gather_mmu(&tlb, mm, range.start, range.end); tlb_gather_mmu(&tlb, mm);
update_hiwater_rss(mm); update_hiwater_rss(mm);
mmu_notifier_invalidate_range_start(&range); mmu_notifier_invalidate_range_start(&range);
......
...@@ -1534,7 +1534,7 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start, ...@@ -1534,7 +1534,7 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start,
lru_add_drain(); lru_add_drain();
mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm, mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm,
start, start + size); start, start + size);
tlb_gather_mmu(&tlb, vma->vm_mm, start, range.end); tlb_gather_mmu(&tlb, vma->vm_mm);
update_hiwater_rss(vma->vm_mm); update_hiwater_rss(vma->vm_mm);
mmu_notifier_invalidate_range_start(&range); mmu_notifier_invalidate_range_start(&range);
for ( ; vma && vma->vm_start < range.end; vma = vma->vm_next) for ( ; vma && vma->vm_start < range.end; vma = vma->vm_next)
...@@ -1561,7 +1561,7 @@ static void zap_page_range_single(struct vm_area_struct *vma, unsigned long addr ...@@ -1561,7 +1561,7 @@ static void zap_page_range_single(struct vm_area_struct *vma, unsigned long addr
lru_add_drain(); lru_add_drain();
mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm, mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm,
address, address + size); address, address + size);
tlb_gather_mmu(&tlb, vma->vm_mm, address, range.end); tlb_gather_mmu(&tlb, vma->vm_mm);
update_hiwater_rss(vma->vm_mm); update_hiwater_rss(vma->vm_mm);
mmu_notifier_invalidate_range_start(&range); mmu_notifier_invalidate_range_start(&range);
unmap_single_vma(&tlb, vma, address, range.end, details); unmap_single_vma(&tlb, vma, address, range.end, details);
......
...@@ -2671,7 +2671,7 @@ static void unmap_region(struct mm_struct *mm, ...@@ -2671,7 +2671,7 @@ static void unmap_region(struct mm_struct *mm,
struct mmu_gather tlb; struct mmu_gather tlb;
lru_add_drain(); lru_add_drain();
tlb_gather_mmu(&tlb, mm, start, end); tlb_gather_mmu(&tlb, mm);
update_hiwater_rss(mm); update_hiwater_rss(mm);
unmap_vmas(&tlb, vma, start, end); unmap_vmas(&tlb, vma, start, end);
free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS, free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS,
......
...@@ -253,21 +253,17 @@ void tlb_flush_mmu(struct mmu_gather *tlb) ...@@ -253,21 +253,17 @@ void tlb_flush_mmu(struct mmu_gather *tlb)
* tlb_gather_mmu - initialize an mmu_gather structure for page-table tear-down * tlb_gather_mmu - initialize an mmu_gather structure for page-table tear-down
* @tlb: the mmu_gather structure to initialize * @tlb: the mmu_gather structure to initialize
* @mm: the mm_struct of the target address space * @mm: the mm_struct of the target address space
* @start: start of the region that will be removed from the page-table * @fullmm: @mm is without users and we're going to destroy the full address
* @end: end of the region that will be removed from the page-table * space (exit/execve)
* *
* Called to initialize an (on-stack) mmu_gather structure for page-table * Called to initialize an (on-stack) mmu_gather structure for page-table
* tear-down from @mm. The @start and @end are set to 0 and -1 * tear-down from @mm.
* respectively when @mm is without users and we're going to destroy
* the full address space (exit/execve).
*/ */
static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
unsigned long start, unsigned long end) bool fullmm)
{ {
tlb->mm = mm; tlb->mm = mm;
tlb->fullmm = fullmm;
/* Is it from 0 to ~0? */
tlb->fullmm = !(start | (end+1));
#ifndef CONFIG_MMU_GATHER_NO_GATHER #ifndef CONFIG_MMU_GATHER_NO_GATHER
tlb->need_flush_all = 0; tlb->need_flush_all = 0;
...@@ -287,16 +283,14 @@ static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, ...@@ -287,16 +283,14 @@ static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
inc_tlb_flush_pending(tlb->mm); inc_tlb_flush_pending(tlb->mm);
} }
void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm)
unsigned long start, unsigned long end)
{ {
WARN_ON(!(start | (end + 1))); /* Use _fullmm() instead */ __tlb_gather_mmu(tlb, mm, false);
__tlb_gather_mmu(tlb, mm, start, end);
} }
void tlb_gather_mmu_fullmm(struct mmu_gather *tlb, struct mm_struct *mm) void tlb_gather_mmu_fullmm(struct mmu_gather *tlb, struct mm_struct *mm)
{ {
__tlb_gather_mmu(tlb, mm, 0, -1); __tlb_gather_mmu(tlb, mm, true);
} }
/** /**
......
...@@ -546,7 +546,7 @@ bool __oom_reap_task_mm(struct mm_struct *mm) ...@@ -546,7 +546,7 @@ bool __oom_reap_task_mm(struct mm_struct *mm)
mmu_notifier_range_init(&range, MMU_NOTIFY_UNMAP, 0, mmu_notifier_range_init(&range, MMU_NOTIFY_UNMAP, 0,
vma, mm, vma->vm_start, vma, mm, vma->vm_start,
vma->vm_end); vma->vm_end);
tlb_gather_mmu(&tlb, mm, range.start, range.end); tlb_gather_mmu(&tlb, mm);
if (mmu_notifier_invalidate_range_start_nonblock(&range)) { if (mmu_notifier_invalidate_range_start_nonblock(&range)) {
tlb_finish_mmu(&tlb); tlb_finish_mmu(&tlb);
ret = false; ret = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment