All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
@ 2020-01-09  5:40 Juergen Gross
  2020-01-09 10:07 ` George Dunlap
  0 siblings, 1 reply; 8+ messages in thread
From: Juergen Gross @ 2020-01-09  5:40 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Stefano Stabellini, Julien Grall, Wei Liu,
	Konrad Rzeszutek Wilk, George Dunlap, Andrew Cooper, Ian Jackson,
	Jan Beulich

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.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/common/spinlock.c | 2 +-
 xen/include/xen/lib.h | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c
index 286f916bca..8f54580d24 100644
--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -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;
 }
 
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 8fbe84032d..000ea677d0 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -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
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
  2020-01-09  5:40 [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG Juergen Gross
@ 2020-01-09 10:07 ` George Dunlap
  2020-01-09 10:15   ` Jürgen Groß
  2020-01-09 10:15   ` Jan Beulich
  0 siblings, 2 replies; 8+ messages in thread
From: George Dunlap @ 2020-01-09 10:07 UTC (permalink / raw)
  To: Juergen Gross, xen-devel
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Jan Beulich

On 1/9/20 5:40 AM, Juergen Gross wrote:
> 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.

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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
  2020-01-09 10:07 ` George Dunlap
@ 2020-01-09 10:15   ` Jürgen Groß
  2020-01-09 10:30     ` Jan Beulich
  2020-01-09 10:15   ` Jan Beulich
  1 sibling, 1 reply; 8+ messages in thread
From: Jürgen Groß @ 2020-01-09 10:15 UTC (permalink / raw)
  To: George Dunlap, xen-devel
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Jan Beulich

On 09.01.20 11:07, George Dunlap wrote:
> On 1/9/20 5:40 AM, Juergen Gross wrote:
>> 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.
> 
> 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.

> 
> 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
  2020-01-09 10:07 ` George Dunlap
  2020-01-09 10:15   ` Jürgen Groß
@ 2020-01-09 10:15   ` Jan Beulich
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2020-01-09 10:15 UTC (permalink / raw)
  To: George Dunlap, Juergen Gross
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel

On 09.01.2020 11:07, George Dunlap wrote:
> On 1/9/20 5:40 AM, Juergen Gross wrote:
>> 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.
> 
> 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
  2020-01-09 10:15   ` Jürgen Groß
@ 2020-01-09 10:30     ` Jan Beulich
  2020-01-09 10:39       ` George Dunlap
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2020-01-09 10:30 UTC (permalink / raw)
  To: Jürgen Groß
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, George Dunlap,
	xen-devel

On 09.01.2020 11:15, Jürgen Groß  wrote:
> On 09.01.20 11:07, George Dunlap wrote:
>> On 1/9/20 5:40 AM, Juergen Gross wrote:
>>> 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.
>>
>> 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
  2020-01-09 10:30     ` Jan Beulich
@ 2020-01-09 10:39       ` George Dunlap
  2020-01-09 10:45         ` Jan Beulich
  0 siblings, 1 reply; 8+ messages in thread
From: George Dunlap @ 2020-01-09 10:39 UTC (permalink / raw)
  To: Jan Beulich, Jürgen Groß
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel

On 1/9/20 10:30 AM, Jan Beulich wrote:
> On 09.01.2020 11:15, Jürgen Groß  wrote:
>> On 09.01.20 11:07, George Dunlap wrote:
>>> On 1/9/20 5:40 AM, Juergen Gross wrote:
>>>> 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.
>>>
>>> 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();
>     }

Is there a reason we can't make BUG_ON() print the condition?

 -George

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
  2020-01-09 10:39       ` George Dunlap
@ 2020-01-09 10:45         ` Jan Beulich
  2020-01-09 10:53           ` Jürgen Groß
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2020-01-09 10:45 UTC (permalink / raw)
  To: George Dunlap
  Cc: Jürgen Groß,
	Stefano Stabellini, Julien Grall, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel

On 09.01.2020 11:39, George Dunlap wrote:
> On 1/9/20 10:30 AM, Jan Beulich wrote:
>> On 09.01.2020 11:15, Jürgen Groß  wrote:
>>> On 09.01.20 11:07, George Dunlap wrote:
>>>> On 1/9/20 5:40 AM, Juergen Gross wrote:
>>>>> 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.
>>>>
>>>> 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();
>>     }
> 
> 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
  2020-01-09 10:45         ` Jan Beulich
@ 2020-01-09 10:53           ` Jürgen Groß
  0 siblings, 0 replies; 8+ messages in thread
From: Jürgen Groß @ 2020-01-09 10:53 UTC (permalink / raw)
  To: Jan Beulich, George Dunlap
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel

On 09.01.20 11:45, Jan Beulich wrote:
> On 09.01.2020 11:39, George Dunlap wrote:
>> On 1/9/20 10:30 AM, Jan Beulich wrote:
>>> On 09.01.2020 11:15, Jürgen Groß  wrote:
>>>> On 09.01.20 11:07, George Dunlap wrote:
>>>>> On 1/9/20 5:40 AM, Juergen Gross wrote:
>>>>>> 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.
>>>>>
>>>>> 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();
>>>      }
>>
>> 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.

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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2020-01-09 10:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  5:40 [Xen-devel] [PATCH] xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG Juergen Gross
2020-01-09 10:07 ` George Dunlap
2020-01-09 10:15   ` Jürgen Groß
2020-01-09 10:30     ` Jan Beulich
2020-01-09 10:39       ` George Dunlap
2020-01-09 10:45         ` Jan Beulich
2020-01-09 10:53           ` Jürgen Groß
2020-01-09 10:15   ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.