Re: [trace] kernel BUG at kernel/sched/core.c:2881!

From: Steven Rostedt
Date: Tue Jul 07 2015 - 15:03:46 EST


On Tue, 7 Jul 2015 11:06:27 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> On Tue, 30 Jun 2015 22:18:03 +0800
> Fengguang Wu <fengguang.wu@xxxxxxxxx> wrote:
>
> > Hi Rostedt,
> >
> > FYI, this merge changes kernel crash to some more obvious kernel BUG
> > message. If it's still not helpful, I can try bisect the old crash
> > or split up the merge and bisect into them.
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> >
>
> This has been a bug for some time. Does this fix it?
>

Test this patch instead, this is the one I'm testing and will be
pushing to Linus.

-- Steve

---
kernel/trace/trace.h | 1 +
kernel/trace/trace_branch.c | 13 ++++++++-----
2 files changed, 9 insertions(+), 5 deletions(-)

Index: linux-trace.git/kernel/trace/trace.h
===================================================================
--- linux-trace.git.orig/kernel/trace/trace.h 2015-07-07 14:28:27.391715136 -0400
+++ linux-trace.git/kernel/trace/trace.h 2015-07-07 14:29:08.133213493 -0400
@@ -444,6 +444,7 @@ enum {

TRACE_CONTROL_BIT,

+ TRACE_BRANCH_BIT,
/*
* Abuse of the trace_recursion.
* As we need a way to maintain state if we are tracing the function
Index: linux-trace.git/kernel/trace/trace_branch.c
===================================================================
--- linux-trace.git.orig/kernel/trace/trace_branch.c 2015-07-07 14:28:27.391715136 -0400
+++ linux-trace.git/kernel/trace/trace_branch.c 2015-07-07 14:56:52.036764240 -0400
@@ -36,9 +36,12 @@ probe_likely_condition(struct ftrace_bra
struct trace_branch *entry;
struct ring_buffer *buffer;
unsigned long flags;
- int cpu, pc;
+ int pc;
const char *p;

+ if (current->trace_recursion & TRACE_BRANCH_BIT)
+ return;
+
/*
* I would love to save just the ftrace_likely_data pointer, but
* this code can also be used by modules. Ugly things can happen
@@ -50,9 +53,9 @@ probe_likely_condition(struct ftrace_bra
return;

local_irq_save(flags);
- cpu = raw_smp_processor_id();
- data = per_cpu_ptr(tr->trace_buffer.data, cpu);
- if (atomic_inc_return(&data->disabled) != 1)
+ current->trace_recursion |= TRACE_BRANCH_BIT;
+ data = this_cpu_ptr(tr->trace_buffer.data);
+ if (atomic_read(&data->disabled))
goto out;

pc = preempt_count();
@@ -81,7 +84,7 @@ probe_likely_condition(struct ftrace_bra
__buffer_unlock_commit(buffer, event);

out:
- atomic_dec(&data->disabled);
+ current->trace_recursion &= ~TRACE_BRANCH_BIT;
local_irq_restore(flags);
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/