[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250825121415-a748d95f-7cfd-4d28-be56-dc0addc27ff1@linutronix.de>
Date: Mon, 25 Aug 2025 12:22:34 +0200
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Miroslav Lichvar <mlichvar@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
john.stultz@...aro.org
Subject: Re: CLOCK_AUX stepping
Hi Miroslav,
thanks for the report.
On Mon, Aug 25, 2025 at 11:26:12AM +0200, Miroslav Lichvar wrote:
> There is an issue with the new system auxiliary clocks. When I make
> a larger step of a CLOCK_AUX clock (by clock_settime() or
> adjtimex(ADJ_SETOFFSET)), the system slows down significantly to
> almost being unusable. This didn't happen with the original
> tglx/timers/ptp/driver-auxclock branch, but happens with 6.17-rc1
> and later.
>
> Reproducer:
> - echo 1 > /sys/kernel/time/aux_clocks/0/aux_clock_enable
> - git clone -b staging https://github.com/mlichvar/linuxptp.git
> - cd linuxptp && make
> - ./phc_ctl CLOCK_AUX0 set
>
> "echo 0 > .../aux_clock_enable" revives the system.
For high offsets we are stuck looping in __iter_div_u64().
As far as I know, doing regular divisions in the timekeeping hot patch are
problematic on some architectures, so instead of storing the offset as a
single ktime_t, we might need to switch to 'struct timespec64' and do the
division on clock adjustments.
Can you try the following patch for now?
diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c
index 8ba8b0d8a387..8190e9dc6569 100644
--- a/kernel/time/vsyscall.c
+++ b/kernel/time/vsyscall.c
@@ -8,6 +8,7 @@
*/
#include <linux/hrtimer.h>
+#include <linux/math64.h>
#include <linux/timekeeper_internal.h>
#include <vdso/datapage.h>
#include <vdso/helpers.h>
@@ -143,6 +144,7 @@ void vdso_time_update_aux(struct timekeeper *tk)
struct vdso_timestamp *vdso_ts;
struct vdso_clock *vc;
s32 clock_mode;
+ u32 nsec32;
u64 nsec;
vc = &vdata->aux_clock_data[tk->id - TIMEKEEPER_AUX_FIRST];
@@ -163,7 +165,8 @@ void vdso_time_update_aux(struct timekeeper *tk)
nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift;
nsec += tk->offs_aux;
- vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &nsec);
+ vdso_ts->sec += div_u64_rem(nsec, NSEC_PER_SEC, &nsec32);
+ nsec = nsec32;
nsec = nsec << tk->tkr_mono.shift;
vdso_ts->nsec = nsec;
}
Thomas
Powered by blists - more mailing lists