Skip to contentSkip to conversation

lockdep: fix spurious 'inconsistent lock state' warning

PATCH In review Dmitry Baryshkov 2 participants 2 messages Aug 18, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockdep: fix spurious 'inconsistent lock state' warning

Since f82b217e3513fe3af342c0f3ee1494e86250c21c lockdep can output spurious warnings related to hwirqs due to hardirq_off shrinkage from int to bit-sized flag. Guard it with double negation to fix the warning.

---
 kernel/lockdep.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/lockdep.c +1 -1
index 1aa91fd..b298888 100644
@@ -2584,7 +2584,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
 	hlock->trylock = trylock;
 	hlock->read = read;
 	hlock->check = check;
-	hlock->hardirqs_off = hardirqs_off;
+	hlock->hardirqs_off = !!hardirqs_off;
 #ifdef CONFIG_LOCK_STAT
 	hlock->waittime_stamp = 0;
 	hlock->holdtime_stamp = sched_clock();
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 6 lines · Dmitry Baryshkov

Since f82b217e3513fe3af342c0f3ee1494e86250c21c lockdep can output spurious warnings related to hwirqs due to hardirq_off shrinkage from int to bit-sized flag. Guard it with double negation to fix the warning.

good spotting! Applied to tip/core/urgent, thanks Dmitry.

I'm wondering, is there any way to teach gcc some sanity here - a safer variant of bitfields, that is just not allowed to overflow into or corrupt nearby fields? The fact that a benign looking hlock->state = 15 can corrupt other fields worries me quite a bit. Valid C semantics or not, this is a totally dangerous construct. The space savings are very real though, so it would be nice to get 'safer bitfields', somehow.

Ingo