From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: mingo@elte.hu, paulus@samba.org, rostedt@goodmis.org
Cc: linux-kernel@vger.kernel.org, Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 07/10] perf_counter: hook up the tracepoint events
Date: Thu, 19 Mar 2009 20:26:17 +0100 [thread overview]
Message-ID: <20090319194233.744044174@chello.nl> (raw)
In-Reply-To: 20090319192610.660857280@chello.nl
[-- Attachment #1: perf_swcounter_event.patch --]
[-- Type: text/plain, Size: 3057 bytes --]
Enable usage of tracepoints as perf counter events.
tracepoint event ids can be found in /debug/tracing/event/*/*/id
and (for now) are represented as -65536+id in the type field.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
include/linux/perf_counter.h | 3 +++
init/Kconfig | 5 +++++
kernel/perf_counter.c | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
Index: linux-2.6/include/linux/perf_counter.h
===================================================================
--- linux-2.6.orig/include/linux/perf_counter.h
+++ linux-2.6/include/linux/perf_counter.h
@@ -53,6 +53,8 @@ enum hw_event_types {
PERF_COUNT_PAGE_FAULTS_MAJ = -7,
PERF_SW_EVENTS_MIN = -8,
+
+ PERF_TP_EVENTS_MIN = -65536
};
/*
@@ -222,6 +224,7 @@ struct perf_counter {
struct perf_data *usrdata;
struct perf_data data[2];
+ void (*destroy)(struct perf_counter *);
struct rcu_head rcu_head;
#endif
};
Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1152,6 +1152,9 @@ static void free_counter_rcu(struct rcu_
static void free_counter(struct perf_counter *counter)
{
+ if (counter->destroy)
+ counter->destroy(counter);
+
call_rcu(&counter->rcu_head, free_counter_rcu);
}
@@ -1727,6 +1730,45 @@ static const struct hw_perf_counter_ops
.read = cpu_migrations_perf_counter_read,
};
+#ifdef CONFIG_EVENT_PROFILE
+void perf_tpcounter_event(int event_id)
+{
+ perf_swcounter_event(PERF_TP_EVENTS_MIN + event_id, 1, 1,
+ task_pt_regs(current));
+}
+
+extern int ftrace_profile_enable(int);
+extern void ftrace_profile_disable(int);
+
+static void tp_perf_counter_destroy(struct perf_counter *counter)
+{
+ int event_id = counter->hw_event.type - PERF_TP_EVENTS_MIN;
+
+ ftrace_profile_disable(event_id);
+}
+
+static const struct hw_perf_counter_ops *
+tp_perf_counter_init(struct perf_counter *counter)
+{
+ int event_id = counter->hw_event.type - PERF_TP_EVENTS_MIN;
+ int ret;
+
+ ret = ftrace_profile_enable(event_id);
+ if (ret)
+ return NULL;
+
+ counter->destroy = tp_perf_counter_destroy;
+
+ return &perf_ops_generic;
+}
+#else
+static const struct hw_perf_counter_ops *
+tp_perf_counter_init(struct perf_counter *counter)
+{
+ return NULL;
+}
+#endif
+
static const struct hw_perf_counter_ops *
sw_perf_counter_init(struct perf_counter *counter)
{
@@ -1772,6 +1814,7 @@ sw_perf_counter_init(struct perf_counter
hw_ops = &perf_ops_cpu_migrations;
break;
default:
+ hw_ops = tp_perf_counter_init(counter);
break;
}
Index: linux-2.6/init/Kconfig
===================================================================
--- linux-2.6.orig/init/Kconfig
+++ linux-2.6/init/Kconfig
@@ -945,6 +945,11 @@ config PERF_COUNTERS
Say Y if unsure.
+config EVENT_PROFILE
+ bool "Tracepoint profile sources"
+ depends on PERF_COUNTERS && EVENT_TRACER
+ default y
+
endmenu
config VM_EVENT_COUNTERS
--
next prev parent reply other threads:[~2009-03-19 19:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-19 19:26 [PATCH 00/10] tracepoint perf counter events and new ABI Peter Zijlstra
2009-03-19 19:26 ` [PATCH 01/10] perf_counter: fix uninitialized usage of event_list Peter Zijlstra
2009-03-20 10:24 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-19 19:26 ` [PATCH 02/10] perf_counter: generic context switch event Peter Zijlstra
2009-03-20 10:24 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-19 19:26 ` [PATCH 03/10] ftrace: provide an id file for each event Peter Zijlstra
2009-03-20 10:19 ` [tip:tracing/ftrace] " Peter Zijlstra
2009-03-19 19:26 ` [PATCH 04/10] ftrace: ensure every event gets an id Peter Zijlstra
2009-03-20 10:19 ` [tip:tracing/ftrace] " Peter Zijlstra
2009-03-19 19:26 ` [PATCH 05/10] ftrace: event profile hooks Peter Zijlstra
2009-03-20 10:19 ` [tip:tracing/ftrace] " Peter Zijlstra
2009-03-19 19:26 ` [PATCH 06/10] perf_counter: fix up counter free paths Peter Zijlstra
2009-03-20 10:25 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-19 19:26 ` Peter Zijlstra [this message]
2009-03-20 10:25 ` [tip:perfcounters/core] perf_counter: hook up the tracepoint events Peter Zijlstra
2009-03-22 8:57 ` Ingo Molnar
2009-07-29 1:01 ` Jeff Garzik
2009-07-29 8:35 ` Peter Zijlstra
2009-07-29 8:59 ` Jeff Garzik
2009-07-29 9:12 ` Peter Zijlstra
2009-08-02 13:09 ` [tip:perfcounters/core] tracing, perf_counter: Add help text to CONFIG_EVENT_PROFILE tip-bot for Peter Zijlstra
2009-03-19 19:26 ` [PATCH 08/10] perf_counter: revamp syscall input ABI Peter Zijlstra
2009-03-20 10:25 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-19 19:26 ` [PATCH 09/10] perf_counter: unify irq output code Peter Zijlstra
2009-03-20 10:25 ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-19 19:26 ` [PATCH 10/10] perf_counter: powerpc: clean up perc_counter_interrupt Peter Zijlstra
2009-03-19 22:17 ` Paul Mackerras
2009-03-20 8:54 ` Ingo Molnar
2009-03-20 10:25 ` [tip:perfcounters/core] " Paul Mackerras
2009-03-20 9:27 ` [PATCH 00/10] tracepoint perf counter events and new ABI Ingo Molnar
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=20090319194233.744044174@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--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