diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 20:15:20 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 20:15:20 -0400 |
| commit | 31453a9764f7e2a72a6e2c502ace586e2663a68c (patch) | |
| tree | 5d4db63de5b4b85d1ffdab4e95a75175a784a10a /arch/x86/mm/fault.c | |
| parent | f9ba5375a8aae4aeea6be15df77e24707a429812 (diff) | |
| parent | 93ed0e2d07b25aff4db1d61bfbcd1e82074c0ad5 (diff) | |
Merge branch 'akpm-incoming-1'
* akpm-incoming-1: (176 commits)
scripts/checkpatch.pl: add check for declaration of pci_device_id
scripts/checkpatch.pl: add warnings for static char that could be static const char
checkpatch: version 0.31
checkpatch: statement/block context analyser should look at sanitised lines
checkpatch: handle EXPORT_SYMBOL for DEVICE_ATTR and similar
checkpatch: clean up structure definition macro handline
checkpatch: update copyright dates
checkpatch: Add additional attribute #defines
checkpatch: check for incorrect permissions
checkpatch: ensure kconfig help checks only apply when we are adding help
checkpatch: simplify and consolidate "missing space after" checks
checkpatch: add check for space after struct, union, and enum
checkpatch: returning errno typically should be negative
checkpatch: handle casts better fixing false categorisation of : as binary
checkpatch: ensure we do not collapse bracketed sections into constants
checkpatch: suggest cleanpatch and cleanfile when appropriate
checkpatch: types may sit on a line on their own
checkpatch: fix regressions in "fix handling of leading spaces"
div64_u64(): improve precision on 32bit platforms
lib/parser: cleanup match_number()
...
Diffstat (limited to 'arch/x86/mm/fault.c')
| -rw-r--r-- | arch/x86/mm/fault.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 852b319edbdc..7d90ceb882a4 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
| @@ -919,9 +919,9 @@ spurious_fault(unsigned long error_code, unsigned long address) | |||
| 919 | int show_unhandled_signals = 1; | 919 | int show_unhandled_signals = 1; |
| 920 | 920 | ||
| 921 | static inline int | 921 | static inline int |
| 922 | access_error(unsigned long error_code, int write, struct vm_area_struct *vma) | 922 | access_error(unsigned long error_code, struct vm_area_struct *vma) |
| 923 | { | 923 | { |
| 924 | if (write) { | 924 | if (error_code & PF_WRITE) { |
| 925 | /* write, present and write, not present: */ | 925 | /* write, present and write, not present: */ |
| 926 | if (unlikely(!(vma->vm_flags & VM_WRITE))) | 926 | if (unlikely(!(vma->vm_flags & VM_WRITE))) |
| 927 | return 1; | 927 | return 1; |
| @@ -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,9 +1114,7 @@ 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; | 1117 | if (unlikely(access_error(error_code, vma))) { |
| 1115 | |||
| 1116 | 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; |
| 1119 | } | 1120 | } |
| @@ -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); |
