linux-stable/kernel/time
Jason A. Donenfeld 8776be6e6f wireguard: ratelimiter: use hrtimer in selftest
[ Upstream commit 151c8e499f ]

Using msleep() is problematic because it's compared against
ratelimiter.c's ktime_get_coarse_boottime_ns(), which means on systems
with slow jiffies (such as UML's forced HZ=100), the result is
inaccurate. So switch to using schedule_hrtimeout().

However, hrtimer gives us access only to the traditional posix timers,
and none of the _COARSE variants. So now, rather than being too
imprecise like jiffies, it's too precise.

One solution would be to give it a large "range" value, but this will
still fire early on a loaded system. A better solution is to align the
timeout to the actual coarse timer, and then round up to the nearest
tick, plus change.

So add the timeout to the current coarse time, and then
schedule_hrtimer() until the absolute computed time.

This should hopefully reduce flakes in CI as well. Note that we keep the
retry loop in case the entire function is running behind, because the
test could still be scheduled out, by either the kernel or by the
hypervisor's kernel, in which case restarting the test and hoping to not
be scheduled out still helps.

Fixes: e7096c131e ("net: WireGuard secure network tunnel")
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-17 14:41:16 +02:00
..
alarmtimer.c alarmtimer: Check RTC features instead of ops 2021-05-11 21:28:04 +02:00
clockevents.c clockevents: Use list_move() instead of list_del()/list_add() 2021-06-22 17:16:46 +02:00
clocksource-wdtest.c clocksource: Make clocksource watchdog test safe for slow-HZ systems 2021-08-28 17:01:32 +02:00
clocksource.c clocksource: Add a Kconfig option for WATCHDOG_MAX_SKEW 2022-02-01 17:35:43 -08:00
hrtimer.c wireguard: ratelimiter: use hrtimer in selftest 2022-08-17 14:41:16 +02:00
itimer.c
jiffies.c clocksource: Make clocksource watchdog test safe for slow-HZ systems 2021-08-28 17:01:32 +02:00
Kconfig clocksource: Add a Kconfig option for WATCHDOG_MAX_SKEW 2022-02-01 17:35:43 -08:00
Makefile time: Improve performance of time64_to_tm() 2021-06-24 11:51:59 +02:00
namespace.c memcg: enable accounting for new namesapces and struct nsproxy 2021-09-03 09:58:12 -07:00
ntp.c
ntp_internal.h
posix-clock.c
posix-cpu-timers.c ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
posix-stubs.c
posix-timers.c fix race between exit_itimers() and /proc/pid/timers 2022-07-22 10:21:18 +02:00
posix-timers.h
sched_clock.c
test_udelay.c
tick-broadcast-hrtimer.c
tick-broadcast.c timer_list: Print name of per-cpu wakeup device 2021-05-31 17:04:49 +02:00
tick-common.c timekeeping: Distangle resume and clock-was-set events 2021-08-10 17:57:23 +02:00
tick-internal.h clocksource: Make clocksource watchdog test safe for slow-HZ systems 2021-08-28 17:01:32 +02:00
tick-legacy.c
tick-oneshot.c
tick-sched.c tick/nohz: unexport __init-annotated tick_nohz_full_setup() 2022-07-02 16:44:55 +02:00
tick-sched.h tick: Detect and fix jiffies update stall 2022-03-07 23:01:19 +01:00
time.c
time_test.c time/kunit: Add missing MODULE_LICENSE() 2021-06-28 07:40:23 +02:00
timeconst.bc
timeconv.c time: Improve performance of time64_to_tm() 2021-06-24 11:51:59 +02:00
timecounter.c
timekeeping.c timekeeping: Add raw clock fallback for random_get_entropy() 2022-05-30 09:24:04 +02:00
timekeeping.h
timekeeping_debug.c
timekeeping_internal.h
timer.c timers: Fix warning condition in __run_timers() 2022-04-09 22:17:47 +02:00
timer_list.c timer_list: Print name of per-cpu wakeup device 2021-05-31 17:04:49 +02:00
vsyscall.c