summaryrefslogtreecommitdiff
path: root/kernel/time/clocksource.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2024-03-25 08:40:21 +0200
committerThomas Gleixner <tglx@linutronix.de>2024-04-08 15:03:08 +0200
commitfcf190c369149c3b04539797cedf28741eb14164 (patch)
tree9a2860f6c895ca93b5247686cd47b0617f778f2c /kernel/time/clocksource.c
parente809a80aa0bcf802f99407c23fd6be6fd4eb250a (diff)
timekeeping: Make delta calculation overflow safe
Kernel timekeeping is designed to keep the change in cycles (since the last timer interrupt) below max_cycles, which prevents multiplication overflow when converting cycles to nanoseconds. However, if timer interrupts stop, the calculation will eventually overflow. Add protection against that. In timekeeping_cycles_to_ns() calculation, check against max_cycles, falling back to a slower higher precision calculation. In timekeeping_forward_now(), process delta in chunks of at most max_cycles. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20240325064023.2997-18-adrian.hunter@intel.com
Diffstat (limited to 'kernel/time/clocksource.c')
0 files changed, 0 insertions, 0 deletions