Skip to contentSkip to conversation

x86, vmi: TSC going backwards check in vmi clocksource

PATCH Applied Alok Kataria 2 participants 7 messages Feb 18, 2009 – Feb 20, 2009 x86

lore
Share & tools
lore
#0 lore raw

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
index c4c1f9e..bde106c 100644
@@ -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 = {
#1 lore raw
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

#2 lore raw
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

Applied
#3 lore raw
Quoted 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_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.

Applied to tip:x86/urgent, thanks Alok!

Ingo

#4 lore raw
In reply to Alok Kataria

arch/x86/kernel/vmiclock_32.c void __devinit vmi_time_ap_init(void) · line 292

Quoted 6 lines · Alok Kataria

static cycle_t read_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

#5 lore raw
Quoted 10 lines · Ingo Molnar

Review

Quoted 6 lines · Alok Kataria

static cycle_t read_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
index 9cd28c0..b77ad57 100644
@@ -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 = {
Applied
#6 lore raw
Quoted 12 lines · Alok Kataria
Quoted 10 lines · Ingo Molnar

Review

Quoted 6 lines · Alok Kataria

static cycle_t read_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