From: Peter Xu <pet...@redhat.com>

Let's move the fatal signal check even earlier so that we can directly use
the new fault_signal_pending() in x86 mm code.

Signed-off-by: Peter Xu <pet...@redhat.com>
Signed-off-by: Andrew Morton <a...@linux-foundation.org>
Tested-by: Brian Geffon <bgef...@google.com>
Cc: Andrea Arcangeli <aarca...@redhat.com>
Cc: Bobby Powers <bobbypow...@gmail.com>
Cc: David Hildenbrand <da...@redhat.com>
Cc: Denis Plotnikov <dplotni...@virtuozzo.com>
Cc: "Dr . David Alan Gilbert" <dgilb...@redhat.com>
Cc: Hugh Dickins <hu...@google.com>
Cc: Jerome Glisse <jgli...@redhat.com>
Cc: Johannes Weiner <han...@cmpxchg.org>
Cc: "Kirill A . Shutemov" <kir...@shutemov.name>
Cc: Martin Cracauer <craca...@cons.org>
Cc: Marty McFadden <mcfadd...@llnl.gov>
Cc: Matthew Wilcox <wi...@infradead.org>
Cc: Maya Gokhale <gokha...@llnl.gov>
Cc: Mel Gorman <mgor...@suse.de>
Cc: Mike Kravetz <mike.krav...@oracle.com>
Cc: Mike Rapoport <r...@linux.vnet.ibm.com>
Cc: Pavel Emelyanov <xe...@openvz.org>
Link: http://lkml.kernel.org/r/20200220155353.8676-5-pet...@redhat.com
Signed-off-by: Linus Torvalds <torva...@linux-foundation.org>

https://jira.sw.ru/browse/PSBM-102938
(cherry picked from commit 39678191cd8988c811813baf4c97b43bf46094e4)
Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
---
 arch/x86/mm/fault.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index cdafd5fa6d0a..8e71ebad64a1 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1405,27 +1405,25 @@ __do_page_fault(struct pt_regs *regs, unsigned long 
error_code,
        fault = handle_mm_fault(vma, address, flags);
        major |= fault & VM_FAULT_MAJOR;
 
+       /* Quick path to respond to signals */
+       if (fault_signal_pending(fault, regs)) {
+               if (!user_mode(regs))
+                       no_context(regs, error_code, address, SIGBUS,
+                                  BUS_ADRERR);
+               return;
+       }
+
        /*
         * If we need to retry the mmap_sem has already been released,
         * and if there is a fatal signal pending there is no guarantee
         * 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))) {
                /* Retry at most once */
-               if (flags & FAULT_FLAG_ALLOW_RETRY) {
-                       flags &= ~FAULT_FLAG_ALLOW_RETRY;
-                       flags |= FAULT_FLAG_TRIED;
-                       if (!fatal_signal_pending(tsk))
-                               goto retry;
-               }
-
-               /* User mode? Just return to handle the fatal exception */
-               if (flags & FAULT_FLAG_USER)
-                       return;
-
-               /* Not returning to user mode? Handle exceptions or die: */
-               no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
-               return;
+               flags &= ~FAULT_FLAG_ALLOW_RETRY;
+               flags |= FAULT_FLAG_TRIED;
+               goto retry;
        }
 
        up_read(&mm->mmap_sem);
-- 
2.25.3

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to