From: Oleg Nesterov <oleg@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Namhyung Kim <namhyung.kim@lge.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/3] tracing: Teach FETCH_MTD_{symbol,deref} to handle per-cpu data
Date: Mon, 25 Nov 2013 18:22:06 +0100 [thread overview]
Message-ID: <20131125172206.GD14516@redhat.com> (raw)
In-Reply-To: <20131125172106.GA14516@redhat.com>
@symbol can't be used to dump the per-cpu variables. The same is
true for +offset(something) if "something" results in __percpu
pointer.
With this patch parse_probe_offset() treats "~" before the numeric
offset as "per cpu" mark and stores it in the lowest bit,
calc_probe_offset() simply adds per_cpu_offset(smp_processor_id())
if this bit is set.
We could turn {dprm,sc}->offset into the "struct probe_offset" which
holds offset + is_percpu, but this hack looks simple enough and I hope
that LONG_MAX/2 is enough for the numeric offset.
Test-case: 2088 == offsetof(struct rq, curr)
# perf probe 'do_exit curr=%%current rq_curr=@runqueues+~2088:u64'
# perf record -e probe:do_exit true
# perf --no-pager script | tail -1
true 537 [000] 521.282640: probe:do_exit: (ffffffff8103dd60) \
curr=ffff88001da8c900 rq_curr=ffff88001da8c900
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/trace/trace_probe.c | 35 ++++++++++++++++++++++++++++++++---
1 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 723e6e9..bcf6827 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -593,15 +593,44 @@ static int pseudo_reg_query_offset(const char *name)
static long calc_probe_offset(unsigned long offset)
{
- return offset;
+ long off = offset >> 1;
+
+ if (offset & 1)
+ off += per_cpu_offset(raw_smp_processor_id());
+
+ return off;
}
static int parse_probe_offset(const char *name, unsigned long *offset)
{
- if (name[0] == '+') /* kstrtol() rejects '+' */
+ bool negative = false;
+ long percpu_bit = 0;
+ long off = 0;
+
+ switch (name[0]) {
+ case '-':
+ negative = true;
+ case '+':
name++;
+ }
- return kstrtol(name, 0, offset);
+ if (name[0] == '~') {
+ percpu_bit = 1;
+ name++;
+ }
+
+ if (name[0]) {
+ int err = kstrtoul(name, 0, &off);
+
+ if (err || off >= LONG_MAX/2)
+ return -EINVAL;
+
+ if (negative)
+ off = -off;
+ }
+
+ *offset = (off << 1) | percpu_bit;
+ return 0;
}
/* Recursive argument parser */
--
1.5.5.1
next prev parent reply other threads:[~2013-11-25 17:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-23 20:15 [PATCH 0/1] tracing: Introduce "pseudo registers" for FETCH_MTD_reg Oleg Nesterov
2013-11-23 20:16 ` [PATCH 1/1] " Oleg Nesterov
2013-11-24 7:32 ` Masami Hiramatsu
2013-11-25 8:04 ` Namhyung Kim
2013-11-25 14:35 ` Oleg Nesterov
2013-11-25 17:21 ` [RFC PATCH 0/3] tracing: Teach FETCH_MTD_{symbol,deref} to handle per-cpu data Oleg Nesterov
2013-11-25 17:21 ` [RFC PATCH 1/3] tracing: Don't mangle sc->addr in update_symbol_cache() Oleg Nesterov
2013-11-25 17:21 ` [RFC PATCH 2/3] tracing: introduce {calc,parse}_probe_offset() for FETCH_MTD_{symbol,deref} Oleg Nesterov
2013-11-25 17:22 ` Oleg Nesterov [this message]
2013-11-26 9:34 ` [RFC PATCH 3/3] tracing: Teach FETCH_MTD_{symbol,deref} to handle per-cpu data Masami Hiramatsu
2013-11-26 17:43 ` [RFC PATCH 0/2] tracing: Teach FETCH_MTD_symbol " Oleg Nesterov
2013-11-26 17:44 ` [RFC PATCH 1/2] tracing: Don't update sc->addr in update_symbol_cache() Oleg Nesterov
2013-11-26 17:44 ` [RFC PATCH 2/2] tracing: Teach FETCH_MTD_symbol to handle per-cpu data Oleg Nesterov
2013-11-26 17:50 ` modules, add_kallsyms() && DEFINE_PER_CPU Oleg Nesterov
2013-11-27 2:23 ` Masami Hiramatsu
2013-11-27 8:20 ` Namhyung Kim
2013-11-27 11:22 ` Masami Hiramatsu
2013-11-27 13:35 ` Oleg Nesterov
2013-11-28 2:02 ` Masami Hiramatsu
2013-11-27 11:30 ` [RFC PATCH 2/2] tracing: Teach FETCH_MTD_symbol to handle per-cpu data Masami Hiramatsu
2013-11-27 0:37 ` [RFC PATCH 0/2] " Namhyung Kim
2013-11-27 10:01 ` Masami Hiramatsu
2013-11-27 17:41 ` Oleg Nesterov
2013-11-28 2:55 ` Masami Hiramatsu
2013-11-25 19:29 ` [PATCH 0/2] tracing: Add $cpu and $current probe-vars Oleg Nesterov
2013-11-25 19:29 ` [PATCH 1/2] " Oleg Nesterov
2013-11-26 2:21 ` Masami Hiramatsu
2013-11-26 17:23 ` Oleg Nesterov
2013-11-27 8:22 ` Masami Hiramatsu
2013-11-27 17:05 ` Oleg Nesterov
2013-11-28 2:51 ` Masami Hiramatsu
2013-11-25 19:30 ` [PATCH 2/2] tracing: Kill FETCH_MTD_retval, reimplement $retval via pseudo_reg_retval() Oleg Nesterov
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=20131125172206.GD14516@redhat.com \
--to=oleg@redhat.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=namhyung.kim@lge.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;
as well as URLs for NNTP newsgroup(s).