common/spinlock: Improve the output from check_lock() if it trips
PATCH 1/1 common/spinlock: Improve the output from check_lock() if it trips
If check_lock() triggers, a crash will occur. Instead of simply identifying "the irq context was different", indicate the expected and current irq context.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
check_lock() only exists in debug builds, which makes this a low risk change for 4.10.
--- xen/common/spinlock.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
xen/common/spinlock.c +7 -1
@@ -44,7 +44,13 @@ static void check_lock(struct lock_debug *debug)if (unlikely (debug->irq_safe != irq_safe) ) {int seen =cmpxchg (&debug->irq_safe,-1 , irq_safe); -BUG_ON (seen == !irq_safe); + +if ( seen == !irq_safe ) + { +printk ("CHECKLOCK FAILURE: prev irqsafe: %d, curr irqsafe %d\n" , + seen, irq_safe); +BUG (); + } } }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 5 lines · Andrew Cooper
If
check_lock()triggers, a crash will occur. Instead of simply identifying "the irq context was different", indicate the expected and current irq context.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Andrew Cooper
If
check_lock()triggers, a crash will occur. Instead of simply identifying "the irq context was different", indicate the expected and current irq context.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Andrew,
Quoted 5 lines · Andrew Cooper
If
check_lock()triggers, a crash will occur. Instead of simply identifying "the irq context was different", indicate the expected and current irq context.Signed-off-by Andrew Cooper <[email protected]>
Cheers,
Quoted 35 lines
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
check_lock()only exists in debug builds, which makes this a low risk change for 4.10.--- xen/common/spinlock.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/common/spinlock.c +7
-1@@ -44,7 +44,13 @@ static void check_lock(struct lock_debug *debug)if (unlikely (debug->irq_safe != irq_safe) ) {int seen =cmpxchg (&debug->irq_safe,-1 , irq_safe); -BUG_ON (seen == !irq_safe); + +if ( seen == !irq_safe ) + { +printk ("CHECKLOCK FAILURE: prev irqsafe: %d, curr irqsafe %d\n" , + seen, irq_safe); +BUG (); + } } }
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 31.10.17 at 11:49, <[email protected]> wrote:
xen/common/spinlock.c static void check_lock(struct lock_debug *debug) · line 52
Quoted 10 lines
xen/common/spinlock.c +6
-1@@ -44,7 +44,13 @@ static void check_lock(struct lock_debug *debug)if (unlikely (debug->irq_safe != irq_safe) ) {int seen =cmpxchg (&debug->irq_safe,-1 , irq_safe); -BUG_ON (seen == !irq_safe); + +if ( seen == !irq_safe ) + { +printk ("CHECKLOCK FAILURE: prev irqsafe: %d, curr irqsafe %d\n" , + seen, irq_safe); +BUG ();
This really should use XENLOG_ERR imo, so that the message won't be lost if warnings are rate limited.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Jan,
Quoted 17 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 31.10.17 at 11:49, <[email protected]> wrote:
xen/common/spinlock.c static void check_lock(struct lock_debug *debug) · line 52
Quoted 10 lines
xen/common/spinlock.c +6
-1@@ -44,7 +44,13 @@ static void check_lock(struct lock_debug *debug)if (unlikely (debug->irq_safe != irq_safe) ) {int seen =cmpxchg (&debug->irq_safe,-1 , irq_safe); -BUG_ON (seen == !irq_safe); + +if ( seen == !irq_safe ) + { +printk ("CHECKLOCK FAILURE: prev irqsafe: %d, curr irqsafe %d\n" , + seen, irq_safe); +BUG ();This really should use
XENLOG_ERRimo, so that the message won't be lost if warnings are rate limited.
The patch was already merged. I guess a follow-up could be done for Xen 4.10.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel