Merge tag 'timers-urgent-2025-04-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull misc timer fixes from Ingo Molnar:

 - Fix missing ACCESS_PRIVATE() that triggered a Sparse warning

 - Fix lockdep false positive in tick_freeze() on CONFIG_PREEMPT_RT=y

 - Avoid <vdso/unaligned.h> macro's variable shadowing to address build
   warning that triggers under W=2 builds

* tag 'timers-urgent-2025-04-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  vdso: Address variable shadowing in macros
  timekeeping: Add a lockdep override in tick_freeze()
  hrtimer: Add missing ACCESS_PRIVATE() for hrtimer::function
This commit is contained in:
Linus Torvalds
2025-04-10 15:39:39 -07:00
4 changed files with 30 additions and 8 deletions
+1 -1
View File
@@ -345,7 +345,7 @@ static inline void hrtimer_update_function(struct hrtimer *timer,
if (WARN_ON_ONCE(!function))
return;
#endif
timer->function = function;
ACCESS_PRIVATE(timer, function) = function;
}
/* Forward a hrtimer so it expires after now: */
+6 -6
View File
@@ -2,14 +2,14 @@
#ifndef __VDSO_UNALIGNED_H
#define __VDSO_UNALIGNED_H
#define __get_unaligned_t(type, ptr) ({ \
const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \
__pptr->x; \
#define __get_unaligned_t(type, ptr) ({ \
const struct { type x; } __packed * __get_pptr = (typeof(__get_pptr))(ptr); \
__get_pptr->x; \
})
#define __put_unaligned_t(type, val, ptr) do { \
struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \
__pptr->x = (val); \
#define __put_unaligned_t(type, val, ptr) do { \
struct { type x; } __packed * __put_pptr = (typeof(__put_pptr))(ptr); \
__put_pptr->x = (val); \
} while (0)
#endif /* __VDSO_UNALIGNED_H */
+1 -1
View File
@@ -366,7 +366,7 @@ static const struct debug_obj_descr hrtimer_debug_descr;
static void *hrtimer_debug_hint(void *addr)
{
return ((struct hrtimer *) addr)->function;
return ACCESS_PRIVATE((struct hrtimer *)addr, function);
}
/*
+22
View File
@@ -509,6 +509,7 @@ void tick_resume(void)
#ifdef CONFIG_SUSPEND
static DEFINE_RAW_SPINLOCK(tick_freeze_lock);
static DEFINE_WAIT_OVERRIDE_MAP(tick_freeze_map, LD_WAIT_SLEEP);
static unsigned int tick_freeze_depth;
/**
@@ -528,9 +529,22 @@ void tick_freeze(void)
if (tick_freeze_depth == num_online_cpus()) {
trace_suspend_resume(TPS("timekeeping_freeze"),
smp_processor_id(), true);
/*
* All other CPUs have their interrupts disabled and are
* suspended to idle. Other tasks have been frozen so there
* is no scheduling happening. This means that there is no
* concurrency in the system at this point. Therefore it is
* okay to acquire a sleeping lock on PREEMPT_RT, such as a
* spinlock, because the lock cannot be held by other CPUs
* or threads and acquiring it cannot block.
*
* Inform lockdep about the situation.
*/
lock_map_acquire_try(&tick_freeze_map);
system_state = SYSTEM_SUSPEND;
sched_clock_suspend();
timekeeping_suspend();
lock_map_release(&tick_freeze_map);
} else {
tick_suspend_local();
}
@@ -552,8 +566,16 @@ void tick_unfreeze(void)
raw_spin_lock(&tick_freeze_lock);
if (tick_freeze_depth == num_online_cpus()) {
/*
* Similar to tick_freeze(). On resumption the first CPU may
* acquire uncontended sleeping locks while other CPUs block on
* tick_freeze_lock.
*/
lock_map_acquire_try(&tick_freeze_map);
timekeeping_resume();
sched_clock_resume();
lock_map_release(&tick_freeze_map);
system_state = SYSTEM_RUNNING;
trace_suspend_resume(TPS("timekeeping_freeze"),
smp_processor_id(), false);