[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <165149469466.4207.13955503601048091435.tip-bot2@tip-bot2>
Date: Mon, 02 May 2022 12:31:34 -0000
From: "tip-bot2 for Maciej W. Rozycki" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Maciej W. Rozycki" <macro@...am.me.uk>,
Thomas Gleixner <tglx@...utronix.de>,
John Stultz <jstultz@...gle.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: timers/core] time/sched_clock: Round the frequency reported to
nearest rather than down
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 92067440f1311dfa4d77b57a9da6b3706f5da32e
Gitweb: https://git.kernel.org/tip/92067440f1311dfa4d77b57a9da6b3706f5da32e
Author: Maciej W. Rozycki <macro@...am.me.uk>
AuthorDate: Sun, 24 Apr 2022 12:47:20 +01:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Mon, 02 May 2022 14:29:04 +02:00
time/sched_clock: Round the frequency reported to nearest rather than down
The frequency reported for clock sources are rounded down, which gives
misleading figures, e.g.:
I/O ASIC clock frequency 24999480Hz
sched_clock: 32 bits at 24MHz, resolution 40ns, wraps every 85901132779ns
MIPS counter frequency 59998512Hz
sched_clock: 32 bits at 59MHz, resolution 16ns, wraps every 35792281591ns
Rounding to nearest is more adequate:
I/O ASIC clock frequency 24999664Hz
sched_clock: 32 bits at 25MHz, resolution 40ns, wraps every 85900499947ns
MIPS counter frequency 59999728Hz
sched_clock: 32 bits at 60MHz, resolution 16ns, wraps every 35791556599ns
Signed-off-by: Maciej W. Rozycki <macro@...am.me.uk>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Acked-by: John Stultz <jstultz@...gle.com>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2204240055590.9383@angie.orcam.me.uk
---
kernel/time/sched_clock.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index b1b9b12..ee07f3a 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -8,6 +8,7 @@
#include <linux/jiffies.h>
#include <linux/ktime.h>
#include <linux/kernel.h>
+#include <linux/math.h>
#include <linux/moduleparam.h>
#include <linux/sched.h>
#include <linux/sched/clock.h>
@@ -199,11 +200,11 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)
r = rate;
if (r >= 4000000) {
- r /= 1000000;
+ r = DIV_ROUND_CLOSEST(r, 1000000);
r_unit = 'M';
} else {
if (r >= 1000) {
- r /= 1000;
+ r = DIV_ROUND_CLOSEST(r, 1000);
r_unit = 'k';
} else {
r_unit = ' ';
Powered by blists - more mailing lists