2010-02-14 09:09:24

by Ingo Molnar

[permalink] [raw]
Subject: [GIT PULL] tracing fixes

Linus,

Please pull the latest tracing-fixes-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git tracing-fixes-for-linus

Thanks,

Ingo

------------------>
Heiko Carstens (1):
tracing/kprobes: Fix probe parsing

Lai Jiangshan (1):
tracing: Fix circular dead lock in stack trace


kernel/trace/trace_kprobe.c | 2 +-
kernel/trace/trace_stack.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 6ea90c0..50b1b82 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -689,7 +689,7 @@ static int create_trace_probe(int argc, char **argv)
return -EINVAL;
}
/* an address specified */
- ret = strict_strtoul(&argv[0][2], 0, (unsigned long *)&addr);
+ ret = strict_strtoul(&argv[1][0], 0, (unsigned long *)&addr);
if (ret) {
pr_info("Failed to parse address.\n");
return ret;
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 678a512..f4bc9b2 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -157,6 +157,7 @@ stack_max_size_write(struct file *filp, const char __user *ubuf,
unsigned long val, flags;
char buf[64];
int ret;
+ int cpu;

if (count >= sizeof(buf))
return -EINVAL;
@@ -171,9 +172,20 @@ stack_max_size_write(struct file *filp, const char __user *ubuf,
return ret;

local_irq_save(flags);
+
+ /*
+ * In case we trace inside arch_spin_lock() or after (NMI),
+ * we will cause circular lock, so we also need to increase
+ * the percpu trace_active here.
+ */
+ cpu = smp_processor_id();
+ per_cpu(trace_active, cpu)++;
+
arch_spin_lock(&max_stack_lock);
*ptr = val;
arch_spin_unlock(&max_stack_lock);
+
+ per_cpu(trace_active, cpu)--;
local_irq_restore(flags);

return count;
@@ -206,7 +218,13 @@ t_next(struct seq_file *m, void *v, loff_t *pos)

static void *t_start(struct seq_file *m, loff_t *pos)
{
+ int cpu;
+
local_irq_disable();
+
+ cpu = smp_processor_id();
+ per_cpu(trace_active, cpu)++;
+
arch_spin_lock(&max_stack_lock);

if (*pos == 0)
@@ -217,7 +235,13 @@ static void *t_start(struct seq_file *m, loff_t *pos)

static void t_stop(struct seq_file *m, void *p)
{
+ int cpu;
+
arch_spin_unlock(&max_stack_lock);
+
+ cpu = smp_processor_id();
+ per_cpu(trace_active, cpu)--;
+
local_irq_enable();
}


2010-02-15 01:40:48

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [GIT PULL] tracing fixes

Hi Ingo,

Could you push this commit too?

5ecaafdbf44b1ba400b746c60c401d54c7ee0863
kprobes: Add mcount to the kprobes blacklist

Since this bug can be easily reproduced with kprobe-tracer.

Thank you,

Ingo Molnar wrote:
> Linus,
>
> Please pull the latest tracing-fixes-for-linus git tree from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git tracing-fixes-for-linus
>
> Thanks,
>
> Ingo
>
> ------------------>
> Heiko Carstens (1):
> tracing/kprobes: Fix probe parsing
>
> Lai Jiangshan (1):
> tracing: Fix circular dead lock in stack trace
>

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-02-15 04:50:47

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL] tracing fixes


* Masami Hiramatsu <[email protected]> wrote:

> Hi Ingo,
>
> Could you push this commit too?
>
> 5ecaafdbf44b1ba400b746c60c401d54c7ee0863
> kprobes: Add mcount to the kprobes blacklist
>
> Since this bug can be easily reproduced with kprobe-tracer.

Ok, i've cherry-picked it into urgent.

I'm wondering, how complete is the kprobes blacklist? You can test it by
putting a probe on every single function in the system via something like:

for N in $(cut -d' ' -f3 /proc/kallsyms | cut -f1); do
perf probe $N
perf probe -d $N
done

(note: I havent tested it myself yet.)

Thanks,

Ingo

2010-02-15 16:57:58

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [GIT PULL] tracing fixes

Ingo Molnar wrote:
>
> * Masami Hiramatsu <[email protected]> wrote:
>
>> Hi Ingo,
>>
>> Could you push this commit too?
>>
>> 5ecaafdbf44b1ba400b746c60c401d54c7ee0863
>> kprobes: Add mcount to the kprobes blacklist
>>
>> Since this bug can be easily reproduced with kprobe-tracer.
>
> Ok, i've cherry-picked it into urgent.
>
> I'm wondering, how complete is the kprobes blacklist? You can test it by
> putting a probe on every single function in the system via something like:
>
> for N in $(cut -d' ' -f3 /proc/kallsyms | cut -f1); do
> perf probe $N
> perf probe -d $N
> done

Yeah, something like that, and I used kprobe stress test tool which
I attached for that :)

From http://lkml.org/lkml/2009/8/13/497
---
Usage
-----
kprobestest [-s SYMLIST] [-b BLACKLIST] [-w WHITELIST]
Run stress test. If SYMLIST file is specified, use it as
an initial symbol list (This is useful for verifying white list
after diagnosing all symbols).
kprobestest cleanup
Cleanup all lists


How to Work
-----------
This tool list up all symbols in the kernel via /proc/kallsyms, and sorts
it into groups (each of them including 64 symbols in default). And then,
it tests each group by using kprobe-tracer. If a kernel crash occurred,
that group is moved into 'failed' dir. If the group passed the test, this
script moves it into 'passed' dir and saves kprobe_profile into
'passed/profiles/'.
After testing all groups, all 'failed' groups are merged and sorted into
smaller groups (divided by 4, in default). And those are tested again.
This loop will be repeated until all group has just 1 symbol.
Finally, the script sorts all 'passed' symbols into 'tested', 'untested',
and 'missed' based on profiles.


Note
----
- This script just gives us some clues to the blacklisted functions.
In some cases, a combination of probe points will cause a problem, but
each of them doesn't cause the problem alone.
---

Thank you,

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]


Attachments:
kprobestest (4.84 kB)