mm: remove redundant check about FAULT_FLAG_ALLOW_RETRY bit

Since commit 4064b98270 ("mm: allow VM_FAULT_RETRY for multiple
times") allowed VM_FAULT_RETRY for multiple times, the
FAULT_FLAG_ALLOW_RETRY bit of fault_flag will not be changed in the page
fault path, so the following check is no longer needed:

	flags & FAULT_FLAG_ALLOW_RETRY

So just remove it.

[akpm@linux-foundation.org: coding style fixes]

Link: https://lkml.kernel.org/r/20211110123358.36511-1-zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Kirill Shutemov <kirill@shutemov.name>
Cc: Peter Xu <peterx@redhat.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Qi Zheng 2022-01-14 14:05:51 -08:00 committed by Linus Torvalds
parent 2c769ed713
commit 36ef159f44
22 changed files with 128 additions and 162 deletions

View File

@ -165,17 +165,15 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* No need to mmap_read_unlock(mm) as we would /* No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -149,8 +149,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
/* /*
* Fault retry nuances, mmap_lock already relinquished by core mm * Fault retry nuances, mmap_lock already relinquished by core mm
*/ */
if (unlikely((fault & VM_FAULT_RETRY) && if (unlikely(fault & VM_FAULT_RETRY)) {
(flags & FAULT_FLAG_ALLOW_RETRY))) {
flags |= FAULT_FLAG_TRIED; flags |= FAULT_FLAG_TRIED;
goto retry; goto retry;
} }

View File

@ -312,7 +312,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
return 0; return 0;
} }
if (!(fault & VM_FAULT_ERROR) && flags & FAULT_FLAG_ALLOW_RETRY) { if (!(fault & VM_FAULT_ERROR)) {
if (fault & VM_FAULT_RETRY) { if (fault & VM_FAULT_RETRY) {
flags |= FAULT_FLAG_TRIED; flags |= FAULT_FLAG_TRIED;
goto retry; goto retry;

View File

@ -606,10 +606,8 @@ static int __kprobes do_page_fault(unsigned long far, unsigned int esr,
} }
if (fault & VM_FAULT_RETRY) { if (fault & VM_FAULT_RETRY) {
if (mm_flags & FAULT_FLAG_ALLOW_RETRY) { mm_flags |= FAULT_FLAG_TRIED;
mm_flags |= FAULT_FLAG_TRIED; goto retry;
goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -98,11 +98,9 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)
/* The most common case -- we are done. */ /* The most common case -- we are done. */
if (likely(!(fault & VM_FAULT_ERROR))) { if (likely(!(fault & VM_FAULT_ERROR))) {
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED; goto retry;
goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -156,17 +156,15 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* No need to mmap_read_unlock(mm) as we would /* No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -153,18 +153,16 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* /*
* No need to mmap_read_unlock(mm) as we would * No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -232,18 +232,16 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* /*
* No need to mmap_read_unlock(mm) as we would * No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -171,18 +171,17 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
goto do_sigbus; goto do_sigbus;
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) {
if (fault & VM_FAULT_RETRY) {
flags |= FAULT_FLAG_TRIED;
/* if (fault & VM_FAULT_RETRY) {
* No need to mmap_read_unlock(mm) as we would flags |= FAULT_FLAG_TRIED;
* have already released it in __lock_page_or_retry
* in mm/filemap.c.
*/
goto retry; /*
} * No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry
* in mm/filemap.c.
*/
goto retry;
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -230,16 +230,14 @@ void do_page_fault(unsigned long entry, unsigned long addr,
goto bad_area; goto bad_area;
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* No need to mmap_read_unlock(mm) as we would /* No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -149,18 +149,16 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* /*
* No need to mmap_read_unlock(mm) as we would * No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -177,18 +177,16 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { /*RGD modeled on Cris */
/*RGD modeled on Cris */ if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* No need to mmap_read_unlock(mm) as we would /* No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -324,16 +324,14 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
goto bad_area; goto bad_area;
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { /*
/* * No need to mmap_read_unlock(mm) as we would
* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry
* have already released it in __lock_page_or_retry * in mm/filemap.c.
* in mm/filemap.c. */
*/ flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED; goto retry;
goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);
return; return;

View File

@ -516,10 +516,8 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,
* case. * case.
*/ */
if (unlikely(fault & VM_FAULT_RETRY)) { if (unlikely(fault & VM_FAULT_RETRY)) {
if (flags & FAULT_FLAG_ALLOW_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED; goto retry;
goto retry;
}
} }
mmap_read_unlock(current->mm); mmap_read_unlock(current->mm);

View File

@ -330,7 +330,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
if (fault_signal_pending(fault, regs)) if (fault_signal_pending(fault, regs))
return; return;
if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) { if (unlikely(fault & VM_FAULT_RETRY)) {
flags |= FAULT_FLAG_TRIED; flags |= FAULT_FLAG_TRIED;
/* /*

View File

@ -452,21 +452,21 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access)
if (unlikely(fault & VM_FAULT_ERROR)) if (unlikely(fault & VM_FAULT_ERROR))
goto out_up; goto out_up;
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { if (IS_ENABLED(CONFIG_PGSTE) && gmap &&
if (IS_ENABLED(CONFIG_PGSTE) && gmap && (flags & FAULT_FLAG_RETRY_NOWAIT)) {
(flags & FAULT_FLAG_RETRY_NOWAIT)) { /*
/* FAULT_FLAG_RETRY_NOWAIT has been set, * FAULT_FLAG_RETRY_NOWAIT has been set, mmap_lock has
* mmap_lock has not been released */ * not been released
current->thread.gmap_pfault = 1; */
fault = VM_FAULT_PFAULT; current->thread.gmap_pfault = 1;
goto out_up; fault = VM_FAULT_PFAULT;
} goto out_up;
flags &= ~FAULT_FLAG_RETRY_NOWAIT;
flags |= FAULT_FLAG_TRIED;
mmap_read_lock(mm);
goto retry;
} }
flags &= ~FAULT_FLAG_RETRY_NOWAIT;
flags |= FAULT_FLAG_TRIED;
mmap_read_lock(mm);
goto retry;
} }
if (IS_ENABLED(CONFIG_PGSTE) && gmap) { if (IS_ENABLED(CONFIG_PGSTE) && gmap) {
address = __gmap_link(gmap, current->thread.gmap_addr, address = __gmap_link(gmap, current->thread.gmap_addr,

View File

@ -485,17 +485,15 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
if (mm_fault_error(regs, error_code, address, fault)) if (mm_fault_error(regs, error_code, address, fault))
return; return;
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* /*
* No need to mmap_read_unlock(mm) as we would * No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -200,17 +200,15 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* No need to mmap_read_unlock(mm) as we would /* No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -437,17 +437,15 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
/* No need to mmap_read_unlock(mm) as we would /* No need to mmap_read_unlock(mm) as we would
* have already released it in __lock_page_or_retry * have already released it in __lock_page_or_retry
* in mm/filemap.c. * in mm/filemap.c.
*/ */
goto retry; goto retry;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);

View File

@ -87,12 +87,10 @@ int handle_page_fault(unsigned long address, unsigned long ip,
} }
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_RETRY) {
if (fault & VM_FAULT_RETRY) { flags |= FAULT_FLAG_TRIED;
flags |= FAULT_FLAG_TRIED;
goto retry; goto retry;
}
} }
pmd = pmd_off(mm, address); pmd = pmd_off(mm, address);

View File

@ -1413,8 +1413,7 @@ void do_user_addr_fault(struct pt_regs *regs,
* and if there is a fatal signal pending there is no guarantee * and if there is a fatal signal pending there is no guarantee
* that we made any progress. Handle this case first. * that we made any progress. Handle this case first.
*/ */
if (unlikely((fault & VM_FAULT_RETRY) && if (unlikely(fault & VM_FAULT_RETRY)) {
(flags & FAULT_FLAG_ALLOW_RETRY))) {
flags |= FAULT_FLAG_TRIED; flags |= FAULT_FLAG_TRIED;
goto retry; goto retry;
} }

View File

@ -127,17 +127,16 @@ void do_page_fault(struct pt_regs *regs)
goto do_sigbus; goto do_sigbus;
BUG(); BUG();
} }
if (flags & FAULT_FLAG_ALLOW_RETRY) {
if (fault & VM_FAULT_RETRY) {
flags |= FAULT_FLAG_TRIED;
/* No need to mmap_read_unlock(mm) as we would if (fault & VM_FAULT_RETRY) {
* have already released it in __lock_page_or_retry flags |= FAULT_FLAG_TRIED;
* in mm/filemap.c.
*/
goto retry; /* No need to mmap_read_unlock(mm) as we would
} * have already released it in __lock_page_or_retry
* in mm/filemap.c.
*/
goto retry;
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);