Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@orcam.me.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2204240055590.9383@angie.orcam.me.uk

authored by

Maciej W. Rozycki and committed by
Thomas Gleixner
92067440 90be8d6c

+3 -2
+3 -2
kernel/time/sched_clock.c
··· 8 8 #include <linux/jiffies.h> 9 9 #include <linux/ktime.h> 10 10 #include <linux/kernel.h> 11 + #include <linux/math.h> 11 12 #include <linux/moduleparam.h> 12 13 #include <linux/sched.h> 13 14 #include <linux/sched/clock.h> ··· 200 199 201 200 r = rate; 202 201 if (r >= 4000000) { 203 - r /= 1000000; 202 + r = DIV_ROUND_CLOSEST(r, 1000000); 204 203 r_unit = 'M'; 205 204 } else { 206 205 if (r >= 1000) { 207 - r /= 1000; 206 + r = DIV_ROUND_CLOSEST(r, 1000); 208 207 r_unit = 'k'; 209 208 } else { 210 209 r_unit = ' ';