Skip to contentSkip to conversation

timekeeping_adjust may set mult to 0

DISCUSSION David Engraf 2 participants 3 messages Feb 11, 2013 – Feb 26, 2013

lore
Share & tools
lore
#0 lore raw

Hi,

I have encountered a problem when a linux system uses a clocksource with mult = 1 and shift = 0 (clocksource cycle = nanoseconds). It may happen that the function timekeeping_adjust reduces the value of mult to 0 when error is lower than the interval [1]. As soon as timekeeper.mult is 0, ktime_get will no longer work because it uses timekeeping_get_ns which converts the cycle to nanoseconds with mult as 0 and the system clocksource returns always 0.

Best regards
David Engraf

[1] http://lxr.linux.no/linux+v3.0.62/kernel/time/timekeeping.c#L821

#1 lore raw
Quoted 7 lines · David Engraf

I have encountered a problem when a linux system uses a clocksource with mult = 1 and shift = 0 (clocksource cycle = nanoseconds). It may happen that the function timekeeping_adjust reduces the value of mult to 0 when error is lower than the interval [1].
As soon as timekeeper.mult is 0, ktime_get will no longer work because it uses timekeeping_get_ns which converts the cycle to nanoseconds with mult as 0 and the system clocksource returns always 0.

So you *don't* want to use shift=0, since that kills the ability for the frequency adjustment code to do anything, as you've found.

Instead of calculating the clocksource mult/shift pair yourself, please use clocksource_register_hz/khz().

I'm hoping to kill off the open clocksource_register() call soon, to avoid this sort of confusion. Sorry for the trouble.

thanks
-john

#2 lore raw

Am 15.02.2013 23:34, schrieb John Stultz:

Quoted 11 lines · David Engraf
Quoted 7 lines

I have encountered a problem when a linux system uses a clocksource with mult = 1 and shift = 0 (clocksource cycle = nanoseconds). It may happen that the function timekeeping_adjust reduces the value of mult to 0 when error is lower than the interval [1].
As soon as timekeeper.mult is 0, ktime_get will no longer work because it uses timekeeping_get_ns which converts the cycle to nanoseconds with mult as 0 and the system clocksource returns always 0.

So you *don't* want to use shift=0, since that kills the ability for the frequency adjustment code to do anything, as you've found.

The problem is not shift=0 it's mult=1. The frequency adjustment code may increase/decrease mult and mult=0 will not work.

Quoted 2 lines

Instead of calculating the clocksource mult/shift pair yourself, please use clocksource_register_hz/khz().

Thanks, I will try it.

Best regards
- David

Quoted 6 lines

I'm hoping to kill off the open clocksource_register() call soon, to avoid this sort of confusion. Sorry for the trouble.

thanks
-john