[Devel] [PATCH RHEL8 COMMIT] mm: return faster for non-fatal signals in user mode faults

Konstantin Khorenko khorenko at virtuozzo.com
Mon Apr 20 10:34:16 MSK 2020


The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.3.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.3.6
------>
commit f3e2932d6c5342c95ed24a5695850b714673ca89
Author: Peter Xu <peterx at redhat.com>
Date:   Mon Apr 20 10:34:15 2020 +0300

    mm: return faster for non-fatal signals in user mode faults
    
    The idea comes from the upstream discussion between Linus and Andrea:
    
      https://lore.kernel.org/lkml/20171102193644.GB22686@redhat.com/
    
    A summary to the issue: there was a special path in handle_userfault() in
    the past that we'll return a VM_FAULT_NOPAGE when we detected non-fatal
    signals when waiting for userfault handling.  We did that by reacquiring
    the mmap_sem before returning.  However that brings a risk in that the
    vmas might have changed when we retake the mmap_sem and even we could be
    holding an invalid vma structure.
    
    This patch is a preparation of removing that special path by allowing the
    page fault to return even faster if we were interrupted by a non-fatal
    signal during a user-mode page fault handling routine.
    
    Suggested-by: Linus Torvalds <torvalds at linux-foundation.org>
    Suggested-by: Andrea Arcangeli <aarcange at redhat.com>
    Signed-off-by: Peter Xu <peterx at redhat.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Tested-by: Brian Geffon <bgeffon at google.com>
    Cc: Bobby Powers <bobbypowers at gmail.com>
    Cc: David Hildenbrand <david at redhat.com>
    Cc: Denis Plotnikov <dplotnikov at virtuozzo.com>
    Cc: "Dr . David Alan Gilbert" <dgilbert at redhat.com>
    Cc: Hugh Dickins <hughd at google.com>
    Cc: Jerome Glisse <jglisse at redhat.com>
    Cc: Johannes Weiner <hannes at cmpxchg.org>
    Cc: "Kirill A . Shutemov" <kirill at shutemov.name>
    Cc: Martin Cracauer <cracauer at cons.org>
    Cc: Marty McFadden <mcfadden8 at llnl.gov>
    Cc: Matthew Wilcox <willy at infradead.org>
    Cc: Maya Gokhale <gokhale2 at llnl.gov>
    Cc: Mel Gorman <mgorman at suse.de>
    Cc: Mike Kravetz <mike.kravetz at oracle.com>
    Cc: Mike Rapoport <rppt at linux.vnet.ibm.com>
    Cc: Pavel Emelyanov <xemul at openvz.org>
    Link: http://lkml.kernel.org/r/20200220160230.9598-1-peterx@redhat.com
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    
    https://jira.sw.ru/browse/PSBM-102938
    (cherry picked from commit 8b9a65fd282c1d2e5b8ba8d8afaf652cde27b5e7)
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 include/linux/sched/signal.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index e00c838ef52a..8bf8bd259a61 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -382,7 +382,8 @@ static inline bool fault_signal_pending(vm_fault_t fault_flags,
 					struct pt_regs *regs)
 {
 	return unlikely((fault_flags & VM_FAULT_RETRY) &&
-			fatal_signal_pending(current));
+			(fatal_signal_pending(current) ||
+			 (user_mode(regs) && signal_pending(current))));
 }
 
 /*


More information about the Devel mailing list