x86, vmi: TSC going backwards check in vmi clocksource
From: Alok N Kataria <[email protected]>
Similar to the check for TSC going backwards in the TSC clocksource, we also need this check for VMI clocksource.
---
arch/x86/kernel/vmiclock_32.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/x86/kernel/vmiclock_32.c +4 -1
@@ -283,10 +283,13 @@ void __devinit vmi_time_ap_init(void)#endif /** vmi clocksource */ +static struct clocksource clocksource_vmi;static cycle_t read_real_cycles (void ) { -return vmi_timer_ops.get_cycle_counter (VMI_CYCLES_REAL ); +cycle_t ret = (cycle_t )vmi_timer_ops.get_cycle_counter (VMI_CYCLES_REAL ); +return ret >= clocksource_vmi.cycle_last ? + ret : clocksource_vmi.cycle_last; }static struct clocksource clocksource_vmi = {
Quoted 4 lines · Alok Kataria
From: Alok N Kataria <[email protected]>
Similar to the check for TSC going backwards in the TSC clocksource, we also need this check for VMI clocksource.
ok. Precisely what kind of bug/symptoms does this fix?
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 4 lines · Alok Kataria
From: Alok N Kataria <[email protected]>
Similar to the check for TSC going backwards in the TSC clocksource, we also need this check for VMI clocksource.
ok. Precisely what kind of bug/symptoms does this fix?
If the read CYCLES_REAL counter value is less than the cycle_last value, it may result in time jumps.
I also saw some messages about process being stuck for more than 120sec, which was traced back to this.
Thanks,
Alok
Quoted 2 lines
Ingo
Ingo Molnar
AppliedQuoted 8 lines · Alok Kataria
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Alok Kataria
From: Alok N Kataria <[email protected]>
Similar to the check for TSC going backwards in the TSC clocksource, we also need this check for VMI clocksource.
Quoted 6 lines
Quoted 1 line
ok. Precisely what kind of bug/symptoms does this fix?
If the read
CYCLES_REALcounter value is less than thecycle_lastvalue, it may result in time jumps.
I also saw some messages about process being stuck for more than 120sec, which was traced back to this.
Applied to tip:x86/urgent, thanks Alok!
Ingo
arch/x86/kernel/vmiclock_32.c void __devinit vmi_time_ap_init(void) · line 292
Quoted 6 lines · Alok Kataria
static
cycle_tread_real_cycles(void)
{arch/x86/kernel/vmiclock_32.c +3
-1-return vmi_timer_ops.get_cycle_counter (VMI_CYCLES_REAL ); +cycle_t ret = (cycle_t )vmi_timer_ops.get_cycle_counter (VMI_CYCLES_REAL ); +return ret >= clocksource_vmi.cycle_last ? + ret : clocksource_vmi.cycle_last;
btw., could you please clean this up to use max()?
Ingo
Quoted 10 lines · Ingo Molnar
Review
Quoted 6 lines · Alok Kataria
static
cycle_tread_real_cycles(void)
{(quoted diff) +3
-1- return vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL); + cycle_t ret = (cycle_t)vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL); + return ret >= clocksource_vmi.cycle_last ? + ret : clocksource_vmi.cycle_last;btw., could you please clean this up to use
max()?
Please find it below, on top of current tip/master.
--
cleanup vmi_read_cycles to use max()
---
arch/x86/kernel/vmiclock_32.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
arch/x86/kernel/vmiclock_32.c +1 -2
@@ -288,8 +288,7 @@ static struct clocksource clocksource_vmi;static cycle_t read_real_cycles (void ) {cycle_t ret = (cycle_t )vmi_timer_ops.get_cycle_counter (VMI_CYCLES_REAL ); -return ret >= clocksource_vmi.cycle_last ? - ret : clocksource_vmi.cycle_last; +return max (ret, clocksource_vmi.cycle_last); }static struct clocksource clocksource_vmi = {
Ingo Molnar
AppliedQuoted 12 lines · Alok Kataria
Quoted 10 lines · Ingo Molnar
Review
Quoted 6 lines · Alok Kataria
static
cycle_tread_real_cycles(void)
{(quoted diff) +3
-1- return vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL); + cycle_t ret = (cycle_t)vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL); + return ret >= clocksource_vmi.cycle_last ? + ret : clocksource_vmi.cycle_last;btw., could you please clean this up to use
max()?
Quoted 1 line
Please find it below, on top of current tip/master.
Applied to tip:x86/cleanups, thanks!
Ingo