hrtimer: Add missing sparse annotations to hrtimer locking
authorBen Dooks <ben.dooks@codethink.co.uk>
Wed, 21 Jun 2023 07:59:28 +0000 (08:59 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 22 Jun 2023 08:32:37 +0000 (10:32 +0200)
Sparse warns about lock imbalance vs. the hrtimer_base lock due to missing
sparse annotations:

kernel/time/hrtimer.c:175:33: warning: context imbalance in 'lock_hrtimer_base' - wrong count at exit
kernel/time/hrtimer.c:1301:28: warning: context imbalance in 'hrtimer_start_range_ns' - unexpected unlock
kernel/time/hrtimer.c:1336:28: warning: context imbalance in 'hrtimer_try_to_cancel' - unexpected unlock
kernel/time/hrtimer.c:1457:9: warning: context imbalance in '__hrtimer_get_remaining' - unexpected unlock

Add the annotations to the relevant functions.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230621075928.394481-1-ben.dooks@codethink.co.uk
kernel/time/hrtimer.c

index e8c08292defcbd3e79d3a5fd921de7c7bfc905c6..238262e4aba7e2887f2766cc17b61aa0eb546308 100644 (file)
@@ -164,6 +164,7 @@ static inline bool is_migration_base(struct hrtimer_clock_base *base)
 static
 struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
                                             unsigned long *flags)
+       __acquires(&timer->base->lock)
 {
        struct hrtimer_clock_base *base;
 
@@ -280,6 +281,7 @@ static inline bool is_migration_base(struct hrtimer_clock_base *base)
 
 static inline struct hrtimer_clock_base *
 lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
+       __acquires(&timer->base->cpu_base->lock)
 {
        struct hrtimer_clock_base *base = timer->base;
 
@@ -1013,6 +1015,7 @@ void hrtimers_resume_local(void)
  */
 static inline
 void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
+       __releases(&timer->base->cpu_base->lock)
 {
        raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags);
 }