public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Hansen <x@jeffhansen.com>
To: akataria@vmware.com
Cc: Chris Snook <csnook@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	LKML <linux-kernel@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	Daniel Hecht <dhecht@vmware.com>
Subject: Re: [PATCH 0/3] Improve TSC as a clocksource under VMware
Date: Wed, 22 Oct 2008 13:29:24 -0600	[thread overview]
Message-ID: <48FF7F14.8070007@jeffhansen.com> (raw)
In-Reply-To: <1224703586.13953.12.camel@alok-dev1>

Alok,

No objections.  Looks good to me.

-Jeff

Alok Kataria wrote:
> Jeff, i have kept your Signed-off-by with this slightly modified patch,
> incase you have any objections to that please let me know.
>
> --
> [X86] Skip verification by the watchdog for TSC clocksource.
>
> From: Alok N Kataria <akataria@vmware.com>
>
> This is achieved by resetting the CLOCKSOURCE_MUST_VERIFY flag.
>
> We add a tsc=reliable commandline option to enable this.
> This enables legacy hardware without HPET, LAPIC, or ACPI timers
> to enter high-resolution timer mode.
>
> Along with that have extended this to be used in virtualization
> environment, just for VMware as yet. This is important since there
> is a wrap-around problem with the acpi_pm timer.
> The acpi_pm counter is just 24bits and this can overflow in 4 seconds.
> With the NO_HZ kernels in virtualized environment, there can be situations
> when the guest is descheduled for longer duration, as a result we may miss
> the wrap of the acpi counter. When TSC is used as a clocksource and acpi_pm
> timer is being used as the watchdog clocksource this error in acpi_pm
> results in TSC being marked as unstable, and essentially results in time
> dropping in chunks of 4 seconds whenever this wrap is missed. Since the
> virtualized TSC is reliable on VMware, we should always use the TSCs
> clocksource on VMware, so we skip the verfication at runtime.
>
> Since we reset the flag for mgeode systems too, i have combined
> the mgeode case with the check for VMware.
>
> Signed-off-by: Jeff Hansen <jhansen@cardaccess-inc.com>
> Signed-off-by: Alok N Kataria <akataria@vmware.com>
> Cc: Chris Snook <csnook@redhat.com>
> ---
>
>  Documentation/kernel-parameters.txt |    7 +++++++
>  arch/x86/kernel/tsc.c               |   33 +++++++++++++++++++++------------
>  2 files changed, 28 insertions(+), 12 deletions(-)
>
>
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index e82c5bc..c5eb028 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -2230,6 +2230,13 @@ and is between 256 and 4096 characters. It is defined in the file
>  			Format:
>  			<io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq>
>  
> +	tsc=		Disable clocksource-must-verify flag for TSC.
> +			Format: <string>
> +			[x86] reliable: mark tsc clocksource as reliable, this
> +			disables clocksource verification at runtime.
> +			Used to enable high-resolution timer mode on older
> +			hardware, and in virtualized environment.
> +
>  	turbografx.map[2|3]=	[HW,JOY]
>  			TurboGraFX parallel port interface
>  			Format:
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 4ae207c..24eff09 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -32,6 +32,7 @@ static int tsc_unstable;
>     erroneous rdtsc usage on !cpu_has_tsc processors */
>  static int tsc_disabled = -1;
>  
> +static int tsc_clocksource_reliable;
>  /*
>   * Scheduler clock - returns current time in nanosec units.
>   */
> @@ -99,6 +100,15 @@ int __init notsc_setup(char *str)
>  
>  __setup("notsc", notsc_setup);
>  
> +static int __init tsc_setup(char *str)
> +{
> +	if (!strcmp(str, "reliable"))
> +		tsc_clocksource_reliable = 1;
> +	return 1;
> +}
> +
> +__setup("tsc=", tsc_setup);
> +
>  #define MAX_RETRIES     5
>  #define SMI_TRESHOLD    50000
>  
> @@ -745,24 +755,21 @@ static struct dmi_system_id __initdata bad_tsc_dmi_table[] = {
>  	{}
>  };
>  
> -/*
> - * Geode_LX - the OLPC CPU has a possibly a very reliable TSC
> - */
> +static void __init check_system_tsc_reliable(void)
> +{
>  #ifdef CONFIG_MGEODE_LX
> -/* RTSC counts during suspend */
> +	/* RTSC counts during suspend */
>  #define RTSC_SUSP 0x100
> -
> -static void __init check_geode_tsc_reliable(void)
> -{
>  	unsigned long res_low, res_high;
>  
>  	rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
> +	/* Geode_LX - the OLPC CPU has a possibly a very reliable TSC */
>  	if (res_low & RTSC_SUSP)
> -		clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY;
> -}
> -#else
> -static inline void check_geode_tsc_reliable(void) { }
> +		tsc_clocksource_reliable = 1;
>  #endif
> +	if (boot_cpu_data.x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE)
> +		tsc_clocksource_reliable = 1;
> +}
>  
>  /*
>   * Make an educated guess if the TSC is trustworthy and synchronized
> @@ -797,6 +804,8 @@ static void __init init_tsc_clocksource(void)
>  {
>  	clocksource_tsc.mult = clocksource_khz2mult(tsc_khz,
>  			clocksource_tsc.shift);
> +	if (tsc_clocksource_reliable)
> +		clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY;
>  	/* lower the rating if we already know its unstable: */
>  	if (check_tsc_unstable()) {
>  		clocksource_tsc.rating = 0;
> @@ -857,7 +866,7 @@ void __init tsc_init(void)
>  	if (unsynchronized_tsc())
>  		mark_tsc_unstable("TSCs unsynchronized");
>  
> -	check_geode_tsc_reliable();
> +	check_system_tsc_reliable();
>  	init_tsc_clocksource();
>  }
>  
>
>
>   


