From: Jiri Olsa <jolsa@redhat.com>
To: rostedt@goodmis.org, fweisbec@gmail.com, mingo@redhat.com,
a.p.zijlstra@chello.nl
Cc: linux-kernel@vger.kernel.org
Subject: [RFC,PATCH 2/3] trace,perf: add support for registering ftrace/function tracepoint event via perf
Date: Thu, 21 Apr 2011 12:40:57 +0200 [thread overview]
Message-ID: <1303382458-11072-3-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1303382458-11072-1-git-send-email-jolsa@redhat.com>
Added support to enable ftrace/function tracepoint via perf interface.
wbr,
jirka
---
kernel/trace/ftrace.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 00fe267..49fbc8c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3228,10 +3228,41 @@ ftrace_function_call_trace(unsigned long ip, unsigned long parent_ip)
local_irq_restore(flags);
}
+static void
+ftrace_function_call_perf(unsigned long ip, unsigned long parent_ip)
+{
+ struct ftrace_entry *entry;
+ struct hlist_head *head;
+ unsigned long flags;
+ int rctx;
+
+ local_irq_save(flags);
+
+ BUILD_BUG_ON(sizeof(*entry) > PERF_MAX_TRACE_SIZE);
+
+ entry = (struct ftrace_entry *) perf_trace_buf_prepare(sizeof(*entry),
+ TRACE_FN, NULL, &rctx);
+ if (!entry)
+ return;
+
+ entry->ip = ip;
+ entry->parent_ip = parent_ip;
+
+ head = this_cpu_ptr(event_function.perf_events);
+ perf_trace_buf_submit(entry, sizeof(*entry), rctx, 0,
+ 1, NULL, head);
+
+ local_irq_restore(flags);
+}
+
static struct ftrace_ops ftrace_trace_ops __read_mostly = {
.func = ftrace_function_call_trace,
};
+static struct ftrace_ops ftrace_perf_ops __read_mostly = {
+ .func = ftrace_function_call_perf,
+};
+
int ftrace_event_class_register(struct ftrace_event_call *call,
enum trace_reg type)
{
@@ -3246,8 +3277,9 @@ int ftrace_event_class_register(struct ftrace_event_call *call,
case TRACE_REG_UNREGISTER:
return unregister_ftrace_function(&ftrace_trace_ops);
case TRACE_REG_PERF_REGISTER:
+ return register_ftrace_function(&ftrace_perf_ops);
case TRACE_REG_PERF_UNREGISTER:
- break;
+ return unregister_ftrace_function(&ftrace_perf_ops);
}
return -EINVAL;
--
1.7.1
next prev parent reply other threads:[~2011-04-21 10:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 10:40 [RFC,PATCH 0/3] trace,perf: enabling ftrace/function tracepoint Jiri Olsa
2011-04-21 10:40 ` [RFC,PATCH 1/3] trace: add support for enabling ftrace/function tracepoint event Jiri Olsa
2011-04-21 10:40 ` Jiri Olsa [this message]
2011-04-21 10:40 ` [RFC,PATCH 3/3] trace,perf: add filter support for " Jiri Olsa
2011-04-21 15:20 ` Frederic Weisbecker
2011-04-21 15:27 ` [RFC,PATCH 0/3] trace,perf: enabling ftrace/function tracepoint Frederic Weisbecker
2011-04-21 15:34 ` Steven Rostedt
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=1303382458-11072-3-git-send-email-jolsa@redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®