linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* x86, vmi: TSC going backwards check in vmi clocksource
@ 2009-02-18 20:33 Alok Kataria
  2009-02-19 11:18 ` Ingo Molnar
  2009-02-20 17:58 ` Ingo Molnar
  0 siblings, 2 replies; 7+ messages in thread
From: Alok Kataria @ 2009-02-18 20:33 UTC (permalink / raw)
  To: Ingo Molnar, the arch/x86 maintainers; +Cc: LKML, Zachary Amsden

From: Alok N Kataria <akataria@vmware.com>

Similar to the check for TSC going backwards in the TSC clocksource, we also
need this check for VMI clocksource.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Cc: stable@kernel.org
---

 arch/x86/kernel/vmiclock_32.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
index c4c1f9e..bde106c 100644
--- a/arch/x86/kernel/vmiclock_32.c
+++ b/arch/x86/kernel/vmiclock_32.c
@@ -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 = {



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: x86, vmi: TSC going backwards check in vmi clocksource
  2009-02-18 20:33 x86, vmi: TSC going backwards check in vmi clocksource Alok Kataria
@ 2009-02-19 11:18 ` Ingo Molnar
  2009-02-19 18:03   ` Alok Kataria
  2009-02-20 17:58 ` Ingo Molnar
  1 sibling, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2009-02-19 11:18 UTC (permalink / raw)
  To: Alok Kataria; +Cc: the arch/x86 maintainers, LKML, Zachary Amsden


* Alok Kataria <akataria@vmware.com> wrote:

> From: Alok N Kataria <akataria@vmware.com>
> 
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: x86, vmi: TSC going backwards check in vmi clocksource
  2009-02-19 11:18 ` Ingo Molnar
@ 2009-02-19 18:03   ` Alok Kataria
  2009-02-19 18:11     ` Ingo Molnar
  0 siblings, 1 reply; 7+ messages in thread
From: Alok Kataria @ 2009-02-19 18:03 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: the arch/x86 maintainers, LKML, Zach Amsden

On Thu, 2009-02-19 at 03:18 -0800, Ingo Molnar wrote:
> * Alok Kataria <akataria@vmware.com> wrote:
> 
> > From: Alok N Kataria <akataria@vmware.com>
> > 
> > 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
> 
> 	Ingo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: x86, vmi: TSC going backwards check in vmi clocksource
  2009-02-19 18:03   ` Alok Kataria
@ 2009-02-19 18:11     ` Ingo Molnar
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2009-02-19 18:11 UTC (permalink / raw)
  To: Alok Kataria; +Cc: the arch/x86 maintainers, LKML, Zach Amsden


* Alok Kataria <akataria@vmware.com> wrote:

> On Thu, 2009-02-19 at 03:18 -0800, Ingo Molnar wrote:
> > * Alok Kataria <akataria@vmware.com> wrote:
> > 
> > > From: Alok N Kataria <akataria@vmware.com>
> > > 
> > > 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.

Applied to tip:x86/urgent, thanks Alok!

	Ingo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: x86, vmi: TSC going backwards check in vmi clocksource
  2009-02-18 20:33 x86, vmi: TSC going backwards check in vmi clocksource Alok Kataria
  2009-02-19 11:18 ` Ingo Molnar
@ 2009-02-20 17:58 ` Ingo Molnar
  2009-02-20 18:23   ` Alok Kataria
  1 sibling, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2009-02-20 17:58 UTC (permalink / raw)
  To: Alok Kataria
  Cc: the arch/x86 maintainers, LKML, Zachary Amsden, Andrew Morton


* Alok Kataria <akataria@vmware.com> wrote:

>  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;

btw., could you please clean this up to use max()?

	Ingo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: x86, vmi: TSC going backwards check in vmi clocksource
  2009-02-20 17:58 ` Ingo Molnar
@ 2009-02-20 18:23   ` Alok Kataria
  2009-02-20 18:31     ` Ingo Molnar
  0 siblings, 1 reply; 7+ messages in thread
From: Alok Kataria @ 2009-02-20 18:23 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: the arch/x86 maintainers, LKML, Zach Amsden, Andrew Morton

On Fri, 2009-02-20 at 09:58 -0800, Ingo Molnar wrote:
> * Alok Kataria <akataria@vmware.com> wrote:
> 
> >  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;
> 
> 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()

Signed-off-by: Alok N Kataria <akataria@vmware.com>

---

 arch/x86/kernel/vmiclock_32.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)


diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
index 9cd28c0..b77ad57 100644
--- a/arch/x86/kernel/vmiclock_32.c
+++ b/arch/x86/kernel/vmiclock_32.c
@@ -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 = {



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: x86, vmi: TSC going backwards check in vmi clocksource
  2009-02-20 18:23   ` Alok Kataria
@ 2009-02-20 18:31     ` Ingo Molnar
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2009-02-20 18:31 UTC (permalink / raw)
  To: Alok Kataria; +Cc: the arch/x86 maintainers, LKML, Zach Amsden, Andrew Morton


* Alok Kataria <akataria@vmware.com> wrote:

> On Fri, 2009-02-20 at 09:58 -0800, Ingo Molnar wrote:
> > * Alok Kataria <akataria@vmware.com> wrote:
> > 
> > >  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;
> > 
> > btw., could you please clean this up to use max()?
> 
> Please find it below, on top of current tip/master.

Applied to tip:x86/cleanups, thanks!

	Ingo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-20 18:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-18 20:33 x86, vmi: TSC going backwards check in vmi clocksource Alok Kataria
2009-02-19 11:18 ` Ingo Molnar
2009-02-19 18:03   ` Alok Kataria
2009-02-19 18:11     ` Ingo Molnar
2009-02-20 17:58 ` Ingo Molnar
2009-02-20 18:23   ` Alok Kataria
2009-02-20 18:31     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).