From: Miroslav Lichvar <mlichvar@redhat.com>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, jstultz@google.com
Subject: Re: CLOCK_AUX stepping
Date: Mon, 25 Aug 2025 12:45:29 +0200 [thread overview]
Message-ID: <aKw-yTq3jMeku5yG@localhost> (raw)
In-Reply-To: <20250825121415-a748d95f-7cfd-4d28-be56-dc0addc27ff1@linutronix.de>
On Mon, Aug 25, 2025 at 12:22:34PM +0200, Thomas Weißschuh wrote:
> 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?
The patch fixes the problem for me. Thanks.
> 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
>
--
Miroslav Lichvar
prev parent reply other threads:[~2025-08-25 10:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-25 9:26 CLOCK_AUX stepping Miroslav Lichvar
2025-08-25 10:22 ` Thomas Weißschuh
2025-08-25 10:45 ` Miroslav Lichvar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aKw-yTq3jMeku5yG@localhost \
--to=mlichvar@redhat.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=thomas.weissschuh@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.