Skip to content

Commit 2558fd7

Browse files
xzpetertorvalds
authored andcommitted
mm/mips: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened. Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem. Signed-off-by: Peter Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Thomas Bogendoerfer <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent aeb6aef commit 2558fd7

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

arch/mips/mm/fault.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
9696

9797
if (user_mode(regs))
9898
flags |= FAULT_FLAG_USER;
99+
100+
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
99101
retry:
100102
mmap_read_lock(mm);
101103
vma = find_vma(mm, address);
@@ -152,12 +154,11 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
152154
* make sure we exit gracefully rather than endlessly redo
153155
* the fault.
154156
*/
155-
fault = handle_mm_fault(vma, address, flags, NULL);
157+
fault = handle_mm_fault(vma, address, flags, regs);
156158

157159
if (fault_signal_pending(fault, regs))
158160
return;
159161

160-
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
161162
if (unlikely(fault & VM_FAULT_ERROR)) {
162163
if (fault & VM_FAULT_OOM)
163164
goto out_of_memory;
@@ -168,15 +169,6 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
168169
BUG();
169170
}
170171
if (flags & FAULT_FLAG_ALLOW_RETRY) {
171-
if (fault & VM_FAULT_MAJOR) {
172-
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
173-
regs, address);
174-
tsk->maj_flt++;
175-
} else {
176-
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
177-
regs, address);
178-
tsk->min_flt++;
179-
}
180172
if (fault & VM_FAULT_RETRY) {
181173
flags |= FAULT_FLAG_TRIED;
182174

0 commit comments

Comments
 (0)