Skip to contentSkip to conversation

hrtimer: Add missing annotation to lock_hrtimer_base()

PATCH New Jules Irenge 1 participant 1 message Jan 27, 2020 High-resolution timers, timer wheel, clockevents

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 hrtimer: Add missing annotation to lock_hrtimer_base()

Sparse reports several warnings;

warning: context imbalance in lock_hrtimer_base() - wrong count at exit
warning: context imbalance in hrtimer_start_range_ns() - unexpected unlock
warning: context imbalance in hrtimer_try_to_cancel() - unexpected unlock
warning: context imbalance in __hrtimer_get_remaining() - unexpected unlock

The root cause is a missing annotation of lock_hrtimer_base() which also causes the "unexpected unlock" warnings.
To fix these,
an __acquires(timer) annotation is added to lock_hrtimer_base(). Given that lock_hrtimer_base() does actually call READ_ONCE(timer->base), this fixes the warnings.

---
 kernel/time/hrtimer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/time/hrtimer.c +3 -3
index 8de90ea31280..d149b599bdf7 100644
@@ -157,9 +157,9 @@ static inline bool is_migration_base(struct hrtimer_clock_base *base)
  * possible to set timer->base = &migration_base and drop the lock: the timer
  * remains locked.
  */
-static
-struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
-					     unsigned long *flags)
+static struct hrtimer_clock_base *
+lock_hrtimer_base(const struct hrtimer *timer,
+		  unsigned long *flags) __acquires(timer)
 {
 	struct hrtimer_clock_base *base;
 
Signature · 1 line
2.24.1