diff options
Diffstat (limited to 'arch/x86/mm/fault.c')
-rw-r--r-- | arch/x86/mm/fault.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 852b319edbdc..9b2345c9e0c3 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -956,8 +956,10 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
956 | struct task_struct *tsk; | 956 | struct task_struct *tsk; |
957 | unsigned long address; | 957 | unsigned long address; |
958 | struct mm_struct *mm; | 958 | struct mm_struct *mm; |
959 | int write; | ||
960 | int fault; | 959 | int fault; |
960 | int write = error_code & PF_WRITE; | ||
961 | unsigned int flags = FAULT_FLAG_ALLOW_RETRY | | ||
962 | (write ? FAULT_FLAG_WRITE : 0); | ||
961 | 963 | ||
962 | tsk = current; | 964 | tsk = current; |
963 | mm = tsk->mm; | 965 | mm = tsk->mm; |
@@ -1068,6 +1070,7 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
1068 | bad_area_nosemaphore(regs, error_code, address); | 1070 | bad_area_nosemaphore(regs, error_code, address); |
1069 | return; | 1071 | return; |
1070 | } | 1072 | } |
1073 | retry: | ||
1071 | down_read(&mm->mmap_sem); | 1074 | down_read(&mm->mmap_sem); |
1072 | } else { | 1075 | } else { |
1073 | /* | 1076 | /* |
@@ -1111,8 +1114,6 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
1111 | * we can handle it.. | 1114 | * we can handle it.. |
1112 | */ | 1115 | */ |
1113 | good_area: | 1116 | good_area: |
1114 | write = error_code & PF_WRITE; | ||
1115 | |||
1116 | if (unlikely(access_error(error_code, write, vma))) { | 1117 | if (unlikely(access_error(error_code, write, vma))) { |
1117 | bad_area_access_error(regs, error_code, address); | 1118 | bad_area_access_error(regs, error_code, address); |
1118 | return; | 1119 | return; |
@@ -1123,21 +1124,34 @@ good_area: | |||
1123 | * make sure we exit gracefully rather than endlessly redo | 1124 | * make sure we exit gracefully rather than endlessly redo |
1124 | * the fault: | 1125 | * the fault: |
1125 | */ | 1126 | */ |
1126 | fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); | 1127 | fault = handle_mm_fault(mm, vma, address, flags); |
1127 | 1128 | ||
1128 | if (unlikely(fault & VM_FAULT_ERROR)) { | 1129 | if (unlikely(fault & VM_FAULT_ERROR)) { |
1129 | mm_fault_error(regs, error_code, address, fault); | 1130 | mm_fault_error(regs, error_code, address, fault); |
1130 | return; | 1131 | return; |
1131 | } | 1132 | } |
1132 | 1133 | ||
1133 | if (fault & VM_FAULT_MAJOR) { | 1134 | /* |
1134 | tsk->maj_flt++; | 1135 | * Major/minor page fault accounting is only done on the |
1135 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0, | 1136 | * initial attempt. If we go through a retry, it is extremely |
1136 | regs, address); | 1137 | * likely that the page will be found in page cache at that point. |
1137 | } else { | 1138 | */ |
1138 | tsk->min_flt++; | 1139 | if (flags & FAULT_FLAG_ALLOW_RETRY) { |
1139 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0, | 1140 | if (fault & VM_FAULT_MAJOR) { |
1140 | regs, address); | 1141 | tsk->maj_flt++; |
1142 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0, | ||
1143 | regs, address); | ||
1144 | } else { | ||
1145 | tsk->min_flt++; | ||
1146 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0, | ||
1147 | regs, address); | ||
1148 | } | ||
1149 | if (fault & VM_FAULT_RETRY) { | ||
1150 | /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk | ||
1151 | * of starvation. */ | ||
1152 | flags &= ~FAULT_FLAG_ALLOW_RETRY; | ||
1153 | goto retry; | ||
1154 | } | ||
1141 | } | 1155 | } |
1142 | 1156 | ||
1143 | check_v8086_mode(regs, address, tsk); | 1157 | check_v8086_mode(regs, address, tsk); |