lkml.org 
[lkml]   [2013]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC PATCH 3/3] tracing: Teach FETCH_MTD_{symbol,deref} to handle per-cpu data
@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



\
 
 \ /
  Last update: 2013-11-25 18:41    [W:0.247 / U:0.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site