linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] softirq/preempt: add missing current->preempt_disable_ip update
@ 2014-11-24 14:16 Heiko Carstens
  2014-12-09  6:26 ` Heiko Carstens
  0 siblings, 1 reply; 2+ messages in thread
From: Heiko Carstens @ 2014-11-24 14:16 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Peter Zijlstra; +Cc: linux-kernel

While debugging some "sleeping function called from invalid context" bug I
realized that the debug message "Preemption disabled at:" pointed to an
incorrect function.
In particular if the 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>
---
 kernel/softirq.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 501baa9ac1be..edd51027e3ab 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -114,8 +114,13 @@ void __local_bh_disable_ip(unsigned long ip, unsigned int cnt)
 		trace_softirqs_off(ip);
 	raw_local_irq_restore(flags);
 
-	if (preempt_count() == cnt)
-		trace_preempt_off(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1));
+	if (preempt_count() == cnt) {
+		unsigned long ip = get_parent_ip(CALLER_ADDR1);
+#ifdef CONFIG_DEBUG_PREEMPT
+		current->preempt_disable_ip = ip;
+#endif
+		trace_preempt_off(CALLER_ADDR0, ip);
+	}
 }
 EXPORT_SYMBOL(__local_bh_disable_ip);
 #endif /* CONFIG_TRACE_IRQFLAGS */
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] softirq/preempt: add missing current->preempt_disable_ip update
  2014-11-24 14:16 [PATCH] softirq/preempt: add missing current->preempt_disable_ip update Heiko Carstens
@ 2014-12-09  6:26 ` Heiko Carstens
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Carstens @ 2014-12-09  6:26 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Peter Zijlstra, linux-kernel

On Mon, Nov 24, 2014 at 03:16:19PM +0100, Heiko Carstens wrote:
> While debugging some "sleeping function called from invalid context" bug I
> realized that the debug message "Preemption disabled at:" pointed to an
> incorrect function.
> In particular if the 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>
> ---
>  kernel/softirq.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/softirq.c b/kernel/softirq.c
> index 501baa9ac1be..edd51027e3ab 100644
> --- a/kernel/softirq.c
> +++ b/kernel/softirq.c
> @@ -114,8 +114,13 @@ void __local_bh_disable_ip(unsigned long ip, unsigned int cnt)
>  		trace_softirqs_off(ip);
>  	raw_local_irq_restore(flags);
>  
> -	if (preempt_count() == cnt)
> -		trace_preempt_off(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1));
> +	if (preempt_count() == cnt) {
> +		unsigned long ip = get_parent_ip(CALLER_ADDR1);
> +#ifdef CONFIG_DEBUG_PREEMPT
> +		current->preempt_disable_ip = ip;
> +#endif
> +		trace_preempt_off(CALLER_ADDR0, ip);
> +	}
>  }
>  EXPORT_SYMBOL(__local_bh_disable_ip);
>  #endif /* CONFIG_TRACE_IRQFLAGS */

*ping*


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-09  6:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-24 14:16 [PATCH] softirq/preempt: add missing current->preempt_disable_ip update Heiko Carstens
2014-12-09  6:26 ` Heiko Carstens

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).