All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@orcam.me.uk>
To: John Stultz <jstultz@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] sched_clock: Use Hz as the unit for clock rate reporting below 4kHz
Date: Sun, 24 Apr 2022 12:47:26 +0100 (BST)	[thread overview]
Message-ID: <alpine.DEB.2.21.2204240106380.9383@angie.orcam.me.uk> (raw)
In-Reply-To: <alpine.DEB.2.21.2204211556270.9383@angie.orcam.me.uk>

We have always used kHz as the unit for clock rates reported between 
1MHz (inclusive) and 4MHz (exclusive), e.g.:

riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [1]
clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns

This reduces the amount of data lost due to rounding, but hasn't been 
replicated for the kHz range when support was added for proper reporting 
of sub-kHz clock rates.  Take the same approach then for rates between 
1kHz (inclusive) and 4kHz (exclusive), also for consistency.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Fixes: 2f0778afac79 ("ARM: 7205/2: sched_clock: allow sched_clock to be selected at runtime")
---
Russell,

 Please correct me if I am wrong with my guess for the origin of the 4MHz 
boundary as there's no mention of it with your commit 112f38a4a316 ("ARM: 
sched_clock: provide common infrastructure for sched_clock()"), which is 
where this code has come from.

  Maciej
---
 kernel/time/sched_clock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

linux-sched-clock-rate-4khz.diff
Index: linux-macro/kernel/time/sched_clock.c
===================================================================
--- linux-macro.orig/kernel/time/sched_clock.c
+++ linux-macro/kernel/time/sched_clock.c
@@ -203,7 +203,7 @@ sched_clock_register(u64 (*read)(void),
 		r = DIV_ROUND_CLOSEST(r, 1000000);
 		r_unit = 'M';
 	} else {
-		if (r >= 1000) {
+		if (r >= 4000) {
 			r = DIV_ROUND_CLOSEST(r, 1000);
 			r_unit = 'k';
 		} else {

  parent reply	other threads:[~2022-04-24 11:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24 11:47 [PATCH 0/3] sched_clock: Fixes for frequency reporting Maciej W. Rozycki
2022-04-24 11:47 ` [PATCH 1/3] sched_clock: Round the frequency reported to nearest rather than down Maciej W. Rozycki
2022-04-26 20:38   ` John Stultz
2022-05-02 12:31   ` [tip: timers/core] time/sched_clock: " tip-bot2 for Maciej W. Rozycki
2022-04-24 11:47 ` Maciej W. Rozycki [this message]
2022-05-02 12:31   ` [tip: timers/core] time/sched_clock: Use Hz as the unit for clock rate reporting below 4kHz tip-bot2 for Maciej W. Rozycki
2022-04-24 11:47 ` [PATCH 3/3] sched_clock: Fix formatting of frequency reporting code Maciej W. Rozycki
2022-04-26 20:41   ` John Stultz
2022-05-02 12:31   ` [tip: timers/core] time/sched_clock: " tip-bot2 for Maciej W. Rozycki

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=alpine.DEB.2.21.2204240106380.9383@angie.orcam.me.uk \
    --to=macro@orcam.me.uk \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@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.