Skip to content

Commit c5448d4

Browse files
committed
Merge tag 'timers-core-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer core updates from Thomas Gleixner: - Address the inconsistent shutdown sequence of per CPU clockevents on CPU hotplug, which only removed it from the core but failed to invoke the actual device driver shutdown callback. This kept the timer active, which prevented power savings and caused pointless noise in virtualization. - Encapsulate the open coded access to the hrtimer clock base, which is a private implementation detail, so that the implementation can be changed without breaking a lot of usage sites. - Enhance the debug output of the clocksource watchdog to provide better information for analysis. - The usual set of cleanups and enhancements all over the place * tag 'timers-core-2025-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: time: Fix spelling mistakes in comments clocksource: Print durations for sync check unconditionally LoongArch: Remove clockevents shutdown call on offlining tick: Do not set device to detached state in tick_shutdown() hrtimer: Reorder branches in hrtimer_clockid_to_base() hrtimer: Remove hrtimer_clock_base:: Get_time hrtimer: Use hrtimer_cb_get_time() helper media: pwm-ir-tx: Avoid direct access to hrtimer clockbase ALSA: hrtimer: Avoid direct access to hrtimer clockbase lib: test_objpool: Avoid direct access to hrtimer clockbase sched/core: Avoid direct access to hrtimer clockbase timers/itimer: Avoid direct access to hrtimer clockbase posix-timers: Avoid direct access to hrtimer clockbase jiffies: Remove obsolete SHIFTED_HZ comment
2 parents c574fb2 + 391253b commit c5448d4

File tree

19 files changed

+54
-62
lines changed

19 files changed

+54
-62
lines changed

arch/loongarch/kernel/time.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ static int arch_timer_starting(unsigned int cpu)
112112

