Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/mm: Move mmap_sem unlocking in do_page_fault()

Since the fault retry is now handled earlier, we can release the
mmap_sem lock earlier too and remove later unlocking previously done in
mm_fault_error().

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Laurent Dufour and committed by
Michael Ellerman
819cdcdb 14c02e41

+4 -15
+4 -15
arch/powerpc/mm/fault.c
··· 152 152 * continue the pagefault. 153 153 */ 154 154 if (fatal_signal_pending(current)) { 155 - /* 156 - * If we have retry set, the mmap semaphore will have 157 - * alrady been released in __lock_page_or_retry(). Else 158 - * we release it now. 159 - */ 160 - if (!(fault & VM_FAULT_RETRY)) 161 - up_read(&current->mm->mmap_sem); 162 155 /* Coming from kernel, we need to deal with uaccess fixups */ 163 156 if (user_mode(regs)) 164 157 return MM_FAULT_RETURN; ··· 164 171 165 172 /* Out of memory */ 166 173 if (fault & VM_FAULT_OOM) { 167 - up_read(&current->mm->mmap_sem); 168 - 169 174 /* 170 175 * We ran out of memory, or some other thing happened to us that 171 176 * made us unable to handle the page fault gracefully. ··· 174 183 return MM_FAULT_RETURN; 175 184 } 176 185 177 - if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { 178 - up_read(&current->mm->mmap_sem); 186 + if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) 179 187 return do_sigbus(regs, addr, fault); 180 - } 181 188 182 189 /* We don't understand the fault code, this is fatal */ 183 190 BUG(); ··· 465 476 goto retry; 466 477 } 467 478 /* We will enter mm_fault_error() below */ 468 - } 479 + } else 480 + up_read(&current->mm->mmap_sem); 469 481 470 482 if (unlikely(fault & (VM_FAULT_RETRY|VM_FAULT_ERROR))) { 471 483 if (fault & VM_FAULT_SIGSEGV) 472 - goto bad_area; 484 + goto bad_area_nosemaphore; 473 485 rc = mm_fault_error(regs, address, fault); 474 486 if (rc >= MM_FAULT_RETURN) 475 487 goto bail; ··· 502 512 regs, address); 503 513 } 504 514 505 - up_read(&mm->mmap_sem); 506 515 goto bail; 507 516 508 517 bad_area: