Skip to contentSkip to conversation

clocksource: update lpj if clocksource has been changed.

RFC-PATCH MyungJoo Ham 2 participants 2 messages Nov 12, 2010

lore
Share & tools
lore
#0 lore raw
Quoted 39 lines · john stultz
Quoted 27 lines · MyungJoo Ham
Quoted 26 lines · john stultz
Quoted 9 lines · MyungJoo Ham

With a clocksource change, loops_per_jiffy may have been changed; thus, the loops_per_jiffy in each cpu should be updated. Especially after some of the cpus were turned off and on, their loops_per_jiffy values are updated while the cpus kept on are not. Therefore, in order to make them "normalized equally", we need to let the loops_per_jiffy values of different cpus be based on the same clocksource.

Signed-off-by MyungJoo Ham
Signed-off-by Kyungmin Park

First, Thanks for reporting the issue and submitting the patch!

So the premise is that read_current_timer -> get_cycles -> clocksource_read on some arches. And then when we select a different clocksource for timekeeping, this also changes the get_cycles source breaking delay loops.

The clocksource selected for timekeeping and the counter being used for get_cycles really shouldn't be explicitly bound. On most systems I don't think that is the case, so this patch would force needless recalibration calls on clocksource changes.

Which arch specifically are you seeing the issue on? I suspect there is be a better way to fix this.

Quoted 8 lines
Quoted 2 lines

thanks
-john

We are working on ARM/S5PC210 with two cores. Actually, in single core systems, clocksource changes that affect loops-per-jiffy do not matter much as in multi-core systems because we do not have something to compare with in such a system. This patch adds some overheads on changing system clocksources; however, is happens only once at boot.

Well, clocksource changes can happen any time a system is running.

Quoted 9 lines

Looking through the 2.6.37-rc arm code, I'm not seeing any counter based delay implementation. I only see the loop based implementation in arm/lib/delay.S. Additionally, I don't see ARCH_HAS_READ_CURRENT_TIMER or a get_cycles implementation that uses the clocksource.

Have implemented a non-loop based delay for your platform? Or could you more clearly explain how the clocksource being used for timekeeping effects the delay function on your hardware?

Ah.. I'm not concerned with delay functions in this clocksource recalibration issue. The delay function has been working just fine. The issue affects the consistency of "BogoMIPS" values when we try "# cat /proc/cpuinfo", which is based on loops_per_jiffy stroed at cpu_data of each core. The cpu-on/off function recalibrates loops_per_jiffy for the cpu that was turned off and on. In a situation where part of cpus were turned off and on after the clocksource has been changed, the bogomips values have inconsistency between cpus. So, I'm not concerned with the delay function, which has been working fine before and after the patch, but with the consistency of loops_per_jiffy values in different cpus/cores.

Quoted 14 lines
Quoted 6 lines

Or, would it be better if we add another entry to struct clocksource; i.e., "bool recalibrate" in struct clocksource? Then, we can put recalibration routine in clocksource_select() at the end of the function deciding whether to recalibrate based on the "base->recalibrate" value. How about this?

No, I don't think adding more to the clocksource is the right fix here.

In my view, the correct solution should be to separate the get_cycles or read_current_timer implementation (if that is the culprit) so it is not dependent on the clocksource that the timekeeping code is currently using.

Quoted 7 lines

That way, changes to the time keeping clocksource won't affect the delay function, and the re-calibration will be unnecessary.

thanks
-john

�淸�{.n�+돴윯돪�+%듚�깁負쪐w��{.n�+돴쪐{깸G쳺��{ay����,j�f"톒쉹��묎�z_溫(�쉸듶줷"얎�m����G쳺�◀?솳鈺�&x�~뤳턨O뺞촾퇉v�^�m��� �띠�◀?뻀�

#1 lore raw
Quoted 11 lines · MyungJoo Ham
Quoted 9 lines · john stultz

Looking through the 2.6.37-rc arm code, I'm not seeing any counter based delay implementation. I only see the loop based implementation in arm/lib/delay.S. Additionally, I don't see ARCH_HAS_READ_CURRENT_TIMER or a get_cycles implementation that uses the clocksource.

Have implemented a non-loop based delay for your platform? Or could you more clearly explain how the clocksource being used for timekeeping effects the delay function on your hardware?

Quoted 6 lines

Ah.. I'm not concerned with delay functions in this clocksource recalibration issue. The delay function has been working just fine. The issue affects the consistency of "BogoMIPS" values when we try "# cat /proc/cpuinfo", which is based on loops_per_jiffy stroed at cpu_data of each core. The cpu-on/off function recalibrates loops_per_jiffy for the cpu that was turned off and on.

So I'm focused on __delay(), because it is used to generate the loops_per_jiffy value in calibrate_delay(). Or is loops_per_jiffy calculated by some other method on your board?

And if the issue is between the two cpus, it could be something interfering with calibrate_delay when startup up the second cpu. Is it that the first one is faster and the second one slower? Or the other way around? Or is one right and the other just wrong?

Quoted 5 lines

In a situation where part of cpus were turned off and on after the
clocksource has been changed, the bogomips values have inconsistency between cpus. So, I'm not concerned with the delay function, which has been working fine before and after the patch, but with the consistency of loops_per_jiffy values in different cpus/cores.

So have you isolated as to why the bogomips value changes when the clocksource changes? They *should* be independent.

I suspect your patch works, because its causing the calibration to happen again at a later time to correct for whatever interruption occurred during the initial calibration. So if the calibration were run again from an device_initcall() hook instead of the clocksource_select point it would do the exact same thing.

I'd suggest focusing on why the calibration was incorrect the first time, rather then just running it again to fix it.

thanks
-john