113113
static int arch_timer_dying(unsigned int cpu)
114114
{
115-
constant_set_state_shutdown(this_cpu_ptr(&constant_clockevent_device));
116-
117115
/* Clear Timer Interrupt */
118116
write_csr_tintclear(CSR_TINTCLR_TI);
119117

drivers/media/rc/pwm-ir-tx.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ static int pwm_ir_tx_atomic(struct rc_dev *dev, unsigned int *txbuf,
117117
static enum hrtimer_restart pwm_ir_timer(struct hrtimer *timer)
118118
{
119119
struct pwm_ir *pwm_ir = container_of(timer, struct pwm_ir, timer);
120-
ktime_t now;
121120

122121
/*
123122
* If we happen to hit an odd latency spike, loop through the
@@ -139,9 +138,7 @@ static enum hrtimer_restart pwm_ir_timer(struct hrtimer *timer)
139138
hrtimer_add_expires_ns(timer, ns);
140139

141140
pwm_ir->txbuf_index++;
142-
143-
now = timer->base->get_time();
144-
} while (hrtimer_get_expires_tv64(timer) < now);
141+
} while (hrtimer_expires_remaining(timer) > 0);
145142

146143
return HRTIMER_RESTART;
147144
}

include/linux/hrtimer.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,11 @@ static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
154154
return ktime_to_ns(timer->node.expires);
155155
}
156156

157-
static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
158-
{
159-
return ktime_sub(timer->node.expires, timer->base->get_time());
160-
}
157+
ktime_t hrtimer_cb_get_time(const struct hrtimer *timer);
161158

162-
static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)
159+
static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
163160
{
164-
return timer->base->get_time();
161+
return ktime_sub(timer->node.expires, hrtimer_cb_get_time(timer));
165162
}
166163

167164
static inline int hrtimer_is_hres_active(struct hrtimer *timer)
@@ -200,8 +197,7 @@ __hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now)
200197
static inline ktime_t
201198
hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
202199
{
203-
return __hrtimer_expires_remaining_adjusted(timer,
204-
timer->base->get_time());
200+
return __hrtimer_expires_remaining_adjusted(timer, hrtimer_cb_get_time(timer));
205201
}
206202

207203
#ifdef CONFIG_TIMERFD
@@ -363,7 +359,7 @@ hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
363359
static inline u64 hrtimer_forward_now(struct hrtimer *timer,
364360
ktime_t interval)
365361
{
366-
return hrtimer_forward(timer, timer->base->get_time(), interval);
362+
return hrtimer_forward(timer, hrtimer_cb_get_time(timer), interval);
367363
}
368364

369365
/* Precise sleep: */

include/linux/hrtimer_defs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
* @seq: seqcount around __run_hrtimer
4242
* @running: pointer to the currently running hrtimer
4343
* @active: red black tree root node for the active timers
44-
* @get_time: function to retrieve the current time of the clock
4544
* @offset: offset of this clock to the monotonic base
4645
*/
4746
struct hrtimer_clock_base {
@@ -51,7 +50,6 @@ struct hrtimer_clock_base {
5150
seqcount_raw_spinlock_t seq;
5251
struct hrtimer *running;
5352
struct timerqueue_head active;
54-
ktime_t (*get_time)(void);
5553
ktime_t offset;
5654
} __hrtimer_clock_base_align;
5755

include/linux/jiffies.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
extern void register_refined_jiffies(long clock_tick_rate);
6363

64-
/* TICK_USEC is the time between ticks in usec assuming SHIFTED_HZ */
64+
/* TICK_USEC is the time between ticks in usec */
6565
#define TICK_USEC ((USEC_PER_SEC + HZ/2) / HZ)
6666

6767
/* USER_TICK_USEC is the time between ticks in usec assuming fake USER_HZ */

include/vdso/jiffies.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <asm/param.h> /* for HZ */
66
#include <vdso/time64.h>
77

8-
/* TICK_NSEC is the time between ticks in nsec assuming SHIFTED_HZ */
8+
/* TICK_NSEC is the time between ticks in nsec */
99
#define TICK_NSEC ((NSEC_PER_SEC+HZ/2)/HZ)
1010

1111
#endif /* __VDSO_JIFFIES_H */

kernel/sched/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ void hrtick_start(struct rq *rq, u64 delay)
919919
* doesn't make sense and can cause timer DoS.
920920
*/
921921
delta = max_t(s64, delay, 10000LL);
922-
rq->hrtick_time = ktime_add_ns(timer->base->get_time(), delta);
922+
rq->hrtick_time = ktime_add_ns(hrtimer_cb_get_time(timer), delta);
923923

924924
if (rq == this_rq())
925925
__hrtick_restart(rq);

kernel/time/alarmtimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
/**
3737
* struct alarm_base - Alarm timer bases
38-
* @lock: Lock for syncrhonized access to the base
38+
* @lock: Lock for synchronized access to the base
3939
* @timerqueue: Timerqueue head managing the list of events
4040
* @get_ktime: Function to read the time correlating to the base
4141
* @get_timespec: Function to read the namespace time correlating to the base

kernel/time/clockevents.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ void tick_offline_cpu(unsigned int cpu)
633633
raw_spin_lock(&clockevents_lock);
634634

635635
tick_broadcast_offline(cpu);
636-
tick_shutdown(cpu);
636+
tick_shutdown();
637637

638638
/*
639639
* Unregister the clock event devices which were

kernel/time/clocksource.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static u64 suspend_start;
144144
* Default for maximum permissible skew when cs->uncertainty_margin is
145145
* not specified, and the lower bound even when cs->uncertainty_margin
146146
* is specified. This is also the default that is used when registering
147-
* clocks with unspecifed cs->uncertainty_margin, so this macro is used
147+
* clocks with unspecified cs->uncertainty_margin, so this macro is used
148148
* even in CONFIG_CLOCKSOURCE_WATCHDOG=n kernels.
149149
*/
150150
#define WATCHDOG_MAX_SKEW (MAX_SKEW_USEC * NSEC_PER_USEC)
@@ -407,9 +407,8 @@ void clocksource_verify_percpu(struct clocksource *cs)
407407
if (!cpumask_empty(&cpus_behind))
408408
pr_warn(" CPUs %*pbl behind CPU %d for clocksource %s.\n",
409409
cpumask_pr_args(&cpus_behind), testcpu, cs->name);
410-
if (!cpumask_empty(&cpus_ahead) || !cpumask_empty(&cpus_behind))
411-
pr_warn(" CPU %d check durations %lldns - %lldns for clocksource %s.\n",
412-
testcpu, cs_nsec_min, cs_nsec_max, cs->name);
410+
pr_info(" CPU %d check durations %lldns - %lldns for clocksource %s.\n",
411+
testcpu, cs_nsec_min, cs_nsec_max, cs->name);
413412
}
414413
EXPORT_SYMBOL_GPL(clocksource_verify_percpu);
415414

0 commit comments

Comments
 (0)