Re: [PATCH] panic: lockdep: correct lock debugging state check

2016-04-26 Thread Shi, Yang

On 4/26/2016 5:39 AM, Peter Zijlstra wrote:

On Mon, Apr 25, 2016 at 08:36:37PM -0700, Yang Shi wrote:

When kernel oops happens, lock debugging is turned off by debug_locks_off()
in oops_enter() via calling __debug_locks_off() which set debug_locks to 0
via xchg(). But, calling to __debug_locks_off() to check lock debugging state
in add_taint() called by oops_end() will always return false since xchg()
returns the old value of debug_locks which is cleared in oops_enter() already.

This prevents add_taint() from printing out lock debugging disable information
although LOCKDEP_NOW_UNRELIABLE is passed to it.

Check lock debugging state via !debug_locks to fix this. Although
!__debug_locks_off() could do the same thing, it may look confusing.


What are you smoking? This is the second completely insane patch you
send this week.

This breaks add_taint() and gains us nothing except trivialities. Who


I apologize in advance, if I misunderstand the code and please ignore 
all the bullshit below.


In my understanding, add_taint() should call that pr_warn if 
LOCKDEP_NOW_UNRELIABLE is passed and lock debugging is disabled. This is 
what the code tells me.


LOCKDEP_NOW_UNRELIABLE is passed via lock_ok parameter, lock debugging 
is turned off by debug_locks_off() already, so it should print out 
something, but it doesn't since __debug_locks_off() always returns 0.


So, it looks the if statement logic is broken.

There are alternatives to fix it, I may pick up the not ideal one.


bloody cares about that print if you've just had an OOPS.


I do agree not too many people care about that print and such 
information is too trivial to draw attention from people. However, it 
doesn't mean oops print is a perfect place to hide something wrong. I 
just happened to find this by checking the oops information to try to 
get some clue for another issue. Then I thought it is just a quick fix, 
why not I should do that to make kernel better.


Thanks,
Yang







Re: [PATCH] panic: lockdep: correct lock debugging state check

2016-04-26 Thread Shi, Yang

On 4/26/2016 5:39 AM, Peter Zijlstra wrote:

On Mon, Apr 25, 2016 at 08:36:37PM -0700, Yang Shi wrote:

When kernel oops happens, lock debugging is turned off by debug_locks_off()
in oops_enter() via calling __debug_locks_off() which set debug_locks to 0
via xchg(). But, calling to __debug_locks_off() to check lock debugging state
in add_taint() called by oops_end() will always return false since xchg()
returns the old value of debug_locks which is cleared in oops_enter() already.

This prevents add_taint() from printing out lock debugging disable information
although LOCKDEP_NOW_UNRELIABLE is passed to it.

Check lock debugging state via !debug_locks to fix this. Although
!__debug_locks_off() could do the same thing, it may look confusing.


What are you smoking? This is the second completely insane patch you
send this week.

This breaks add_taint() and gains us nothing except trivialities. Who


I apologize in advance, if I misunderstand the code and please ignore 
all the bullshit below.


In my understanding, add_taint() should call that pr_warn if 
LOCKDEP_NOW_UNRELIABLE is passed and lock debugging is disabled. This is 
what the code tells me.


LOCKDEP_NOW_UNRELIABLE is passed via lock_ok parameter, lock debugging 
is turned off by debug_locks_off() already, so it should print out 
something, but it doesn't since __debug_locks_off() always returns 0.


So, it looks the if statement logic is broken.

There are alternatives to fix it, I may pick up the not ideal one.


bloody cares about that print if you've just had an OOPS.


I do agree not too many people care about that print and such 
information is too trivial to draw attention from people. However, it 
doesn't mean oops print is a perfect place to hide something wrong. I 
just happened to find this by checking the oops information to try to 
get some clue for another issue. Then I thought it is just a quick fix, 
why not I should do that to make kernel better.


Thanks,
Yang







Re: [PATCH] panic: lockdep: correct lock debugging state check

2016-04-26 Thread Peter Zijlstra
On Mon, Apr 25, 2016 at 08:36:37PM -0700, Yang Shi wrote:
> When kernel oops happens, lock debugging is turned off by debug_locks_off()
> in oops_enter() via calling __debug_locks_off() which set debug_locks to 0
> via xchg(). But, calling to __debug_locks_off() to check lock debugging state
> in add_taint() called by oops_end() will always return false since xchg()
> returns the old value of debug_locks which is cleared in oops_enter() already.
> 
> This prevents add_taint() from printing out lock debugging disable information
> although LOCKDEP_NOW_UNRELIABLE is passed to it.
> 
> Check lock debugging state via !debug_locks to fix this. Although
> !__debug_locks_off() could do the same thing, it may look confusing.
> 
What are you smoking? This is the second completely insane patch you
send this week.

