linux-stable/kernel/time
Sebastian Andrzej Siewior c401368926 tick/common: Align tick period with the HZ tick.
[ Upstream commit e9523a0d81 ]

With HIGHRES enabled tick_sched_timer() is programmed every jiffy to
expire the timer_list timers. This timer is programmed accurate in
respect to CLOCK_MONOTONIC so that 0 seconds and nanoseconds is the
first tick and the next one is 1000/CONFIG_HZ ms later. For HZ=250 it is
every 4 ms and so based on the current time the next tick can be
computed.

This accuracy broke since the commit mentioned below because the jiffy
based clocksource is initialized with higher accuracy in
read_persistent_wall_and_boot_offset(). This higher accuracy is
inherited during the setup in tick_setup_device(). The timer still fires
every 4ms with HZ=250 but timer is no longer aligned with
CLOCK_MONOTONIC with 0 as it origin but has an offset in the us/ns part
of the timestamp. The offset differs with every boot and makes it
impossible for user land to align with the tick.

Align the tick period with CLOCK_MONOTONIC ensuring that it is always a
multiple of 1000/CONFIG_HZ ms.

Fixes: 857baa87b6 ("sched/clock: Enable sched clock early")
Reported-by: Gusenleitner Klaus <gus@keba.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/20230406095735.0_14edn3@linutronix.de
Link: https://lore.kernel.org/r/20230418122639.ikgfvu3f@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-17 11:47:46 +02:00
..
alarmtimer.c alarmtimer: Prevent starvation by small intervals and SIG_IGN 2023-02-22 12:55:59 +01:00
clockevents.c
clocksource.c clocksource: Suspend the watchdog temporarily when high read latency detected 2023-03-11 16:39:50 +01:00
hrtimer.c timers: Prevent union confusion from unexpected restart_syscall() 2023-03-11 16:39:49 +01:00
itimer.c time: Prevent undefined behaviour in timespec64_to_ns() 2020-10-26 11:48:11 +01:00
jiffies.c clocksource: Reduce clocksource-skew threshold 2022-01-27 10:54:05 +01:00
Kconfig posix-cpu-timers: Provide mechanisms to defer timer handling to task_work 2020-08-06 16:50:59 +02:00
Makefile
namespace.c nsproxy: support CLONE_NEWTIME with setns() 2020-07-08 11:14:22 +02:00
ntp.c
ntp_internal.h
posix-clock.c
posix-cpu-timers.c posix-cpu-timers: Implement the missing timer_wait_running callback 2023-05-17 11:47:31 +02:00
posix-stubs.c timers: Prevent union confusion from unexpected restart_syscall() 2023-03-11 16:39:49 +01:00
posix-timers.c posix-cpu-timers: Implement the missing timer_wait_running callback 2023-05-17 11:47:31 +02:00
posix-timers.h
sched_clock.c time/sched_clock: Mark sched_clock_read_begin/retry() as notrace 2020-10-26 11:34:31 +01:00
test_udelay.c
tick-broadcast-hrtimer.c
tick-broadcast.c tick: Get rid of tick_period 2023-05-17 11:47:46 +02:00
tick-common.c tick/common: Align tick period with the HZ tick. 2023-05-17 11:47:46 +02:00
tick-internal.h tick: Get rid of tick_period 2023-05-17 11:47:46 +02:00
tick-oneshot.c
tick-sched.c tick: Get rid of tick_period 2023-05-17 11:47:46 +02:00
tick-sched.h
time.c
timeconst.bc
timeconv.c
timecounter.c
timekeeping.c timekeeping: contribute wall clock to rng on time change 2022-08-21 15:16:20 +02:00
timekeeping.h
timekeeping_debug.c
timekeeping_internal.h timekeeping/vsyscall: Provide vdso_update_begin/end() 2020-08-06 10:57:30 +02:00
timer.c timers: Fix warning condition in __run_timers() 2022-04-20 09:23:30 +02:00
timer_list.c
vsyscall.c timekeeping/vsyscall: Provide vdso_update_begin/end() 2020-08-06 10:57:30 +02:00