From: Petr Tesarik <ptesarik@suse.com>
To: Thorsten Blum <blum@kernel.org>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Hans Peter Anvin <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Juergen Gross <jgross@suse.com>,
linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH 1/3] x86/tsc: Replace magic constants with xxx_PER_SEC
Date: Mon, 12 Oct 2026 08:16:51 +0200 [thread overview]
Message-ID: <20261012081651.355a5bb2@mordecai> (raw)
In-Reply-To: <asjuNlFdLGsNUJh9@kernel.org>
On Fri, 9 Oct 2026 15:37:58 +0200
Thorsten Blum <blum@kernel.org> wrote:
> On Fri, Oct 09, 2026 at 12:04:34PM +0200, Petr Tesarik wrote:
> > Make it clear that these constants refer to the conversion between seconds
> > and milliseconds or nanoseconds.
> >
> > No functional change intended.
> >
> > Signed-off-by: Petr Tesarik <ptesarik@suse.com>
> > ---
> > arch/x86/kernel/tsc.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> > index 723347e2cf7f8..bac81d37a90ce 100644
> > --- a/arch/x86/kernel/tsc.c
> > +++ b/arch/x86/kernel/tsc.c
> > @@ -253,7 +253,7 @@ noinstr u64 native_sched_clock(void)
> > */
> >
> > /* No locking but a rare wrong value is not a big deal: */
> > - return (jiffies_64 - INITIAL_JIFFIES) * (1000000000 / HZ);
> > + return (jiffies_64 - INITIAL_JIFFIES) * (NSEC_PER_SEC / HZ);
> > }
>
> Maybe use TICK_NSEC here?
Note that the current code always rounds down. TICK_NSEC rounds to the
nearest integer, but since it makes no difference for any possible
value of HZ (100, 250, 300, 1000), I'm going to go for it anyway.
That said, there are other occurences of NSEC_PER_SEC / HZ in the
kernel, so I'm going to clean them up too (in a separate patch).
Thank you!
Petr T
next prev parent reply other threads:[~2026-10-12 6:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 10:04 [PATCH 0/3] x86/tsc: Remove some magic constants Petr Tesarik
2026-10-09 10:04 ` [PATCH 1/3] x86/tsc: Replace magic constants with xxx_PER_SEC Petr Tesarik
2026-10-09 13:37 ` Thorsten Blum
2026-10-12 6:16 ` Petr Tesarik [this message]
2026-10-09 10:04 ` [PATCH 2/3] x86/tsc: Define and use HZ_PER_KHZ and KHZ_PER_MHZ Petr Tesarik
2026-10-09 13:42 ` Thorsten Blum
2026-10-12 6:06 ` Petr Tesarik
2026-10-09 10:04 ` [PATCH 3/3] x86/tsc: Use TSC_CALIBRATE_MULT for the TSC multiplier Petr Tesarik
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=20261012081651.355a5bb2@mordecai \
--to=ptesarik@suse.com \
--cc=blum@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/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®