xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
PATCH 1/1 xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
In expert mode it is possible to enable CONFIG_DEBUG_LOCKS without having enabled CONFIG_DEBUG. The coding is depending on CONFIG_DEBUG as it is using ASSERT(), however.
Fix that by introducing assert() doing the same as ASSERT(), but being available in non-debug builds, too, and use that in spinlock debug code.
--- xen/common/spinlock.c | 2 +- xen/include/xen/lib.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
xen/common/spinlock.c +1 -1
@@ -86,7 +86,7 @@ static void got_lock(union lock_debug *debug)static void rel_lock (union lock_debug *debug) {if (atomic_read (&spin_debug) >0 ) -ASSERT (debug->cpu ==smp_processor_id ()); +assert (debug->cpu ==smp_processor_id ()); debug->cpu =SPINLOCK_NO_CPU ; }
xen/include/xen/lib.h +4 -2
@@ -32,9 +32,11 @@#define gcov_string ""#endif -#ifndef NDEBUG -#define ASSERT (p) \ +#define assert (p) \ do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0) + +#ifndef NDEBUG +#define ASSERT (p) assert(p)#define ASSERT_UNREACHABLE () assert_failed("unreachable")#define debug_build () 1#else
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 3 lines · Juergen Gross
In expert mode it is possible to enable
CONFIG_DEBUG_LOCKSwithout having enabledCONFIG_DEBUG. The coding is depending onCONFIG_DEBUGas it is usingASSERT(), however.
Any reason not to use BUG_ON() in that case?
Having two different asserts is almost certainly going to cause bugs.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · George Dunlap
Quoted 3 lines · Juergen Gross
In expert mode it is possible to enable
CONFIG_DEBUG_LOCKSwithout having enabledCONFIG_DEBUG. The coding is depending onCONFIG_DEBUGas it is usingASSERT(), however.Any reason not to use
BUG_ON()in that case?
The main reason is the missing message which condition failed.
A rename ("BUG_ASSERT"?) could be an alternative to just dropping the message. Both would be fine with me.
Quoted 2 lines
Having two different asserts is almost certainly going to cause bugs.
Obviously having only one is enough for bugs already. ;-)
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Jürgen Groß
Quoted 5 lines · George Dunlap
Quoted 3 lines · Juergen Gross
In expert mode it is possible to enable
CONFIG_DEBUG_LOCKSwithout having enabledCONFIG_DEBUG. The coding is depending onCONFIG_DEBUGas it is usingASSERT(), however.
Quoted 6 lines
Quoted 1 line
Any reason not to use
BUG_ON()in that case?The main reason is the missing message which condition failed.
A rename ("
BUG_ASSERT"?) could be an alternative to just dropping the message. Both would be fine with me.
How about
if ( ... )
{
printk(...);
BUG();
}?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Jürgen Groß
Quoted 5 lines · George Dunlap
Quoted 3 lines · Juergen Gross
In expert mode it is possible to enable
CONFIG_DEBUG_LOCKSwithout having enabledCONFIG_DEBUG. The coding is depending onCONFIG_DEBUGas it is usingASSERT(), however.Quoted 6 lines
Quoted 1 line
Any reason not to use
BUG_ON()in that case?The main reason is the missing message which condition failed.
A rename ("
BUG_ASSERT"?) could be an alternative to just dropping the message. Both would be fine with me.
Quoted 7 lines
How about
if ( ... ) { printk(...); BUG(); }
Is there a reason we can't make BUG_ON() print the condition?
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 17 lines · George Dunlap
Quoted 16 lines · Jan Beulich
Quoted 6 lines · Jürgen Groß
Quoted 5 lines · George Dunlap
Quoted 3 lines · Juergen Gross
In expert mode it is possible to enable
CONFIG_DEBUG_LOCKSwithout having enabledCONFIG_DEBUG. The coding is depending onCONFIG_DEBUGas it is usingASSERT(), however.Quoted 6 lines
Quoted 1 line
Any reason not to use
BUG_ON()in that case?The main reason is the missing message which condition failed.
A rename ("
BUG_ASSERT"?) could be an alternative to just dropping the message. Both would be fine with me.How about
Quoted 7 lines
Quoted 5 lines
if ( ... ) { printk(...); BUG(); }Is there a reason we can't make
BUG_ON()print the condition?
Of course we could, in principle, at the price of a meaningful growth of the .rodata section. If we do this, perhaps we'd want something like Linux'es CONFIG_DEBUG_BUGVERBOSE to control this.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 24 lines · Jan Beulich
Quoted 23 lines · George Dunlap
Quoted 21 lines · Jan Beulich
Quoted 6 lines · Jürgen Groß
Quoted 5 lines · George Dunlap
Quoted 3 lines · Juergen Gross
In expert mode it is possible to enable
CONFIG_DEBUG_LOCKSwithout having enabledCONFIG_DEBUG. The coding is depending onCONFIG_DEBUGas it is usingASSERT(), however.Quoted 6 lines
Quoted 1 line
Any reason not to use
BUG_ON()in that case?The main reason is the missing message which condition failed.
A rename ("
BUG_ASSERT"?) could be an alternative to just dropping the message. Both would be fine with me.How about
if ( ... ) { printk(...); BUG(); }
Quoted 5 lines
Quoted 1 line
Is there a reason we can't make
BUG_ON()print the condition?Of course we could, in principle, at the price of a meaningful growth of the .rodata section. If we do this, perhaps we'd want something like Linux'es
CONFIG_DEBUG_BUGVERBOSEto control this.
In case nobody objects I'll modify my patch to do that (well, split it to introduce that option and then use it).
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · George Dunlap
Quoted 3 lines · Juergen Gross
In expert mode it is possible to enable
CONFIG_DEBUG_LOCKSwithout having enabledCONFIG_DEBUG. The coding is depending onCONFIG_DEBUGas it is usingASSERT(), however.Any reason not to use
BUG_ON()in that case?Having two different asserts is almost certainly going to cause bugs.
Furthermore, assert() is a C standard library construct, mandated to be controlled by NDEBUG. I.e. if anything at all, ASSERT() could be made behave differently, but of course this would be quite big a change to the code base. +1 to (continue) using BUG_ON() anywhere we want more than just debug build checking.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel