mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
vdso/vsyscall: Avoid slow division loop in auxiliary clock update
The call to __iter_div_u64_rem() in vdso_time_update_aux() is a wrapper
around subtraction. It cannot be used to divide large numbers, as that
introduces long, computationally expensive delays. A regular u64 division
is also not possible in the timekeeper update path as it can be too slow.
Instead of splitting the ktime_t offset into into second and subsecond
components during the timekeeper update fast-path, do it together with the
adjustment of tk->offs_aux in the slow-path. Equivalent to the handling of
offs_boot and monotonic_to_boot.
Reuse the storage of monotonic_to_boot for the new field, as it is not used
by auxiliary timekeepers.
Fixes: 380b84e168 ("vdso/vsyscall: Update auxiliary clock data in the datapage")
Reported-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250825-vdso-auxclock-division-v1-1-a1d32a16a313@linutronix.de
Closes: https://lore.kernel.org/lkml/aKwsNNWsHJg8IKzj@localhost/
This commit is contained in:
committed by
Thomas Gleixner
parent
b320789d68
commit
762af5a2aa
@@ -76,6 +76,7 @@ struct tk_read_base {
|
||||
* @cs_was_changed_seq: The sequence number of clocksource change events
|
||||
* @clock_valid: Indicator for valid clock
|
||||
* @monotonic_to_boot: CLOCK_MONOTONIC to CLOCK_BOOTTIME offset
|
||||
* @monotonic_to_aux: CLOCK_MONOTONIC to CLOCK_AUX offset
|
||||
* @cycle_interval: Number of clock cycles in one NTP interval
|
||||
* @xtime_interval: Number of clock shifted nano seconds in one NTP
|
||||
* interval.
|
||||
@@ -117,6 +118,9 @@ struct tk_read_base {
|
||||
* @offs_aux is used by the auxiliary timekeepers which do not utilize any
|
||||
* of the regular timekeeper offset fields.
|
||||
*
|
||||
* @monotonic_to_aux is a timespec64 representation of @offs_aux to
|
||||
* accelerate the VDSO update for CLOCK_AUX.
|
||||
*
|
||||
* The cacheline ordering of the structure is optimized for in kernel usage of
|
||||
* the ktime_get() and ktime_get_ts64() family of time accessors. Struct
|
||||
* timekeeper is prepended in the core timekeeping code with a sequence count,
|
||||
@@ -159,7 +163,10 @@ struct timekeeper {
|
||||
u8 cs_was_changed_seq;
|
||||
u8 clock_valid;
|
||||
|
||||
struct timespec64 monotonic_to_boot;
|
||||
union {
|
||||
struct timespec64 monotonic_to_boot;
|
||||
struct timespec64 monotonic_to_aux;
|
||||
};
|
||||
|
||||
u64 cycle_interval;
|
||||
u64 xtime_interval;
|
||||
|
||||
Reference in New Issue
Block a user