This breaks add_taint() and gains us nothing except trivialities. Who
bloody cares about that print if you've just had an OOPS.


Re: [PATCH] panic: lockdep: correct lock debugging state check

2016-04-26 Thread Peter Zijlstra
On Mon, Apr 25, 2016 at 08:36:37PM -0700, Yang Shi wrote:
> When kernel oops happens, lock debugging is turned off by debug_locks_off()
> in oops_enter() via calling __debug_locks_off() which set debug_locks to 0
> via xchg(). But, calling to __debug_locks_off() to check lock debugging state
> in add_taint() called by oops_end() will always return false since xchg()
> returns the old value of debug_locks which is cleared in oops_enter() already.
> 
> This prevents add_taint() from printing out lock debugging disable information
> although LOCKDEP_NOW_UNRELIABLE is passed to it.
> 
> Check lock debugging state via !debug_locks to fix this. Although
> !__debug_locks_off() could do the same thing, it may look confusing.
> 
What are you smoking? This is the second completely insane patch you
send this week.

This breaks add_taint() and gains us nothing except trivialities. Who
bloody cares about that print if you've just had an OOPS.


[PATCH] panic: lockdep: correct lock debugging state check

2016-04-25 Thread Yang Shi
When kernel oops happens, lock debugging is turned off by debug_locks_off()
in oops_enter() via calling __debug_locks_off() which set debug_locks to 0
via xchg(). But, calling to __debug_locks_off() to check lock debugging state
in add_taint() called by oops_end() will always return false since xchg()
returns the old value of debug_locks which is cleared in oops_enter() already.

This prevents add_taint() from printing out lock debugging disable information
although LOCKDEP_NOW_UNRELIABLE is passed to it.

Check lock debugging state via !debug_locks to fix this. Although
!__debug_locks_off() could do the same thing, it may look confusing.

Before the fix, oops output looks like:
RIP  [] release_freepages+0x18/0xa0
 RSP 
CR2: 
[ end trace 2e96d09e0ba6342f ]

Aftere the fix, it looks like:
RIP  [] release_freepages+0x18/0xa0
 RSP 
CR2: 
Disabling lock debugging due to kernel taint
[ end trace 2e96d09e0ba6342f ]

And, fix a trivial typo in the comment of add_taint().

Signed-off-by: Yang Shi 
---
 kernel/panic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 535c965..859499d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -346,11 +346,11 @@ unsigned long get_taint(void)
  * @lockdep_ok: whether lock debugging is still OK.
  *
  * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for
- * some notewortht-but-not-corrupting cases, it can be set to true.
+ * some noteworthy-but-not-corrupting cases, it can be set to true.
  */
 void add_taint(unsigned flag, enum lockdep_ok lockdep_ok)
 {
-   if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off())
+   if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && !debug_locks)
pr_warn("Disabling lock debugging due to kernel taint\n");
 
set_bit(flag, _mask);
-- 
2.0.2



[PATCH] panic: lockdep: correct lock debugging state check

2016-04-25 Thread Yang Shi
When kernel oops happens, lock debugging is turned off by debug_locks_off()
in oops_enter() via calling __debug_locks_off() which set debug_locks to 0
via xchg(). But, calling to __debug_locks_off() to check lock debugging state
in add_taint() called by oops_end() will always return false since xchg()
returns the old value of debug_locks which is cleared in oops_enter() already.

This prevents add_taint() from printing out lock debugging disable information
although LOCKDEP_NOW_UNRELIABLE is passed to it.

Check lock debugging state via !debug_locks to fix this. Although
!__debug_locks_off() could do the same thing, it may look confusing.

Before the fix, oops output looks like:
RIP  [] release_freepages+0x18/0xa0
 RSP 
CR2: 
[ end trace 2e96d09e0ba6342f ]

Aftere the fix, it looks like:
RIP  [] release_freepages+0x18/0xa0
 RSP 
CR2: 
Disabling lock debugging due to kernel taint
[ end trace 2e96d09e0ba6342f ]

And, fix a trivial typo in the comment of add_taint().

Signed-off-by: Yang Shi 
---
 kernel/panic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 535c965..859499d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -346,11 +346,11 @@ unsigned long get_taint(void)
  * @lockdep_ok: whether lock debugging is still OK.
  *
  * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for
- * some notewortht-but-not-corrupting cases, it can be set to true.
+ * some noteworthy-but-not-corrupting cases, it can be set to true.
  */
 void add_taint(unsigned flag, enum lockdep_ok lockdep_ok)
 {
-   if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && __debug_locks_off())
+   if (lockdep_ok == LOCKDEP_NOW_UNRELIABLE && !debug_locks)
pr_warn("Disabling lock debugging due to kernel taint\n");
 
set_bit(flag, _mask);
-- 
2.0.2