Skip to content

Commit 4487dcf

Browse files
xzpetertorvalds
authored andcommitted
mm/nios2: 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. 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(). Signed-off-by: Peter Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Ley Foon Tan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent daf7bf5 commit 4487dcf

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

arch/nios2/mm/fault.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/mm.h>
2525
#include <linux/extable.h>
2626
#include <linux/uaccess.h>
27+
#include <linux/perf_event.h>
2728

2829
#include <asm/mmu_context.h>
2930
#include <asm/traps.h>
@@ -83,6 +84,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
8384
if (user_mode(regs))
8485
flags |= FAULT_FLAG_USER;
8586

87+
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
88+
8689
if (!mmap_read_trylock(mm)) {
8790
if (!user_mode(regs) && !search_exception_tables(regs->ea))
8891
goto bad_area_nosemaphore;
@@ -131,7 +134,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
131134
* make sure we exit gracefully rather than endlessly redo
132135
* the fault.
133136
*/
134-
fault = handle_mm_fault(vma, address, flags, NULL);
137+
fault = handle_mm_fault(vma, address, flags, regs);
135138

136139
if (fault_signal_pending(fault, regs))
137140
return;
@@ -146,16 +149,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
146149
BUG();
147150
}
148151

149-
/*
150-
* Major/minor page fault accounting is only done on the
151-
* initial attempt. If we go through a retry, it is extremely
152-
* likely that the page will be found in page cache at that point.
153-
*/
154152
if (flags & FAULT_FLAG_ALLOW_RETRY) {
155-
if (fault & VM_FAULT_MAJOR)
156-
current->maj_flt++;
157-
else
158-
current->min_flt++;
159153
if (fault & VM_FAULT_RETRY) {
160154
flags |= FAULT_FLAG_TRIED;
161155

0 commit comments

Comments
 (0)