LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] taint on lockdep warning with new TAINT_LOCKDEP
@ 2015-01-29 21:50 Slava Pestov
2015-01-30 23:44 ` Andrew Morton
2015-02-18 22:53 ` Ingo Molnar
0 siblings, 2 replies; 4+ messages in thread
From: Slava Pestov @ 2015-01-29 21:50 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar
Cc: Andrew Morton, Greg Kroah-Hartman, linux-kernel, Slava Pestov
This helps when writing automated tests, since they can fail the
test if the kernel was tainted instead of manually scraping dmesg
for interesting strings.
Signed-off-by: Slava Pestov <sp@daterainc.com>
---
include/linux/kernel.h | 1 +
kernel/locking/lockdep.c | 31 +++++++++++++++++++++++++++++++
kernel/panic.c | 2 ++
3 files changed, 34 insertions(+)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5449d2f..c46e24e 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -471,6 +471,7 @@ extern enum system_states {
#define TAINT_OOT_MODULE 12
#define TAINT_UNSIGNED_MODULE 13
#define TAINT_SOFTLOCKUP 14
+#define TAINT_LOCKDEP 15
extern const char hex_asc[];
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 88d0d44..4916a32 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -382,6 +382,8 @@ static unsigned long stack_trace[MAX_STACK_TRACE_ENTRIES];
static void print_lockdep_off(const char *bug_msg)
{
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk(KERN_DEBUG "%s\n", bug_msg);
printk(KERN_DEBUG "turning off the locking correctness validator.\n");
#ifdef CONFIG_LOCK_STAT
@@ -739,6 +741,9 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
*/
if (!static_obj(lock->key)) {
debug_locks_off();
+
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("INFO: trying to register non-static key.\n");
printk("the code is fine but needs lockdep annotation.\n");
printk("turning off the locking correctness validator.\n");
@@ -1190,6 +1195,8 @@ static noinline int print_circular_bug(struct lock_list *this,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
if (!save_trace(&this->trace))
return 0;
@@ -1492,6 +1499,8 @@ print_bad_irq_dependency(struct task_struct *curr,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("======================================================\n");
printk("[ INFO: %s-safe -> %s-unsafe lock order detected ]\n",
@@ -1722,6 +1731,8 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=============================================\n");
printk("[ INFO: possible recursive locking detected ]\n");
@@ -2226,6 +2237,8 @@ print_usage_bug(struct task_struct *curr, struct held_lock *this,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=================================\n");
printk("[ INFO: inconsistent lock state ]\n");
@@ -2291,6 +2304,8 @@ print_irq_inversion_bug(struct task_struct *curr,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=========================================================\n");
printk("[ INFO: possible irq lock inversion dependency detected ]\n");
@@ -3014,6 +3029,8 @@ print_lock_nested_lock_not_held(struct task_struct *curr,
if (debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("==================================\n");
printk("[ BUG: Nested lock was not taken ]\n");
@@ -3219,6 +3236,8 @@ print_unlock_imbalance_bug(struct task_struct *curr, struct lockdep_map *lock,
if (debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=====================================\n");
printk("[ BUG: bad unlock balance detected! ]\n");
@@ -3664,6 +3683,8 @@ print_lock_contention_bug(struct task_struct *curr, struct lockdep_map *lock,
if (debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=================================\n");
printk("[ BUG: bad contention detected! ]\n");
@@ -4040,6 +4061,8 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
if (debug_locks_silent)
return;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=========================\n");
printk("[ BUG: held lock freed! ]\n");
@@ -4098,6 +4121,8 @@ static void print_held_locks_bug(void)
if (debug_locks_silent)
return;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=====================================\n");
printk("[ BUG: %s/%d still has locks held! ]\n",
@@ -4197,6 +4222,9 @@ asmlinkage __visible void lockdep_sys_exit(void)
if (unlikely(curr->lockdep_depth)) {
if (!debug_locks_off())
return;
+
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("================================================\n");
printk("[ BUG: lock held when returning to user space! ]\n");
@@ -4216,6 +4244,9 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
if (!debug_locks_off())
return;
#endif /* #ifdef CONFIG_PROVE_RCU_REPEATEDLY */
+
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
/* Note: the following can be executed concurrently, so be careful. */
printk("\n");
printk("===============================\n");
diff --git a/kernel/panic.c b/kernel/panic.c
index 4d8d6f9..7bd42ba 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -226,6 +226,7 @@ static const struct tnt tnts[] = {
{ TAINT_OOT_MODULE, 'O', ' ' },
{ TAINT_UNSIGNED_MODULE, 'E', ' ' },
{ TAINT_SOFTLOCKUP, 'L', ' ' },
+ { TAINT_LOCKDEP, 'K', ' ' },
};
/**
@@ -246,6 +247,7 @@ static const struct tnt tnts[] = {
* 'O' - Out-of-tree module has been loaded.
* 'E' - Unsigned module has been loaded.
* 'L' - A soft lockup has previously occurred.
+ * 'K' - Lockdep warning was generated.
*
* The string is overwritten by the next call to print_tainted().
*/
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] taint on lockdep warning with new TAINT_LOCKDEP
2015-01-29 21:50 [PATCH] taint on lockdep warning with new TAINT_LOCKDEP Slava Pestov
@ 2015-01-30 23:44 ` Andrew Morton
2015-02-18 22:53 ` Ingo Molnar
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2015-01-30 23:44 UTC (permalink / raw)
To: Slava Pestov
Cc: Peter Zijlstra, Ingo Molnar, Greg Kroah-Hartman, linux-kernel,
Slava Pestov
On Thu, 29 Jan 2015 13:50:26 -0800 Slava Pestov <sp@datera.io> wrote:
> This helps when writing automated tests, since they can fail the
> test if the kernel was tainted instead of manually scraping dmesg
> for interesting strings.
Seems sane. It wouldn't hurt to mention this in
Documentation/locking/lockdep-design.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] taint on lockdep warning with new TAINT_LOCKDEP
2015-01-29 21:50 [PATCH] taint on lockdep warning with new TAINT_LOCKDEP Slava Pestov
2015-01-30 23:44 ` Andrew Morton
@ 2015-02-18 22:53 ` Ingo Molnar
1 sibling, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2015-02-18 22:53 UTC (permalink / raw)
To: Slava Pestov
Cc: Peter Zijlstra, Ingo Molnar, Andrew Morton, Greg Kroah-Hartman,
linux-kernel, Slava Pestov
* Slava Pestov <sp@datera.io> wrote:
> This helps when writing automated tests, since they can fail the
> test if the kernel was tainted instead of manually scraping dmesg
> for interesting strings.
>
> Signed-off-by: Slava Pestov <sp@daterainc.com>
> ---
> include/linux/kernel.h | 1 +
> kernel/locking/lockdep.c | 31 +++++++++++++++++++++++++++++++
> kernel/panic.c | 2 ++
> 3 files changed, 34 insertions(+)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 5449d2f..c46e24e 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -471,6 +471,7 @@ extern enum system_states {
> #define TAINT_OOT_MODULE 12
> #define TAINT_UNSIGNED_MODULE 13
> #define TAINT_SOFTLOCKUP 14
> +#define TAINT_LOCKDEP 15
>
> extern const char hex_asc[];
> #define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 88d0d44..4916a32 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -382,6 +382,8 @@ static unsigned long stack_trace[MAX_STACK_TRACE_ENTRIES];
>
> static void print_lockdep_off(const char *bug_msg)
> {
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
>
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
> + add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
If only we had a function that turns lockdep off in a
single place, instead of having to crap all over lockdep.c?
;-)
Thanks,
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] taint on lockdep warning with new TAINT_LOCKDEP
@ 2015-01-27 23:52 Slava Pestov
0 siblings, 0 replies; 4+ messages in thread
From: Slava Pestov @ 2015-01-27 23:52 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar; +Cc: linux-kernel, kmo, Slava Pestov
Hi Peter and Ingo,
Something like this seems like it would be a useful addition. I've heard
a few people mention that lockdep taints the kernel and even seen it come
up in mailing list posts, but this does not appear to be the case.
This patch adds a new taint flag. I'm using a similar patch on 3.14 here
at Datera, but I haven't verified the below version. It seemed to apply
without problems and compile. I hope I didn't miss anything obvious.
Slava
Change-Id: I482ad5470c7e24fc9fcdc17d9ea9f72d263f5261
---
include/linux/kernel.h | 1 +
kernel/locking/lockdep.c | 31 +++++++++++++++++++++++++++++++
kernel/panic.c | 2 ++
3 files changed, 34 insertions(+)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5449d2f..c46e24e 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -471,6 +471,7 @@ extern enum system_states {
#define TAINT_OOT_MODULE 12
#define TAINT_UNSIGNED_MODULE 13
#define TAINT_SOFTLOCKUP 14
+#define TAINT_LOCKDEP 15
extern const char hex_asc[];
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 88d0d44..4916a32 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -382,6 +382,8 @@ static unsigned long stack_trace[MAX_STACK_TRACE_ENTRIES];
static void print_lockdep_off(const char *bug_msg)
{
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk(KERN_DEBUG "%s\n", bug_msg);
printk(KERN_DEBUG "turning off the locking correctness validator.\n");
#ifdef CONFIG_LOCK_STAT
@@ -739,6 +741,9 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
*/
if (!static_obj(lock->key)) {
debug_locks_off();
+
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("INFO: trying to register non-static key.\n");
printk("the code is fine but needs lockdep annotation.\n");
printk("turning off the locking correctness validator.\n");
@@ -1190,6 +1195,8 @@ static noinline int print_circular_bug(struct lock_list *this,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
if (!save_trace(&this->trace))
return 0;
@@ -1492,6 +1499,8 @@ print_bad_irq_dependency(struct task_struct *curr,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("======================================================\n");
printk("[ INFO: %s-safe -> %s-unsafe lock order detected ]\n",
@@ -1722,6 +1731,8 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=============================================\n");
printk("[ INFO: possible recursive locking detected ]\n");
@@ -2226,6 +2237,8 @@ print_usage_bug(struct task_struct *curr, struct held_lock *this,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=================================\n");
printk("[ INFO: inconsistent lock state ]\n");
@@ -2291,6 +2304,8 @@ print_irq_inversion_bug(struct task_struct *curr,
if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=========================================================\n");
printk("[ INFO: possible irq lock inversion dependency detected ]\n");
@@ -3014,6 +3029,8 @@ print_lock_nested_lock_not_held(struct task_struct *curr,
if (debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("==================================\n");
printk("[ BUG: Nested lock was not taken ]\n");
@@ -3219,6 +3236,8 @@ print_unlock_imbalance_bug(struct task_struct *curr, struct lockdep_map *lock,
if (debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=====================================\n");
printk("[ BUG: bad unlock balance detected! ]\n");
@@ -3664,6 +3683,8 @@ print_lock_contention_bug(struct task_struct *curr, struct lockdep_map *lock,
if (debug_locks_silent)
return 0;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=================================\n");
printk("[ BUG: bad contention detected! ]\n");
@@ -4040,6 +4061,8 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
if (debug_locks_silent)
return;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=========================\n");
printk("[ BUG: held lock freed! ]\n");
@@ -4098,6 +4121,8 @@ static void print_held_locks_bug(void)
if (debug_locks_silent)
return;
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("=====================================\n");
printk("[ BUG: %s/%d still has locks held! ]\n",
@@ -4197,6 +4222,9 @@ asmlinkage __visible void lockdep_sys_exit(void)
if (unlikely(curr->lockdep_depth)) {
if (!debug_locks_off())
return;
+
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
printk("\n");
printk("================================================\n");
printk("[ BUG: lock held when returning to user space! ]\n");
@@ -4216,6 +4244,9 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
if (!debug_locks_off())
return;
#endif /* #ifdef CONFIG_PROVE_RCU_REPEATEDLY */
+
+ add_taint(TAINT_LOCKDEP, LOCKDEP_NOW_UNRELIABLE);
+
/* Note: the following can be executed concurrently, so be careful. */
printk("\n");
printk("===============================\n");
diff --git a/kernel/panic.c b/kernel/panic.c
index 4d8d6f9..7bd42ba 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -226,6 +226,7 @@ static const struct tnt tnts[] = {
{ TAINT_OOT_MODULE, 'O', ' ' },
{ TAINT_UNSIGNED_MODULE, 'E', ' ' },
{ TAINT_SOFTLOCKUP, 'L', ' ' },
+ { TAINT_LOCKDEP, 'K', ' ' },
};
/**
@@ -246,6 +247,7 @@ static const struct tnt tnts[] = {
* 'O' - Out-of-tree module has been loaded.
* 'E' - Unsigned module has been loaded.
* 'L' - A soft lockup has previously occurred.
+ * 'K' - Lockdep warning was generated.
*
* The string is overwritten by the next call to print_tainted().
*/
--
2.1.3
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-18 22:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 21:50 [PATCH] taint on lockdep warning with new TAINT_LOCKDEP Slava Pestov
2015-01-30 23:44 ` Andrew Morton
2015-02-18 22:53 ` Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2015-01-27 23:52 Slava Pestov
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).