Skip to content

Commit 8b9a65f

Browse files
xzpetertorvalds
authored andcommitted
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/[email protected]/ 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 <[email protected]> Suggested-by: Andrea Arcangeli <[email protected]> Signed-off-by: Peter Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Brian Geffon <[email protected]> Cc: Bobby Powers <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Denis Plotnikov <[email protected]> Cc: "Dr . David Alan Gilbert" <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Jerome Glisse <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: "Kirill A . Shutemov" <[email protected]> Cc: Martin Cracauer <[email protected]> Cc: Marty McFadden <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Maya Gokhale <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Pavel Emelyanov <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent fb027ad commit 8b9a65f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/linux/sched/signal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ static inline bool fault_signal_pending(vm_fault_t fault_flags,
381381
struct pt_regs *regs)
382382
{
383383
return unlikely((fault_flags & VM_FAULT_RETRY) &&
384-
fatal_signal_pending(current));
384+
(fatal_signal_pending(current) ||
385+
(user_mode(regs) && signal_pending(current))));
385386
}
386387

387388
/*

0 commit comments

Comments
 (0)