linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: credmonster@gmail.com (Chris Redmon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] arm: Utilize trace events for major and minor page faults
Date: Wed, 12 Apr 2017 22:20:39 -0400	[thread overview]
Message-ID: <20170413022040.10156-3-credmonster@gmail.com> (raw)
In-Reply-To: <20170413022040.10156-1-credmonster@gmail.com>

Signed-off-by: Chris Redmon <credmonster@gmail.com>
---
 arch/arm/mm/fault.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index ff8b0aa2dfde..e59514f85e01 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -29,6 +29,9 @@
 
 #include "fault.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/fault.h>
+
 #ifdef CONFIG_MMU
 
 #ifdef CONFIG_KPROBES
@@ -262,6 +265,8 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	struct mm_struct *mm;
 	int fault, sig, code;
 	unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
+	ktime_t start_time;
+	bool trace_fault_enabled = false;
 
 	if (notify_page_fault(regs, fsr))
 		return 0;
@@ -285,6 +290,11 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	if (fsr & FSR_WRITE)
 		flags |= FAULT_FLAG_WRITE;
 
+	if (trace_fault_major_enabled() || trace_fault_minor_enabled()) {
+		start_time = ktime_get();
+		trace_fault_enabled = true;
+	}
+
 	/*
 	 * As per x86, we may deadlock here.  However, since the kernel only
 	 * validly references user space from well defined areas of the code,
@@ -330,10 +340,14 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 			tsk->maj_flt++;
 			perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
 					regs, addr);
+			if (trace_fault_enabled)
+				trace_fault_major(addr, regs, fsr, start_time, flags, fault);
 		} else {
 			tsk->min_flt++;
 			perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
 					regs, addr);
+			if (trace_fault_enabled)
+				trace_fault_minor(addr, regs, fsr, start_time, flags, fault);
 		}
 		if (fault & VM_FAULT_RETRY) {
 			/* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
-- 
2.12.2.599.gcf11a67

  parent reply	other threads:[~2017-04-13  2:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13  2:20 [PATCH 0/3] Add fault_major, fault_minor page fault trace events Chris Redmon
2017-04-13  2:20 ` [PATCH 1/3] tracing: Introduce traces for major and minor page faults Chris Redmon
2017-04-13  2:20 ` Chris Redmon [this message]
2017-04-13  2:20 ` [PATCH 3/3] arm64: Utilize trace events " Chris Redmon
2017-04-25 16:49 ` [PATCH 0/3] Add fault_major, fault_minor page fault trace events Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170413022040.10156-3-credmonster@gmail.com \
    --to=credmonster@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).