-- 
---------------------------------------------------
"If someone's gotta do it, it might as well be me."
                x@jeffhansen.com


  reply	other threads:[~2008-10-22 19:29 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-21  1:35 [PATCH 0/3] Improve TSC as a clocksource under VMware Alok Kataria
2008-10-21  5:55 ` Chris Snook
2008-10-21 19:11   ` Alok Kataria
2008-10-22 19:26   ` Alok Kataria
2008-10-22 19:29     ` Jeff Hansen [this message]
2008-10-21  9:43 ` Andi Kleen
2008-10-21 16:41   ` Alok Kataria
2008-10-21 17:40     ` Andi Kleen
2008-10-21 18:04       ` Alok Kataria
2008-10-21 18:15         ` Andi Kleen
2008-10-21 19:10           ` Alok Kataria
2008-10-21 19:27             ` Andi Kleen
2008-10-21 19:47               ` Alok Kataria
2008-10-21 21:41                 ` Alok Kataria
2008-10-22 19:23               ` [PATCH] Skip tsc synchronization checks if CONSTANT_TSC bit is set Alok Kataria
2008-10-22 19:26                 ` Ingo Molnar
2008-10-22 19:30                   ` Alok Kataria
2008-10-22 20:17                   ` Andi Kleen
2008-10-22 22:04                     ` Alok Kataria
2008-10-22 19:58                 ` Andi Kleen
2008-10-22 22:00                   ` Alok Kataria
2008-10-22 22:13                     ` Andi Kleen
2008-10-22 22:11                       ` Alok Kataria
2008-10-22 22:54                         ` Andi Kleen
2008-10-23  2:21                           ` Alok Kataria
2008-10-23  8:10                             ` Andi Kleen
2008-10-23 23:39                               ` Alok Kataria
2008-10-23 23:47                                 ` H. Peter Anvin
2008-10-24  0:25                                   ` Andi Kleen
2008-10-24  0:46                                     ` H. Peter Anvin
2008-10-24  7:23                                       ` Andi Kleen
2008-10-24 15:30                                         ` H. Peter Anvin
2008-10-24 19:25                                           ` Andi Kleen
2008-10-24 19:19                                             ` H. Peter Anvin
2008-10-24 19:34                                               ` Andi Kleen
2008-10-24 19:50                                                 ` Alok Kataria
2008-10-24 20:18                                             ` Dan Hecht
2008-10-24  1:12                                   ` Alok Kataria
2008-10-24  1:18                                     ` H. Peter Anvin
2008-10-22 22:15                     ` Alan Cox
2008-10-22 22:17                       ` Alok Kataria
2008-10-21  9:50 ` [PATCH 0/3] Improve TSC as a clocksource under VMware Pavel Machek
2008-10-21 16:48   ` Alok Kataria
2008-10-21 18:36     ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48FF7F14.8070007@jeffhansen.com \
    --to=x@jeffhansen.com \
    --cc=akataria@vmware.com \
    --cc=csnook@redhat.com \
    --cc=dhecht@vmware.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox