From: David Laight <david.laight.linux@gmail.com>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Zhan Xusheng <zhanxusheng1024@gmail.com>,
tglx@kernel.org, luto@kernel.org, vincenzo.frascino@arm.com,
linux-kernel@vger.kernel.org, zhanxusheng@xiaomi.com
Subject: Re: [PATCH v3 1/3] vdso/math64: Add and use __iter_div64_u64_rem()
Date: Tue, 1 Sep 2026 13:48:20 +0100 [thread overview]
Message-ID: <20260901134820.0c5b820b@pumpkin> (raw)
In-Reply-To: <20260901102036-f5a7282d-4d8f-4f4a-89b3-7a75c83582c0@linutronix.de>
On Tue, 1 Sep 2026 10:35:30 +0200
Thomas Weißschuh <thomas.weissschuh@linutronix.de> wrote:
> Hi Zhan,
>
> thanks for the new version. However please slow down a bit with sending new
> revisions to give people time to respond.
>
> On Tue, Sep 01, 2026 at 10:06:34AM +0800, Zhan Xusheng wrote:
> > The vDSO basetimes for CLOCK_MONOTONIC and CLOCK_BOOTTIME are kept in the
> > scaled nanoseconds of tkr_mono, so normalising them means dividing by
> > NSEC_PER_SEC << shift, which does not fit the u32 divisor of
> > __iter_div_u64_rem().
> >
> > update_vdso_time_data() therefore open-codes the iterative division twice.
> > Turning the loops into a plain modulo is not an option either, as the vDSO
> > has no 64-bit division helpers on 32-bit.
>
> This is not vDSO userspace code, but on the kernel side.
> The problem is that divisions are unnecessarily slow.
Until you get to (on x86) zen3 or cannon lake when they drop to ~15 clocks.
(I think someone finally allocated a bit of silicon to integer divide.)
> Also a module alone would not be enough, as we need the division result.
Isn't the divisor constant? (or rather a constant shifted left some).
In that case you can do a 'multiply by reciprocal'.
The simple 'multiply an shift right 32' will give slightly low quotient.
But you need to calculate the remainder - so can fixup the overlarge
remainder it can generate.
Of course, even that is only worthwhile if the quotient is more than
(a guess) 4.
David
next prev parent reply other threads:[~2026-09-01 12:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 2:06 [PATCH v3 0/3] vdso: Keep the CLOCK_AUX base at full precision Zhan Xusheng
2026-09-01 2:06 ` [PATCH v3 1/3] vdso/math64: Add and use __iter_div64_u64_rem() Zhan Xusheng
2026-09-01 8:35 ` Thomas Weißschuh
2026-09-01 12:48 ` David Laight [this message]
2026-09-01 13:05 ` Thomas Weißschuh
2026-09-01 2:06 ` [PATCH v3 2/3] vdso/vsyscall: Keep the CLOCK_AUX base scaled Zhan Xusheng
2026-09-01 8:42 ` Thomas Weißschuh
2026-09-01 2:06 ` [PATCH v3 3/3] vdso/gettimeofday: Assert that the clock id fits the dispatch mask Zhan Xusheng
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=20260901134820.0c5b820b@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=vincenzo.frascino@arm.com \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®