Timekeeping updates to tip/timers/core for 4.6
Hey Thomas, Ingo,
Here's my somewhat truncated queue for 4.6. I was hoping to
get the cross-timestamp patchset from Christopher sent along, but he's got some last minute changes to address feedback from Andy, so I'm holding off.
If the response is good for that last change, I may try to send another set with those changes next week, but we're cutting it fairly close to -rc6, so I'll check with you before doing so.
So.. two tiny cleanup fixes is all for now.
Boring is good, right?
Let me know if you have any thoughts or objections.
thanks
-john
The following changes since commit 18558cae0272f8fd9647e69d3fec1565a7949865:
Linux 4.5-rc4 (2016-02-14 13:05:20 -0800)
are available in the git repository at:
https://git.linaro.org/people/john.stultz/linux.git fortglx/4.6/time
for you to fetch changes up to ea23c1da598bfd361af5cd769e292a9667ecb7ab:
jiffies: use CLOCKSOURCE_MASK instead of constant (2016-02-26 19:05:25 -0800)
----------------------------------------------------------------
Alexander Kuleshov (2):
clocksource: introduce clocksource_freq2mult()
jiffies: use CLOCKSOURCE_MASK instead of constant
include/linux/clocksource.h | 45 +++++++++++++++++++-------------------------- kernel/time/jiffies.c | 2 +- 2 files changed, 20 insertions(+), 27 deletions(-)
Alexander Kuleshov (2):
clocksource: introduce clocksource_freq2mult()
jiffies: use CLOCKSOURCE_MASK instead of constant
include/linux/clocksource.h | 45 +++++++++++++++++++-------------------------- kernel/time/jiffies.c | 2 +- 2 files changed, 20 insertions(+), 27 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 clocksource: introduce clocksource_freq2mult()
From: Alexander Kuleshov <[email protected]>
The clocksource_khz2mult() and clocksource_hz2mult() share similar code wihch calculates a mult from the given frequency. Both implementations in differ only in value of a frequency. This patch introduces the clocksource_freq2mult() helper with generic implementation of mult calculation to prevent code duplication.
--- include/linux/clocksource.h | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-)
include/linux/clocksource.h +19 -26
@@ -118,6 +118,23 @@ struct clocksource {/* simplify initialization of mask field */ #define CLOCKSOURCE_MASK (bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) +static inline u32 clocksource_freq2mult (u32 freq,u32 shift_constant,u64 from) +{ +/* freq = cyc/from +* mult/2^shift = ns/cyc +* mult = ns/cyc * 2^shift +* mult = from/freq * 2^shift +* mult = from * 2^shift / freq +* mult = (from<<shift) / freq +*/ +u64 tmp = ((u64 )from) << shift_constant; + + tmp += freq/2 ;/* round for do_div */ +do_div (tmp, freq); + +return (u32 )tmp; +} +/** * clocksource_khz2mult - calculates mult from khz and shift * @khz: Clocksource frequency in KHz
@@ -128,19 +145,7 @@ struct clocksource {*/ static inline u32 clocksource_khz2mult (u32 khz,u32 shift_constant) { -/* khz = cyc/(Million ns) -* mult/2^shift = ns/cyc -* mult = ns/cyc * 2^shift -* mult = 1Million/khz * 2^shift -* mult = 1000000 * 2^shift / khz -* mult = (1000000<<shift) / khz -*/ -u64 tmp = ((u64 )1000000 ) << shift_constant; - - tmp += khz/2 ;/* round for do_div */ -do_div (tmp, khz); - -return (u32 )tmp; +return clocksource_freq2mult (khz, shift_constant,NSEC_PER_MSEC ); }/**
@@ -154,19 +159,7 @@ static inline u32 clocksource_khz2mult(u32 khz, u32 shift_constant)*/ static inline u32 clocksource_hz2mult (u32 hz,u32 shift_constant) { -/* hz = cyc/(Billion ns) -* mult/2^shift = ns/cyc -* mult = ns/cyc * 2^shift -* mult = 1Billion/hz * 2^shift -* mult = 1000000000 * 2^shift / hz -* mult = (1000000000<<shift) / hz -*/ -u64 tmp = ((u64 )1000000000 ) << shift_constant; - - tmp += hz/2 ;/* round for do_div */ -do_div (tmp, hz); - -return (u32 )tmp; +return clocksource_freq2mult (hz, shift_constant,NSEC_PER_SEC ); }/**
Signature · 1 line
1.9.1
tip-bot for Alexander Kuleshov
merge bot[tip:timers/core] clocksource: Introduce clocksource_freq2mult()
clocksource: Introduce clocksource_freq2mult()
Commit-ID: 7aca0c07207385cca76025cc85231519935722b9 Gitweb: http://git.kernel.org/tip/7aca0c07207385cca76025cc85231519935722b9 Author: Alexander Kuleshov <[email protected]> AuthorDate: Fri, 26 Feb 2016 19:14:13 -0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 27 Feb 2016 08:55:30 +0100
clocksource: Introduce clocksource_freq2mult()
The clocksource_khz2mult() and clocksource_hz2mult() share similar code wihch calculates a mult from the given frequency. Both implementations in differ only in value of a frequency. This patch introduces the clocksource_freq2mult() helper with generic implementation of mult calculation to prevent code duplication.
--- include/linux/clocksource.h | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-)
include/linux/clocksource.h +19 -26
@@ -118,6 +118,23 @@ struct clocksource {/* simplify initialization of mask field */ #define CLOCKSOURCE_MASK (bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) +static inline u32 clocksource_freq2mult (u32 freq,u32 shift_constant,u64 from) +{ +/* freq = cyc/from +* mult/2^shift = ns/cyc +* mult = ns/cyc * 2^shift +* mult = from/freq * 2^shift +* mult = from * 2^shift / freq +* mult = (from<<shift) / freq +*/ +u64 tmp = ((u64 )from) << shift_constant; + + tmp += freq/2 ;/* round for do_div */ +do_div (tmp, freq); + +return (u32 )tmp; +} +/** * clocksource_khz2mult - calculates mult from khz and shift * @khz: Clocksource frequency in KHz
@@ -128,19 +145,7 @@ struct clocksource {*/ static inline u32 clocksource_khz2mult (u32 khz,u32 shift_constant) { -/* khz = cyc/(Million ns) -* mult/2^shift = ns/cyc -* mult = ns/cyc * 2^shift -* mult = 1Million/khz * 2^shift -* mult = 1000000 * 2^shift / khz -* mult = (1000000<<shift) / khz -*/ -u64 tmp = ((u64 )1000000 ) << shift_constant; - - tmp += khz/2 ;/* round for do_div */ -do_div (tmp, khz); - -return (u32 )tmp; +return clocksource_freq2mult (khz, shift_constant,NSEC_PER_MSEC ); }/**
@@ -154,19 +159,7 @@ static inline u32 clocksource_khz2mult(u32 khz, u32 shift_constant)*/ static inline u32 clocksource_hz2mult (u32 hz,u32 shift_constant) { -/* hz = cyc/(Billion ns) -* mult/2^shift = ns/cyc -* mult = ns/cyc * 2^shift -* mult = 1Billion/hz * 2^shift -* mult = 1000000000 * 2^shift / hz -* mult = (1000000000<<shift) / hz -*/ -u64 tmp = ((u64 )1000000000 ) << shift_constant; - - tmp += hz/2 ;/* round for do_div */ -do_div (tmp, hz); - -return (u32 )tmp; +return clocksource_freq2mult (hz, shift_constant,NSEC_PER_SEC ); }/**
PATCH 2/2 jiffies: use CLOCKSOURCE_MASK instead of constant
In reply to John StultzFrom: Alexander Kuleshov <[email protected]>
The CLOCKSOURCE_MASK(32) macro expands to the same value, but makes code more readable.
--- kernel/time/jiffies.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/jiffies.c +1 -1
@@ -68,7 +68,7 @@ static struct clocksource clocksource_jiffies = { .name = "jiffies", .rating = 1, /* lowest valid rating*/ .read = jiffies_read, - .mask = 0xffffffff, /*32bits*/ + .mask = CLOCKSOURCE_MASK(32), .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ .shift = JIFFIES_SHIFT, .max_cycles = 10,
Signature · 1 line
1.9.1
tip-bot for Alexander Kuleshov
merge bot[tip:timers/core] jiffies: Use CLOCKSOURCE_MASK instead of constant
jiffies: Use CLOCKSOURCE_MASK instead of constant
Commit-ID: 232d26373d310a941ef2ab46e53ea62fe076ed13 Gitweb: http://git.kernel.org/tip/232d26373d310a941ef2ab46e53ea62fe076ed13 Author: Alexander Kuleshov <[email protected]> AuthorDate: Fri, 26 Feb 2016 19:14:14 -0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 27 Feb 2016 08:55:31 +0100
jiffies: Use CLOCKSOURCE_MASK instead of constant
The CLOCKSOURCE_MASK(32) macro expands to the same value, but makes code more readable.
--- kernel/time/jiffies.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/jiffies.c +1 -1
@@ -68,7 +68,7 @@ static struct clocksource clocksource_jiffies = { .name = "jiffies", .rating = 1, /* lowest valid rating*/ .read = jiffies_read, - .mask = 0xffffffff, /*32bits*/ + .mask = CLOCKSOURCE_MASK(32), .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ .shift = JIFFIES_SHIFT, .max_cycles = 10,
John,
Quoted 9 lines · John Stultz
Hey Thomas, Ingo,
Here's my somewhat truncated queue for 4.6. I was hoping to
get the cross-timestamp patchset from Christopher sent along, but he's got some last minute changes to address feedback from Andy, so I'm holding off.If the response is good for that last change, I may try to send another set with those changes next week, but we're cutting it fairly close to -rc6, so I'll check with you before doing so.
If it's just the small fixup to address review comments, we still should take it.
Quoted 3 lines
So.. two tiny cleanup fixes is all for now.
Boring is good, right?
:)
Thanks,
tglx
Quoted 2 lines · John Stultz
clocksource: introduce
clocksource_freq2mult()
jiffies: useCLOCKSOURCE_MASKinstead of constant
Bah. You again forgot to make the first letter of the sentence upper case.
Hint: There is the concept of scripts, which can automate that :)
Thanks,
tglx