All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] csky: add page fault perf event support
@ 2019-04-18  6:20 Mao Han
  2019-04-19 11:18 ` Guo Ren
  0 siblings, 1 reply; 2+ messages in thread
From: Mao Han @ 2019-04-18  6:20 UTC (permalink / raw)
  To: guoren; +Cc: linux-kernel, Mao Han

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: Mao Han <han_mao@c-sky.com>
---
 arch/csky/mm/fault.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
index e1725f8..d07141d 100644
--- a/arch/csky/mm/fault.c
+++ b/arch/csky/mm/fault.c
@@ -17,6 +17,7 @@
 #include <linux/vt_kern.h>
 #include <linux/extable.h>
 #include <linux/uaccess.h>
+#include <linux/perf_event.h>
 
 #include <asm/hardirq.h>
 #include <asm/mmu_context.h>
@@ -106,6 +107,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
 		return;
 	}
 #endif
+
+	perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
 	/*
 	 * If we're in an interrupt or have no user
 	 * context, we must not take the fault..
@@ -153,10 +156,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
 			goto bad_area;
 		BUG();
 	}
-	if (fault & VM_FAULT_MAJOR)
+	if (fault & VM_FAULT_MAJOR) {
 		tsk->maj_flt++;
-	else
+		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
+			      address);
+	} else {
 		tsk->min_flt++;
+		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs,
+			      address);
+	}
 
 	up_read(&mm->mmap_sem);
 	return;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] csky: add page fault perf event support
  2019-04-18  6:20 [PATCH 1/1] csky: add page fault perf event support Mao Han
@ 2019-04-19 11:18 ` Guo Ren
  0 siblings, 0 replies; 2+ messages in thread
From: Guo Ren @ 2019-04-19 11:18 UTC (permalink / raw)
  To: Mao Han; +Cc: linux-kernel

Looks good, nice Job, Maomao

On Thu, Apr 18, 2019 at 02:20:40PM +0800, Mao Han wrote:
> 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: Mao Han <han_mao@c-sky.com>
> ---
>  arch/csky/mm/fault.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
> index e1725f8..d07141d 100644
> --- a/arch/csky/mm/fault.c
> +++ b/arch/csky/mm/fault.c
> @@ -17,6 +17,7 @@
>  #include <linux/vt_kern.h>
>  #include <linux/extable.h>
>  #include <linux/uaccess.h>
> +#include <linux/perf_event.h>
>  
>  #include <asm/hardirq.h>
>  #include <asm/mmu_context.h>
> @@ -106,6 +107,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>  		return;
>  	}
>  #endif
> +
> +	perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
>  	/*
>  	 * If we're in an interrupt or have no user
>  	 * context, we must not take the fault..
> @@ -153,10 +156,15 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>  			goto bad_area;
>  		BUG();
>  	}
> -	if (fault & VM_FAULT_MAJOR)
> +	if (fault & VM_FAULT_MAJOR) {
>  		tsk->maj_flt++;
> -	else
> +		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
> +			      address);
> +	} else {
>  		tsk->min_flt++;
> +		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs,
> +			      address);
> +	}
>  
>  	up_read(&mm->mmap_sem);
>  	return;
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-19 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18  6:20 [PATCH 1/1] csky: add page fault perf event support Mao Han
2019-04-19 11:18 ` Guo Ren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.