Commit 0eaf50de authored by Mao Han's avatar Mao Han Committed by Guo Ren

csky: add page fault perf event support

This patch add support for page fault count, major fault count
and minorfault count. Without this patch page faults are not
sampled for perf event.

Performance counter stats for '/usr/lib/perf-test/callchain_test':
	0      page-faults               #    0.000 K/sec
Signed-off-by: default avatarMao Han <han_mao@c-sky.com>
Signed-off-by: default avatarGuo Ren <ren_guo@c-sky.com>
parent 683fafeb
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/vt_kern.h> #include <linux/vt_kern.h>
#include <linux/extable.h> #include <linux/extable.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/perf_event.h>
#include <asm/hardirq.h> #include <asm/hardirq.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
...@@ -106,6 +107,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, ...@@ -106,6 +107,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
return; return;
} }
#endif #endif
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
/* /*
* If we're in an interrupt or have no user * If we're in an interrupt or have no user
* context, we must not take the fault.. * context, we must not take the fault..
...@@ -153,10 +156,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, ...@@ -153,10 +156,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
goto bad_area; goto bad_area;
BUG(); BUG();
} }
if (fault & VM_FAULT_MAJOR) if (fault & VM_FAULT_MAJOR) {
tsk->maj_flt++; tsk->maj_flt++;
else perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
address);
} else {
tsk->min_flt++; tsk->min_flt++;
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs,
address);
}
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment