Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

softirq/preempt: Add missing current->preempt_disable_ip update

While debugging some "sleeping function called from invalid context" bug I
realized that the debugging message "Preemption disabled at:" pointed to
an incorrect function.

In particular if the last function/action that disabled preemption was
spin_lock_bh() then current->preempt_disable_ip won't be updated.

The reason for this is that __local_bh_disable_ip() will increase
preempt_count manually instead of calling preempt_count_add(), which
would handle the update correctly.

It look like the manual handling was done to work around some lockdep issue.

So add the missing update of current->preempt_disable_ip to
__local_bh_disable_ip() as well.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20150107090441.GC4365@osiris
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Heiko Carstens and committed by
Ingo Molnar
0f1ba9a2 036cc30c

+5 -1
+5 -1
kernel/softirq.c
··· 114 114 trace_softirqs_off(ip); 115 115 raw_local_irq_restore(flags); 116 116 117 - if (preempt_count() == cnt) 117 + if (preempt_count() == cnt) { 118 + #ifdef CONFIG_DEBUG_PREEMPT 119 + current->preempt_disable_ip = get_parent_ip(CALLER_ADDR1); 120 + #endif 118 121 trace_preempt_off(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1)); 122 + } 119 123 } 120 124 EXPORT_SYMBOL(__local_bh_disable_ip); 121 125 #endif /* CONFIG_TRACE_IRQFLAGS */