aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/mm/fault.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index d7de5b8657d5..b74a7e130b03 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1055,7 +1055,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
1055 struct vm_area_struct *vma; 1055 struct vm_area_struct *vma;
1056 struct task_struct *tsk; 1056 struct task_struct *tsk;
1057 struct mm_struct *mm; 1057 struct mm_struct *mm;
1058 int fault; 1058 int fault, major = 0;
1059 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; 1059 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
1060 1060
1061 tsk = current; 1061 tsk = current;
@@ -1230,48 +1230,50 @@ good_area:
1230 * we get VM_FAULT_RETRY back, the mmap_sem has been unlocked. 1230 * we get VM_FAULT_RETRY back, the mmap_sem has been unlocked.
1231 */ 1231 */
1232 fault = handle_mm_fault(mm, vma, address, flags); 1232 fault = handle_mm_fault(mm, vma, address, flags);
1233 major |= fault & VM_FAULT_MAJOR;
1233 1234
1234 /* 1235 /*
1235 * If we need to retry but a fatal signal is pending, handle the 1236 * If we need to retry the mmap_sem has already been released,
1236 * signal first. We do not need to release the mmap_sem because it 1237 * and if there is a fatal signal pending there is no guarantee
1237 * would already be released in __lock_page_or_retry in mm/filemap.c. 1238 * that we made any progress. Handle this case first.
1238 */ 1239 */
1239 if (unlikely((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))) 1240 if (unlikely(fault & VM_FAULT_RETRY)) {
1241 /* Retry at most once */
1242 if (flags & FAULT_FLAG_ALLOW_RETRY) {
1243 flags &= ~FAULT_FLAG_ALLOW_RETRY;
1244 flags |= FAULT_FLAG_TRIED;
1245 if (!fatal_signal_pending(tsk))
1246 goto retry;
1247 }
1248
1249 /* User mode? Just return to handle the fatal exception */
1250 if (fault & FAULT_FLAG_USER)
1251 return;
1252
1253 /* Not returning to user mode? Handle exceptions or die: */
1254 no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
1240 return; 1255 return;
1256 }
1241 1257
1258 up_read(&mm->mmap_sem);
1242 if (unlikely(fault & VM_FAULT_ERROR)) { 1259 if (unlikely(fault & VM_FAULT_ERROR)) {
1243 up_read(&mm->mmap_sem);
1244 mm_fault_error(regs, error_code, address, fault); 1260 mm_fault_error(regs, error_code, address, fault);
1245 return; 1261 return;
1246 } 1262 }
1247 1263
1248 /* 1264 /*
1249 * Major/minor page fault accounting is only done on the 1265 * Major/minor page fault accounting. If any of the events
1250 * initial attempt. If we go through a retry, it is extremely 1266 * returned VM_FAULT_MAJOR, we account it as a major fault.
1251 * likely that the page will be found in page cache at that point.
1252 */ 1267 */
1253 if (flags & FAULT_FLAG_ALLOW_RETRY) { 1268 if (major) {
1254 if (fault & VM_FAULT_MAJOR) { 1269 tsk->maj_flt++;
1255 tsk->maj_flt++; 1270 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
1256 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 1271 } else {
1257 regs, address); 1272 tsk->min_flt++;
1258 } else { 1273 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
1259 tsk->min_flt++;
1260 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
1261 regs, address);
1262 }
1263 if (fault & VM_FAULT_RETRY) {
1264 /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
1265 * of starvation. */
1266 flags &= ~FAULT_FLAG_ALLOW_RETRY;
1267 flags |= FAULT_FLAG_TRIED;
1268 goto retry;
1269 }
1270 } 1274 }
1271 1275
1272 check_v8086_mode(regs, address, tsk); 1276 check_v8086_mode(regs, address, tsk);
1273
1274 up_read(&mm->mmap_sem);
1275} 1277}
1276NOKPROBE_SYMBOL(__do_page_fault); 1278NOKPROBE_SYMBOL(__do_page_fault);
1277 1279