From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Paul Mackerras <paulus@samba.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] perf_event: support getting relocation offset
Date: Wed, 30 Dec 2009 11:17:51 +0800 [thread overview]
Message-ID: <4B3AC65F.8090005@cn.fujitsu.com> (raw)
In-Reply-To: <4B3AC5CD.1000502@cn.fujitsu.com>
Support getting relocation offset by using 'inject' event
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
arch/x86/kernel/cpu/perf_event.c | 6 ++++++
include/linux/perf_event.h | 1 +
kernel/perf_event.c | 23 +++++++++++++++++++++--
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 11d2a7d..fbb39f6 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -2470,3 +2470,9 @@ void hw_perf_event_setup_online(int cpu)
{
init_debug_store_on_cpu(cpu);
}
+
+int perf_inject_get_relocate_offset(u64 *offset)
+{
+ *offset = relocate_offset;
+ return 0;
+}
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 6c93f88..2671234 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -428,6 +428,7 @@ enum perf_event_type {
enum perf_inject_event {
PERF_INJECT_HZ = 0x01,
+ PERF_INJECT_RELOCATE_OFFSET = 0x02,
};
enum perf_callchain_context {
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 9343c6c..9331426 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -2012,6 +2012,12 @@ unlock:
return ret;
}
+extern __weak int perf_inject_get_relocate_offset(u64 *offset)
+{
+ *offset = 0;
+ return 0;
+}
+
static int perf_inject_get_hz(u64 *hz)
{
*hz = HZ;
@@ -2050,10 +2056,23 @@ exit:
static int perf_inject_ioctl(struct perf_event *event, unsigned int arg)
{
- if (!arg || arg & ~PERF_INJECT_HZ)
+ int ret = 0;
+
+ if (!arg || arg & ~(PERF_INJECT_HZ | PERF_INJECT_RELOCATE_OFFSET))
return -EINVAL;
- return perf_inject_event(event, PERF_INJECT_HZ, perf_inject_get_hz);
+ if (arg & PERF_INJECT_HZ) {
+ ret = perf_inject_event(event, PERF_INJECT_HZ,
+ perf_inject_get_hz);
+ if (ret)
+ goto exit;
+ }
+
+ if (arg & PERF_INJECT_RELOCATE_OFFSET)
+ ret = perf_inject_event(event, PERF_INJECT_RELOCATE_OFFSET,
+ perf_inject_get_relocate_offset);
+exit:
+ return ret;
}
static int perf_event_set_output(struct perf_event *event, int output_fd);
--
1.6.1.2
next prev parent reply other threads:[~2009-12-30 3:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-30 3:15 [PATCH 0/3] perf_event: fix getting symbol error if kernel is relocatable Xiao Guangrong
2009-12-30 3:16 ` [PATCH 1/3] x86: record relocation offset Xiao Guangrong
2009-12-30 13:15 ` Arnaldo Carvalho de Melo
2009-12-30 19:45 ` H. Peter Anvin
2009-12-30 20:39 ` Arnaldo Carvalho de Melo
2009-12-30 21:58 ` Arnaldo Carvalho de Melo
2009-12-30 22:22 ` James Bottomley
2009-12-30 3:17 ` Xiao Guangrong [this message]
2009-12-30 3:18 ` [PATCH 3/3] perf tools: adjust symbol address Xiao Guangrong
2009-12-30 13:10 ` Arnaldo Carvalho de Melo
2009-12-31 2:59 ` Xiao Guangrong
2009-12-31 10:29 ` Arnaldo Carvalho de Melo
2009-12-31 10:49 ` Xiao Guangrong
2009-12-31 11:08 ` Arnaldo Carvalho de Melo
2009-12-31 11:30 ` Xiao Guangrong
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=4B3AC65F.8090005@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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 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.