[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1469135662-31512-3-git-send-email-mathieu.desnoyers@efficios.com>
Date: Thu, 21 Jul 2016 17:14:17 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Russell King <linux@....linux.org.uk>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>
Cc: linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
Paul Turner <pjt@...gle.com>, Andrew Hunter <ahh@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...capital.net>,
Andi Kleen <andi@...stfloor.org>,
Dave Watson <davejwatson@...com>, Chris Lameter <cl@...ux.com>,
Ben Maurer <bmaurer@...com>,
Steven Rostedt <rostedt@...dmis.org>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Josh Triplett <josh@...htriplett.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Michael Kerrisk <mtk.manpages@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Subject: [RFC PATCH v7 2/7] tracing: instrument restartable sequences
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Paul Turner <pjt@...gle.com>
CC: Andrew Hunter <ahh@...gle.com>
CC: Peter Zijlstra <peterz@...radead.org>
CC: Andy Lutomirski <luto@...capital.net>
CC: Andi Kleen <andi@...stfloor.org>
CC: Dave Watson <davejwatson@...com>
CC: Chris Lameter <cl@...ux.com>
CC: Ingo Molnar <mingo@...hat.com>
CC: "H. Peter Anvin" <hpa@...or.com>
CC: Ben Maurer <bmaurer@...com>
CC: Steven Rostedt <rostedt@...dmis.org>
CC: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
CC: Josh Triplett <josh@...htriplett.org>
CC: Linus Torvalds <torvalds@...ux-foundation.org>
CC: Andrew Morton <akpm@...ux-foundation.org>
CC: Russell King <linux@....linux.org.uk>
CC: Catalin Marinas <catalin.marinas@....com>
CC: Will Deacon <will.deacon@....com>
CC: Michael Kerrisk <mtk.manpages@...il.com>
CC: Boqun Feng <boqun.feng@...il.com>
CC: linux-api@...r.kernel.org
---
include/trace/events/rseq.h | 60 +++++++++++++++++++++++++++++++++++++++++++++
kernel/rseq.c | 18 +++++++++++---
2 files changed, 75 insertions(+), 3 deletions(-)
create mode 100644 include/trace/events/rseq.h
diff --git a/include/trace/events/rseq.h b/include/trace/events/rseq.h
new file mode 100644
index 0000000..83fd31e
--- /dev/null
+++ b/include/trace/events/rseq.h
@@ -0,0 +1,60 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rseq
+
+#if !defined(_TRACE_RSEQ_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_RSEQ_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(rseq_inc,
+
+ TP_PROTO(uint32_t event_counter, int ret),
+
+ TP_ARGS(event_counter, ret),
+
+ TP_STRUCT__entry(
+ __field(uint32_t, event_counter)
+ __field(int, ret)
+ ),
+
+ TP_fast_assign(
+ __entry->event_counter = event_counter;
+ __entry->ret = ret;
+ ),
+
+ TP_printk("event_counter=%u ret=%d",
+ __entry->event_counter, __entry->ret)
+);
+
+TRACE_EVENT(rseq_ip_fixup,
+
+ TP_PROTO(void __user *regs_ip, void __user *post_commit_ip,
+ void __user *abort_ip, uint32_t kevcount, int ret),
+
+ TP_ARGS(regs_ip, post_commit_ip, abort_ip, kevcount, ret),
+
+ TP_STRUCT__entry(
+ __field(void __user *, regs_ip)
+ __field(void __user *, post_commit_ip)
+ __field(void __user *, abort_ip)
+ __field(uint32_t, kevcount)
+ __field(int, ret)
+ ),
+
+ TP_fast_assign(
+ __entry->regs_ip = regs_ip;
+ __entry->post_commit_ip = post_commit_ip;
+ __entry->abort_ip = abort_ip;
+ __entry->kevcount = kevcount;
+ __entry->ret = ret;
+ ),
+
+ TP_printk("regs_ip=%p post_commit_ip=%p abort_ip=%p kevcount=%u ret=%d",
+ __entry->regs_ip, __entry->post_commit_ip, __entry->abort_ip,
+ __entry->kevcount, __entry->ret)
+);
+
+#endif /* _TRACE_SOCK_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/kernel/rseq.c b/kernel/rseq.c
index e1c847b..cab326a 100644
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -29,6 +29,9 @@
#include <linux/rseq.h>
#include <asm/ptrace.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/rseq.h>
+
/*
* Each restartable sequence assembly block defines a "struct rseq_cs"
* structure which describes the post_commit_ip address, and the
@@ -90,8 +93,12 @@
static int rseq_increment_event_counter(struct task_struct *t)
{
- if (__put_user(++t->rseq_event_counter,
- &t->rseq->u.e.event_counter))
+ int ret;
+
+ ret = __put_user(++t->rseq_event_counter,
+ &t->rseq->u.e.event_counter);
+ trace_rseq_inc(t->rseq_event_counter, ret);
+ if (ret)
return -1;
return 0;
}
@@ -134,8 +141,13 @@ static int rseq_ip_fixup(struct pt_regs *regs)
struct task_struct *t = current;
void __user *post_commit_ip = NULL;
void __user *abort_ip = NULL;
+ int ret;
- if (rseq_get_rseq_cs(t, &post_commit_ip, &abort_ip))
+ ret = rseq_get_rseq_cs(t, &post_commit_ip, &abort_ip);
+ trace_rseq_ip_fixup((void __user *)instruction_pointer(regs),
+ post_commit_ip, abort_ip, t->rseq_event_counter,
+ ret);
+ if (ret)
return -1;
/* Handle potentially being within a critical section. */
--
2.1.4
Powered by blists - more mailing lists