Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

time/sched_clock: Expire timer in hardirq context

To minimize latency, PREEMPT_RT kernels expires hrtimers in preemptible
softirq context by default. This can be overriden by marking the timer's
expiry with HRTIMER_MODE_HARD.

sched_clock_timer is missing this annotation: if its callback is preempted
and the duration of the preemption exceeds the wrap around time of the
underlying clocksource, sched clock will get out of sync.

Mark the sched_clock_timer for expiry in hard interrupt context.

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200309181529.26558-1-a.darwish@linutronix.de

authored by

Ahmed S. Darwish and committed by
Thomas Gleixner
2c8bd588 048495eb

+5 -4
+5 -4
kernel/time/sched_clock.c
··· 208 208 209 209 if (sched_clock_timer.function != NULL) { 210 210 /* update timeout for clock wrap */ 211 - hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); 211 + hrtimer_start(&sched_clock_timer, cd.wrap_kt, 212 + HRTIMER_MODE_REL_HARD); 212 213 } 213 214 214 215 r = rate; ··· 255 254 * Start the timer to keep sched_clock() properly updated and 256 255 * sets the initial epoch. 257 256 */ 258 - hrtimer_init(&sched_clock_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 257 + hrtimer_init(&sched_clock_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 259 258 sched_clock_timer.function = sched_clock_poll; 260 - hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); 259 + hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD); 261 260 } 262 261 263 262 /* ··· 294 293 struct clock_read_data *rd = &cd.read_data[0]; 295 294 296 295 rd->epoch_cyc = cd.actual_read_sched_clock(); 297 - hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); 296 + hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD); 298 297 rd->read_sched_clock = cd.actual_read_sched_clock; 299 298 } 300 299