Skip to content

Commit

Permalink
timekeeping/clocksource_cyc2ns: Document intended range limitation
Browse files Browse the repository at this point in the history
The "cycles" argument should not be an absolute clocksource cycle
value, as the implementation's arithmetic will overflow relatively
easily with wide (64 bit) clocksource counters.

For performance, the implementation is simple and fast, since the
function is intended for only relatively small delta values of
clocksource cycles.

[jstultz: Fixed up to merge against HEAD & commit message tweaks,
 also included rewording suggestion by Ingo]
Signed-off-by: Chris Metcalf <[email protected]>
Signed-off-by: John Stultz <[email protected]>
Cc: Prarit Bhargava <[email protected]>
Cc: Richard Cochran <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
cmetcalf-tilera authored and KAGA-KOKO committed Nov 29, 2016
1 parent ba58d10 commit ec4101e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/linux/clocksource.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant)
* @mult: cycle to nanosecond multiplier
* @shift: cycle to nanosecond divisor (power of two)
*
* Converts cycles to nanoseconds, using the given mult and shift.
* Converts clocksource cycles to nanoseconds, using the given @mult and @shift.
* The code is optimized for performance and is not intended to work
* with absolute clocksource cycles (as those will easily overflow),
* but is only intended to be used with relative (delta) clocksource cycles.
*
* XXX - This could use some mult_lxl_ll() asm optimization
*/
Expand Down

0 comments on commit ec4101e

Please sign in to comment.