xen: fix CONFIG_DEBUG_LOCKS
v3 cover xen: fix CONFIG_DEBUG_LOCKS
CONFIG_DEBUG_LOCKS is using ASSERT() for catching issues making it depend on CONFIG_DEBUG.
This series fixes that by using BUG_ON() instead. In order not to lose the rather nice debugging information which condition was hit add a config option to include a message similar to the one ASSERT() is printing in case of BUG_ON() triggering.
Juergen Gross (2):
xen: add config option to include failing condition in BUG_ON()
message
xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
xen/Kconfig.debug | 8 +++++++- xen/common/spinlock.c | 2 +- xen/include/asm-arm/bug.h | 6 ++++-- xen/include/asm-x86/bug.h | 5 +++-- xen/include/xen/lib.h | 4 ++++ 5 files changed, 19 insertions(+), 6 deletions(-)
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v3 1/2 xen: add config option to include failing condition in BUG_ON() message
Today a triggering BUG_ON() will only print source file and line information. Add the possibility to print the triggering condition like ASSERT().
Do that by introducing BUG_VERBOSE() and add a Kconfig option to make BUG_ON use BUG_VERBOSE().
---
V3:
- move kconfig option out of DEBUG || expert section (Jan Beulich)
- fix ARM build (Jan Beulich)
- eliminate BUG_ON_VERBOSE() (Jan Beulich)
--- xen/Kconfig.debug | 8 +++++++- xen/include/asm-arm/bug.h | 6 ++++-- xen/include/asm-x86/bug.h | 5 +++-- xen/include/xen/lib.h | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-)
xen/Kconfig.debug +7 -1
@@ -11,6 +11,13 @@ config DEBUG You probably want to say 'N' here. +config DEBUG_BUGVERBOSE + bool "Verbose BUG_ON messages" + default DEBUG + ---help--- + In case a BUG_ON triggers additionally print the triggering + condition on the console. + if DEBUG || EXPERT = "y" config CRASH_DEBUG
@@ -81,7 +88,6 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. - config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG
xen/include/asm-arm/bug.h +4 -2
@@ -60,11 +60,13 @@ struct bug_frame {#define WARN () BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "") -#define BUG () do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, ""); \ +#define BUG_VERBOSE (msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \ unreachable(); \ } while (0) +#define BUG () BUG_VERBOSE("") +#define assert_failed (msg) do { \ BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \ unreachable(); \
xen/include/asm-x86/bug.h +3 -2
@@ -60,10 +60,11 @@ struct bug_frame {#define WARN () BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, NULL) -#define BUG () do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL); \ +#define BUG_VERBOSE (msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \ unreachable(); \ } while (0) +#define BUG () BUG_VERBOSE(NULL)#define run_in_exception_handler (fn) BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL)
xen/include/xen/lib.h +4 -0
@@ -22,7 +22,11 @@#include <xen/string.h> #include <asm/bug.h> +#ifdef CONFIG_DEBUG_BUGVERBOSE +#define BUG_ON (p) do { if (unlikely(p)) BUG_VERBOSE(#p); } while (0) +#else #define BUG_ON (p) do { if (unlikely(p)) BUG(); } while (0) +#endif #define WARN_ON (p) do { if (unlikely(p)) WARN(); } while (0)#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=6 )
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v3 1/2] xen: add config option to include failing condition in BUG_ON() message
Quoted 8 lines · Juergen Gross
Today a triggering
BUG_ON()will only print source file and line information. Add the possibility to print the triggering condition likeASSERT().Do that by introducing
BUG_VERBOSE()and add aKconfigoption to makeBUG_ONuseBUG_VERBOSE().Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v3 1/2] xen: add config option to include failing condition in BUG_ON() message
In reply to Juergen GrossHi Juergen,
Quoted 3 lines · Juergen Gross
Today a triggering
BUG_ON()will only print source file and line information. Add the possibility to print the triggering condition likeASSERT().
Any reason to only limit the change for BUG_ON? How about WARN_ON?
Quoted 36 lines
Do that by introducing
BUG_VERBOSE()and add aKconfigoption to makeBUG_ONuseBUG_VERBOSE().Signed-off-by Juergen Gross <[email protected]>---
V3:
- move kconfig option out of DEBUG || expert section (Jan Beulich)
- fix ARM build (Jan Beulich)
- eliminateBUG_ON_VERBOSE()(Jan Beulich)--- xen/Kconfig.debug | 8 +++++++- xen/include/asm-arm/bug.h | 6 ++++-- xen/include/asm-x86/bug.h | 5 +++-- xen/include/xen/lib.h | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-)xen/Kconfig.debug +7
-0@@ -11,6 +11,13 @@ config DEBUG You probably want to say 'N' here. +config DEBUG_BUGVERBOSE + bool "Verbose BUG_ON messages" + default DEBUG + ---help--- + In case a BUG_ON triggers additionally print the triggering + condition on the console. + if DEBUG || EXPERT = "y" config CRASH_DEBUG
xen/Kconfig.debug config PERF_ARRAYS · line 84
Quoted 4 lines
xen/Kconfig.debug +0
-1@@ -81,7 +88,6 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. -
While I agree this should be dropped this is a spurious line, this feels a bit out of context. So I would suggest to mention it in the commit message or split it in a separate patch.
Quoted 8 lines
xen/Kconfig.debug +0
-0config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUGxen/include/asm-arm/bug.h +0
-0
xen/include/asm-arm/bug.h struct bug_frame { · line 64
Quoted 7 lines
xen/include/asm-arm/bug.h +2
-2@@ -60,11 +60,13 @@ struct bug_frame {#define WARN () BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "") -#define BUG () do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, ""); \ +#define BUG_VERBOSE (msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \
I am afraid this is not going to be enough to make it work on Arm. You also need to update do_bug_frame() to print the string.
I would actually expect a similar change required on the x86 side. Do you mind explaining how this works?
Quoted 33 lines
xen/include/asm-arm/bug.h +2
-0unreachable (); \ } while (0) +#define BUG () BUG_VERBOSE("") +#define assert_failed (msg) do { \ BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \ unreachable(); \xen/include/asm-x86/bug.h +3
-2@@ -60,10 +60,11 @@ struct bug_frame {#define WARN () BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, NULL) -#define BUG () do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL); \ +#define BUG_VERBOSE (msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \ unreachable(); \ } while (0) +#define BUG () BUG_VERBOSE(NULL)#define run_in_exception_handler (fn) BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL)xen/include/xen/lib.h +0
-0@@ -22,7 +22,11 @@#include <xen/string.h>
xen/include/xen/lib.h line 32
Quoted 10 lines
xen/include/xen/lib.h +4
-0#include <asm/bug.h> +#ifdef CONFIG_DEBUG_BUGVERBOSE +#define BUG_ON (p) do { if (unlikely(p)) BUG_VERBOSE(#p); } while (0) +#else #define BUG_ON (p) do { if (unlikely(p)) BUG(); } while (0) +#endif #define WARN_ON (p) do { if (unlikely(p)) WARN(); } while (0)#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=6 )
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v3 1/2] xen: add config option to include failing condition in BUG_ON() message
Quoted 8 lines · Julien Grall
Hi Juergen,
Quoted 3 lines · Juergen Gross
Today a triggering
BUG_ON()will only print source file and line information. Add the possibility to print the triggering condition likeASSERT().Any reason to only limit the change for
BUG_ON? How aboutWARN_ON?
Hmm, why not.
Any objections?
Quoted 31 lines
Quoted 31 lines
Do that by introducing
BUG_VERBOSE()and add aKconfigoption to makeBUG_ONuseBUG_VERBOSE().Signed-off-by Juergen Gross <[email protected]>---
V3:
- move kconfig option out of DEBUG || expert section (Jan Beulich)
- fix ARM build (Jan Beulich)
- eliminateBUG_ON_VERBOSE()(Jan Beulich)
---
xen/Kconfig.debug | 8 +++++++-xen/include/asm-arm/bug.h| 6 ++++--xen/include/asm-x86/bug.h| 5 +++-- xen/include/xen/lib.h | 4 ++++4 files changed, 18 insertions(+), 5 deletions(-)xen/Kconfig.debug +0
-0@@ -11,6 +11,13 @@ config DEBUGYou probably want to say 'N' here.
xen/Kconfig.debug +7
-0+config DEBUG_BUGVERBOSE + bool "Verbose BUG_ON messages" + default DEBUG + ---help--- + In case a BUG_ON triggers additionally print the triggering + condition on the console. +
Quoted 8 lines
Quoted 6 lines
if DEBUG || EXPERT = "y"
configCRASH_DEBUGxen/Kconfig.debug +0
-0@@ -81,7 +88,6 @@ config PERF_ARRAYS---help---
Enables software performance counter array histograms. -While I agree this should be dropped this is a spurious line, this feels a bit out of context. So I would suggest to mention it in the commit message or split it in a separate patch.
In fact this is the result of moving the new option in V3.
I'll mention the change in the commit message.
Quoted 17 lines
Quoted 9 lines
config
VERBOSE_DEBUG
bool "Verbose debug messages"
default DEBUGxen/include/asm-arm/bug.h +0
-0xen/include/asm-arm/bug.h struct bug_frame { · line 62
Quoted 5 lines
xen/include/asm-arm/bug.h +2
-2@@ -60,11 +60,13 @@ struct bug_frame { #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "") -#define BUG () do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, ""); \ +#define BUG_VERBOSE (msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \I am afraid this is not going to be enough to make it work on Arm. You also need to update
do_bug_frame()to print the string.
Quoted 1 line
I would actually expect a similar change required on the x86 side. Do you mind explaining how this works?
You are right, of course.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v3 2/2 xen: make CONFIG_DEBUG_LOCKS usable without CONFIG_DEBUG
In reply to Juergen GrossIn 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 using BUG_ON() instead of ASSERT() in rel_lock().
--- xen/common/spinlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 ()); +BUG_ON (debug->cpu !=smp_processor_id ()); debug->cpu =SPINLOCK_NO_CPU ; }
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel