diff options
author | Paul E. McKenney <paulmck@kernel.org> | 2021-08-12 18:31:28 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2021-08-28 17:01:32 +0200 |
commit | d25a025201ed98f4b93775e0999a3f2135702106 (patch) | |
tree | 2fcc4adf70cf9f897619f188db2dc97392667139 /kernel/time/tick-internal.h | |
parent | Merge tag 'timers-v5.15' of https://git.linaro.org/people/daniel.lezcano/linu... (diff) | |
download | linux-d25a025201ed98f4b93775e0999a3f2135702106.tar.xz linux-d25a025201ed98f4b93775e0999a3f2135702106.zip |
clocksource: Make clocksource watchdog test safe for slow-HZ systems
The clocksource watchdog test sets a local JIFFIES_SHIFT macro and assumes
that HZ is >= 100. For smaller HZ values this shift value is too large and
causes undefined behaviour.
Move the HZ-based definitions of JIFFIES_SHIFT from kernel/time/jiffies.c
to kernel/time/tick-internal.h so the clocksource watchdog test can utilize
them, which makes it work correctly with all HZ values.
[ tglx: Resolved conflicts and massaged changelog ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/lkml/20210812000133.GA402890@paulmck-ThinkPad-P17-Gen-1/
Diffstat (limited to 'kernel/time/tick-internal.h')
-rw-r--r-- | kernel/time/tick-internal.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index 3548f0829e6d..649f2b48e8f0 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h @@ -177,3 +177,23 @@ void clock_was_set(unsigned int bases); void clock_was_set_delayed(void); void hrtimers_resume_local(void); + +/* Since jiffies uses a simple TICK_NSEC multiplier + * conversion, the .shift value could be zero. However + * this would make NTP adjustments impossible as they are + * in units of 1/2^.shift. Thus we use JIFFIES_SHIFT to + * shift both the nominator and denominator the same + * amount, and give ntp adjustments in units of 1/2^8 + * + * The value 8 is somewhat carefully chosen, as anything + * larger can result in overflows. TICK_NSEC grows as HZ + * shrinks, so values greater than 8 overflow 32bits when + * HZ=100. + */ +#if HZ < 34 +#define JIFFIES_SHIFT 6 +#elif HZ < 67 +#define JIFFIES_SHIFT 7 +#else +#define JIFFIES_SHIFT 8 +#endif |