Skip to content

Commit 7fb08ec

Browse files
committed
x86: mm: move mmap_sem unlock from mm_fault_error() to caller
This replaces four copies in various stages of mm_fault_error() handling with just a single one. It will also allow for more natural placement of the unlocking after some further cleanup. Signed-off-by: Linus Torvalds <[email protected]>
1 parent 67e2c38 commit 7fb08ec

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

arch/x86/mm/fault.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,8 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
844844
unsigned int fault)
845845
{
846846
struct task_struct *tsk = current;
847-
struct mm_struct *mm = tsk->mm;
848847
int code = BUS_ADRERR;
849848

850-
up_read(&mm->mmap_sem);
851-
852849
/* Kernel mode? Handle exceptions or die: */
853850
if (!(error_code & PF_USER)) {
854851
no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
@@ -879,22 +876,18 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
879876
unsigned long address, unsigned int fault)
880877
{
881878
if (fatal_signal_pending(current) && !(error_code & PF_USER)) {
882-
up_read(&current->mm->mmap_sem);
883879
no_context(regs, error_code, address, 0, 0);
884880
return;
885881
}
886882

887883
if (fault & VM_FAULT_OOM) {
888884
/* Kernel mode? Handle exceptions or die: */
889885
if (!(error_code & PF_USER)) {
890-
up_read(&current->mm->mmap_sem);
891886
no_context(regs, error_code, address,
892887
SIGSEGV, SEGV_MAPERR);
893888
return;
894889
}
895890

896-
up_read(&current->mm->mmap_sem);
897-
898891
/*
899892
* We ran out of memory, call the OOM killer, and return the
900893
* userspace (which will retry the fault, or kill us if we got
@@ -1247,6 +1240,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
12471240
return;
12481241

12491242
if (unlikely(fault & VM_FAULT_ERROR)) {
1243+
up_read(&mm->mmap_sem);
12501244
mm_fault_error(regs, error_code, address, fault);
12511245
return;
12521246
}

0 commit comments

Comments
 (0)