Use the general page fault accounting by passing regs into handle_mm_fault(). Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
Unified · Split
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <linux/interrupt.h> |
| 26 | 26 | #include <linux/extable.h> |
| 27 | 27 | #include <linux/uaccess.h> |
| 28 | +#include <linux/perf_event.h> | |
| 28 | 29 | |
| 29 | 30 | extern void die_if_kernel(char *,struct pt_regs *,long, unsigned long *); |
| 30 | 31 | |
| @@ -116,6 +117,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr, · 85 unmodified lines | ||
| 116 | 117 | #endif |
| 117 | 118 | if (user_mode(regs)) |
| 118 | 119 | flags |= FAULT_FLAG_USER; |
| 120 | + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); | |
| 119 | 121 | retry: |
| 120 | 122 | mmap_read_lock(mm); |
| 121 | 123 | vma = find_vma(mm, address); |
| @@ -148,7 +150,7 @@ retry: · 26 unmodified lines | ||
| 148 | 150 | /* If for any reason at all we couldn't handle the fault, |
| 149 | 151 | make sure we exit gracefully rather than endlessly redo |
| 150 | 152 | the fault. */ |
| 151 | − fault = handle_mm_fault(vma, address, flags, NULL); | |
| 153 | + fault = handle_mm_fault(vma, address, flags, regs); | |
| 152 | 154 | |
| 153 | 155 | if (fault_signal_pending(fault, regs)) |
| 154 | 156 | return; |
| @@ -164,10 +166,6 @@ retry: · 9 unmodified lines | ||
| 164 | 166 | } |
| 165 | 167 | |
| 166 | 168 | if (flags & FAULT_FLAG_ALLOW_RETRY) { |
| 167 | − if (fault & VM_FAULT_MAJOR) | |
| 168 | − current->maj_flt++; | |
| 169 | − else | |
| 170 | − current->min_flt++; | |
| 171 | 169 | if (fault & VM_FAULT_RETRY) { |
| 172 | 170 | flags |= FAULT_FLAG_TRIED; |
| 173 | 171 | |