lockdep: warn about lockdep disabling after kernel taint
PATCH 1/2 lockdep: warn about lockdep disabling after kernel taint
Impact: provide useful missing info for developers
Kernel taint can occur in several situations such as warnings, load of prorietary or staging modules, bad page, etc...
But when such taint happens, a developer might still be working on the kernel, expecting that lockdep is still enabled. But a taint disables lockdep without ever warning about it.
Such a kernel behaviour doesn't really help for kernel development.
This patch adds this missing warning.
Since the taint is done most of the time after the main message that explain the real source issue, it seems safe to warn about it inside add_taint() so that it appears at last, without hurting the main information.
kernel/panic.c +8 -2
@@ -213,8 +213,14 @@ unsigned long get_taint(void)void add_taint (unsigned flag) { -/* can't trust the integrity of the kernel anymore: */ - debug_locks =0 ; +/* +* Can't trust the integrity of the kernel anymore. +* We don't call directly debug_locks_off() because the issue +* is not necessarily serious enough to set oops_in_progress to 1 +*/ +if (xchg (&debug_locks,0 )) +printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +set_bit (flag, &tainted_mask); }EXPORT_SYMBOL (add_taint);
Signature · 1 line
1.6.1
PATCH 2/2 lockdep: choose to continue lock debugging despite taint
Lockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or anyone who might develop a kernel that happens to be tainted.
Just provide an option to let one choose to continue lock-debugging after any taint.
kernel/panic.c +2 -0
@@ -213,6 +213,7 @@ unsigned long get_taint(void)void add_taint (unsigned flag) { +#ifndef CONFIG_LOCKDEP_IGNORE_TAINT /* * Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue
@@ -220,6 +221,7 @@ void add_taint(unsigned flag)*/ if (xchg (&debug_locks,0 ))printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +#endif set_bit (flag, &tainted_mask); }
lib/Kconfig.debug +14 -0
@@ -436,6 +436,20 @@ config PROVE_LOCKING For more details, see Documentation/lockdep-design.txt. +config LOCKDEP_IGNORE_TAINT + bool "Lock debugging: continue despite taints" + depends on LOCKDEP + default n + help + If your kernel becomes tainted because of a warning, + a staging or proprietary module loaded, etc... lockdep + will be disabled by default. Select this option if you + want lockdep to continue running despite a taint. If + you are working on a staging driver, experiencing + warnings but focusing on something else, or whatever + reason that makes you developing on a kernel that is + tainted, you might want to say Y here. + config LOCKDEP bool depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
Signature · 1 line
1.6.1
Re: [PATCH 2/2] lockdep: choose to continue lock debugging despite taint
Quoted 5 lines · Frederic Weisbecker
Lockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or anyone who might develop a kernel that happens to be tainted.
Good point. Not having lockdep coverage for drivers/staging/ just prolongs their transition - not good.
But instead of this:
kernel/panic.c void add_taint(unsigned flag) · line 224
Quoted 11 lines
void
add_taint(unsigned flag)
{kernel/panic.c +2
-0+#ifndef CONFIG_LOCKDEP_IGNORE_TAINT /* * Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue @@ -220,6 +221,7 @@ void add_taint(unsigned flag)*/ if (xchg (&debug_locks,0 ))printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +#endif
I'd suggest to not do the debug_locks_off() call if TAINT_CRAP. I.e. something like:
if (!(flag & TAINT_CRAP) && debug_locks_off()) printk(...);
will do the trick.
Ingo
Re: [PATCH 2/2] lockdep: choose to continue lock debugging despite taint
Quoted 29 lines · Ingo Molnar
Quoted 5 lines · Frederic Weisbecker
Lockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or anyone who might develop a kernel that happens to be tainted.
Good point. Not having lockdep coverage for
drivers/staging/just prolongs their transition - not good.But instead of this:
kernel/panic.c void add_taint(unsigned flag) · line 224
Quoted 11 lines
void
add_taint(unsigned flag)
{kernel/panic.c +2
-0+#ifndef CONFIG_LOCKDEP_IGNORE_TAINT /* * Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue @@ -220,6 +221,7 @@ void add_taint(unsigned flag)*/ if (xchg (&debug_locks,0 ))printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +#endif I'd suggest to not do the
debug_locks_off()call ifTAINT_CRAP. I.e. something like:
Quoted 6 lines
if (!(flag & TAINT_CRAP) && debug_locks_off()) printk(...);will do the trick.
Ingo
Ok, but this is not only about staging. It's also about TAINT_WARN. Just imagine that you report a warning to a maintainer, and while you are waiting for it to be fixed, you can't use lockdep for your own needs.
Hm?
Frederic.
Re: [PATCH 2/2] lockdep: choose to continue lock debugging despite taint
Quoted 38 lines · Frederic Weisbecker
Quoted 29 lines · Ingo Molnar
Quoted 5 lines · Frederic Weisbecker
Lockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or anyone who might develop a kernel that happens to be tainted.
Good point. Not having lockdep coverage for
drivers/staging/just prolongs their transition - not good.But instead of this:
kernel/panic.c void add_taint(unsigned flag) · line 224
Quoted 11 lines
void
add_taint(unsigned flag)
{kernel/panic.c +2
-0+#ifndef CONFIG_LOCKDEP_IGNORE_TAINT /* * Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue @@ -220,6 +221,7 @@ void add_taint(unsigned flag)*/ if (xchg (&debug_locks,0 ))printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +#endif I'd suggest to not do the
debug_locks_off()call ifTAINT_CRAP. I.e. something like:Quoted 6 lines
if (!(flag & TAINT_CRAP) && debug_locks_off()) printk(...);will do the trick.
Ingo
Quoted 6 lines
Ok, but this is not only about staging. It's also about
TAINT_WARN. Just imagine that you report a warning to a maintainer, and while you are waiting for it to be fixed, you can't use lockdep for your own needs.Hm?
We can exclude TAINT_WARN too - i.e. (TAINT_CRAP|TAINT_WARN).
Ingo
Re: [PATCH 2/2] lockdep: choose to continue lock debugging despite taint
Quoted 46 lines · Ingo Molnar
Quoted 43 lines · Frederic Weisbecker
Quoted 29 lines · Ingo Molnar
Quoted 5 lines · Frederic Weisbecker
Lockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or anyone who might develop a kernel that happens to be tainted.
Good point. Not having lockdep coverage for
drivers/staging/just prolongs their transition - not good.But instead of this:
kernel/panic.c void add_taint(unsigned flag) · line 224
Quoted 11 lines
void
add_taint(unsigned flag)
{kernel/panic.c +2
-0+#ifndef CONFIG_LOCKDEP_IGNORE_TAINT /* * Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue @@ -220,6 +221,7 @@ void add_taint(unsigned flag)*/ if (xchg (&debug_locks,0 ))printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +#endif I'd suggest to not do the
debug_locks_off()call ifTAINT_CRAP. I.e. something like:Quoted 6 lines
if (!(flag & TAINT_CRAP) && debug_locks_off()) printk(...);will do the trick.
Ingo
Ok, but this is not only about staging. It's also about
TAINT_WARN. Just imagine that you report a warning to a maintainer, and while you are waiting for it to be fixed, you can't use lockdep for your own needs.
Quoted 5 lines
Quoted 1 line
Hm?
We can exclude
TAINT_WARNtoo - i.e. (TAINT_CRAP|TAINT_WARN).Ingo
Fine :-)
See the v2 on further mails in this thread.
Side request: do you think you could merge them on kill-the-BKL tree?
Thanks!
Re: [PATCH 2/2] lockdep: choose to continue lock debugging despite taint
Quoted 51 lines · Frederic Weisbecker
Quoted 50 lines · Ingo Molnar
Quoted 38 lines · Frederic Weisbecker
Quoted 29 lines · Ingo Molnar
Quoted 5 lines · Frederic Weisbecker
Lockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or anyone who might develop a kernel that happens to be tainted.
Good point. Not having lockdep coverage for
drivers/staging/just prolongs their transition - not good.But instead of this:
kernel/panic.c void add_taint(unsigned flag) · line 224
Quoted 11 lines
void
add_taint(unsigned flag)
{kernel/panic.c +2
-0+#ifndef CONFIG_LOCKDEP_IGNORE_TAINT /* * Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue @@ -220,6 +221,7 @@ void add_taint(unsigned flag)*/ if (xchg (&debug_locks,0 ))printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +#endif I'd suggest to not do the
debug_locks_off()call ifTAINT_CRAP. I.e. something like:Quoted 6 lines
if (!(flag & TAINT_CRAP) && debug_locks_off()) printk(...);will do the trick.
Ingo
Quoted 6 lines
Ok, but this is not only about staging. It's also about
TAINT_WARN. Just imagine that you report a warning to a maintainer, and while you are waiting for it to be fixed, you can't use lockdep for your own needs.Hm?
We can exclude
TAINT_WARNtoo - i.e. (TAINT_CRAP|TAINT_WARN).
Quoted 8 lines
Quoted 1 line
Ingo
Fine :-)
See the v2 on further mails in this thread.
Side request: do you think you could merge them on kill-the-BKL tree?
Sorry, forget about this side request. I thought merging tip:master into tip:core/kill-the-BKL would make me suffer a rain of conflicts but actually I've just tried and I only encountered a very simple conflict in sched.c so it's very easy to manage it locally. Then we can keep the history of kill-the-BKL, for now it's good as is.
Frederic.
Quoted 2 lines
Thanks!
Re: [PATCH 2/2] lockdep: choose to continue lock debugging despite taint
Quoted 9 lines · Frederic Weisbecker
Quoted 2 lines
Side request: do you think you could merge them on kill-the-BKL tree?
Sorry, forget about this side request. I thought merging tip:master into tip:core/kill-the-BKL would make me suffer a rain of conflicts but actually I've just tried and I only encountered a very simple conflict in
sched.cso it's very easy to manage it locally. Then we can keep the history of kill-the-BKL, for now it's good as is.
Ok - that's how we like topics anyway: as independent trees which happen to be mostly conflict-free when merged into tip:master.
Ingo
PATCH v2 1/2 lockdep: warn about lockdep disabling after kernel taint
In reply to Ingo MolnarImpact: provide useful missing info for developers
Kernel taint can occur in several situations such as warnings, load of prorietary or staging modules, bad page, etc...
But when such taint happens, a developer might still be working on the kernel, expecting that lockdep is still enabled. But a taint disables lockdep without ever warning about it.
Such a kernel behaviour doesn't really help for kernel development.
This patch adds this missing warning.
Since the taint is done most of the time after the main message that explain the real source issue, it seems safe to warn about it inside add_taint() so that it appears at last, without hurting the main information.
v2: Use a generic helper to disable lockdep instead of an open coded xchg().
--- include/linux/debug_locks.h | 7 +++++++ kernel/panic.c | 10 ++++++++-- lib/debug_locks.c | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-)
include/linux/debug_locks.h +7 -0
@@ -2,12 +2,19 @@#define __LINUX_DEBUG_LOCKING_H#include <linux/kernel.h> +#include <asm/atomic.h> struct task_struct ;extern int debug_locks;extern int debug_locks_silent; + +static inline int __debug_locks_off (void ) +{ +return xchg (&debug_locks,0 ); +} +/* * Generic 'turn off all lock debugging' function: */
kernel/panic.c +8 -2
@@ -213,8 +213,14 @@ unsigned long get_taint(void)void add_taint (unsigned flag) { -/* can't trust the integrity of the kernel anymore: */ - debug_locks =0 ; +/* +* Can't trust the integrity of the kernel anymore. +* We don't call directly debug_locks_off() because the issue +* is not necessarily serious enough to set oops_in_progress to 1 +*/ +if (__debug_locks_off ()) +printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +set_bit (flag, &tainted_mask); }EXPORT_SYMBOL (add_taint);
lib/debug_locks.c +1 -1
@@ -36,7 +36,7 @@ int debug_locks_silent;*/ int debug_locks_off (void ) { -if (xchg (&debug_locks,0 )) { +if (__debug_locks_off ()) {if (!debug_locks_silent) { oops_in_progress =1 ;console_verbose ();
Signature · 1 line
1.6.1
Commit-ID: 9eeba6138cefc0435695463ddadb0d95e0a6bcd2 Gitweb: http://git.kernel.org/tip/9eeba6138cefc0435695463ddadb0d95e0a6bcd2 Author: Frederic Weisbecker <[email protected]> AuthorDate: Sat, 11 Apr 2009 03:17:17 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 12 Apr 2009 16:10:51 +0200
lockdep: warn about lockdep disabling after kernel taint
Impact: provide useful missing info for developers
Kernel taint can occur in several situations such as warnings, load of prorietary or staging modules, bad page, etc...
But when such taint happens, a developer might still be working on the kernel, expecting that lockdep is still enabled. But a taint disables lockdep without ever warning about it.
Such a kernel behaviour doesn't really help for kernel development.
This patch adds this missing warning.
Since the taint is done most of the time after the main message that explain the real source issue, it seems safe to warn about it inside add_taint() so that it appears at last, without hurting the main information.
v2: Use a generic helper to disable lockdep instead of an
open coded xchg().
LKML-Reference: <[email protected]>
--- include/linux/debug_locks.h | 7 +++++++ kernel/panic.c | 10 ++++++++-- lib/debug_locks.c | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-)
include/linux/debug_locks.h +7 -0
@@ -2,12 +2,19 @@#define __LINUX_DEBUG_LOCKING_H#include <linux/kernel.h> +#include <asm/atomic.h> struct task_struct ;extern int debug_locks;extern int debug_locks_silent; + +static inline int __debug_locks_off (void ) +{ +return xchg (&debug_locks,0 ); +} +/* * Generic 'turn off all lock debugging' function: */
kernel/panic.c +8 -2
@@ -213,8 +213,14 @@ unsigned long get_taint(void)void add_taint (unsigned flag) { -/* can't trust the integrity of the kernel anymore: */ - debug_locks =0 ; +/* +* Can't trust the integrity of the kernel anymore. +* We don't call directly debug_locks_off() because the issue +* is not necessarily serious enough to set oops_in_progress to 1 +*/ +if (__debug_locks_off ()) +printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +set_bit (flag, &tainted_mask); }EXPORT_SYMBOL (add_taint);
lib/debug_locks.c +1 -1
@@ -36,7 +36,7 @@ int debug_locks_silent;*/ int debug_locks_off (void ) { -if (xchg (&debug_locks,0 )) { +if (__debug_locks_off ()) {if (!debug_locks_silent) { oops_in_progress =1 ;console_verbose ();
PATCH v2 2/2 lockdep: continue lock debugging despite some taints
In reply to Ingo MolnarLockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or those who experience a warning but are focused on another things that require lockdep.
The v2 of this patch simply don't disable anymore lockdep in case of TAINT_CRAP and TAINT_WARN events.
--- kernel/panic.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
kernel/panic.c +3 -1
@@ -217,8 +217,10 @@ void add_taint(unsigned flag)* Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue * is not necessarily serious enough to set oops_in_progress to 1 +* Also we want to keep up lockdep for staging development and +* post-warning case. */ -if (__debug_locks_off ()) +if (flag !=TAINT_CRAP && flag !=TAINT_WARN &&__debug_locks_off ())printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" );set_bit (flag, &tainted_mask);
Signature · 1 line
1.6.1
[tip:core/urgent] lockdep: continue lock debugging despite some taints
Commit-ID: 574bbe782057fdf0490dc7dec906a2dc26363e20 Gitweb: http://git.kernel.org/tip/574bbe782057fdf0490dc7dec906a2dc26363e20 Author: Frederic Weisbecker <[email protected]> AuthorDate: Sat, 11 Apr 2009 03:17:18 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 12 Apr 2009 16:10:52 +0200
lockdep: continue lock debugging despite some taints
Impact: broaden lockdep checks
Lockdep is disabled after any kernel taints. This might be convenient to ignore bad locking issues which sources come from outside the kernel tree. Nevertheless, it might be a frustrating experience for the staging developers or those who experience a warning but are focused on another things that require lockdep.
The v2 of this patch simply don't disable anymore lockdep in case of TAINT_CRAP and TAINT_WARN events.
LKML-Reference: <[email protected]>
--- kernel/panic.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
kernel/panic.c +3 -1
@@ -217,8 +217,10 @@ void add_taint(unsigned flag)* Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue * is not necessarily serious enough to set oops_in_progress to 1 +* Also we want to keep up lockdep for staging development and +* post-warning case. */ -if (__debug_locks_off ()) +if (flag !=TAINT_CRAP && flag !=TAINT_WARN &&__debug_locks_off ())printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" );set_bit (flag, &tainted_mask);
Quoted 27 lines · Frederic Weisbecker
Impact: provide useful missing info for developers
Kernel taint can occur in several situations such as warnings, load of prorietary or staging modules, bad page, etc...
But when such taint happens, a developer might still be working on the kernel, expecting that lockdep is still enabled. But a taint disables lockdep without ever warning about it.
Such a kernel behaviour doesn't really help for kernel development.This patch adds this missing warning.
Since the taint is done most of the time after the main message that explain the real source issue, it seems safe to warn about it inside
add_taint()so that it appears at last, without hurting the main information.Signed-off-by Frederic Weisbecker <[email protected]>kernel/panic.c +0
-0@@ -213,8 +213,14 @@ unsigned long get_taint(void)void add_taint (unsigned flag) {
kernel/panic.c unsigned long get_taint(void) · line 223
Quoted 10 lines
kernel/panic.c +8
-2-/* can't trust the integrity of the kernel anymore: */ - debug_locks =0 ; +/* +* Can't trust the integrity of the kernel anymore. +* We don't call directly debug_locks_off() because the issue +* is not necessarily serious enough to set oops_in_progress to 1 +*/ +if (xchg (&debug_locks,0 )) +printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +
nice idea - but please use the proper debug_locks_off() construct instead of an open-coded xchg(). Something like:
if (debug_locks_off()) printk(...);
should do the trick.
Ingo
Quoted 44 lines · Ingo Molnar
Quoted 27 lines · Frederic Weisbecker
Impact: provide useful missing info for developers
Kernel taint can occur in several situations such as warnings, load of prorietary or staging modules, bad page, etc...
But when such taint happens, a developer might still be working on the kernel, expecting that lockdep is still enabled. But a taint disables lockdep without ever warning about it.
Such a kernel behaviour doesn't really help for kernel development.This patch adds this missing warning.
Since the taint is done most of the time after the main message that explain the real source issue, it seems safe to warn about it inside
add_taint()so that it appears at last, without hurting the main information.Signed-off-by Frederic Weisbecker <[email protected]>kernel/panic.c +0
-0@@ -213,8 +213,14 @@ unsigned long get_taint(void)void add_taint (unsigned flag) {kernel/panic.c unsigned long get_taint(void) · line 223
Quoted 10 lines
kernel/panic.c +8
-2-/* can't trust the integrity of the kernel anymore: */ - debug_locks =0 ; +/* +* Can't trust the integrity of the kernel anymore. +* We don't call directly debug_locks_off() because the issue +* is not necessarily serious enough to set oops_in_progress to 1 +*/ +if (xchg (&debug_locks,0 )) +printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +nice idea - but please use the proper
debug_locks_off()construct instead of an open-codedxchg(). Something like:
Quoted 6 lines
if (debug_locks_off()) printk(...);should do the trick.
Ingo
Yeah, I first wanted to do so but was shy about the oops_in_progress = 1 inside debug_locks_off(). Isn't it a problem?
Thanks,
Frederic.
Quoted 48 lines · Frederic Weisbecker
Quoted 47 lines · Ingo Molnar
Quoted 27 lines · Frederic Weisbecker
Impact: provide useful missing info for developers
Kernel taint can occur in several situations such as warnings, load of prorietary or staging modules, bad page, etc...
But when such taint happens, a developer might still be working on the kernel, expecting that lockdep is still enabled. But a taint disables lockdep without ever warning about it.
Such a kernel behaviour doesn't really help for kernel development.This patch adds this missing warning.
Since the taint is done most of the time after the main message that explain the real source issue, it seems safe to warn about it inside
add_taint()so that it appears at last, without hurting the main information.Signed-off-by Frederic Weisbecker <[email protected]>kernel/panic.c +0
-0@@ -213,8 +213,14 @@ unsigned long get_taint(void)void add_taint (unsigned flag) {kernel/panic.c unsigned long get_taint(void) · line 223
Quoted 10 lines
kernel/panic.c +8
-2-/* can't trust the integrity of the kernel anymore: */ - debug_locks =0 ; +/* +* Can't trust the integrity of the kernel anymore. +* We don't call directly debug_locks_off() because the issue +* is not necessarily serious enough to set oops_in_progress to 1 +*/ +if (xchg (&debug_locks,0 )) +printk (KERN_WARNING "Disabling lockdep due to kernel taint\n" ); +nice idea - but please use the proper
debug_locks_off()construct instead of an open-codedxchg(). Something like:if (debug_locks_off()) printk(...);
Quoted 6 lines
Quoted 3 lines
should do the trick.
Ingo
Yeah, I first wanted to do so but was shy about the
oops_in_progress= 1 insidedebug_locks_off(). Isn't it a problem?
hm, indeed. How about providing a __debug_locks_off() primitive that only does the xchg and none of the oops_in_progress and console_verbose() calls?
Ingo