linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/centaur: Mark TSC invariant
@ 2018-01-15  1:35 TimGuo
  2018-01-15  9:49 ` Thomas Gleixner
  2018-01-24 18:26 ` Alan Cox
  0 siblings, 2 replies; 5+ messages in thread
From: TimGuo @ 2018-01-15  1:35 UTC (permalink / raw)
  To: tglx, mingo, hpa, mingo, x86, linux-pm, linux-kernel
  Cc: brucechang, cooperyan, qiyuanwang, benjaminpan, TimGuo

Centaur CPU has a constant frequency TSC and that TSC does not stop in C-States.
But because the flags are not set for that CPU, the TSC is treated as non constant
frequency and assumed to stop in C-States, which makes it an unreliable and unusable
clock source. Setting those flags tells the kernel that the TSC is usable, so it
will select it over HPET. The effect of this is that reading time stamps (from kernel
or userspace) will be faster and more efficient.

Signed-off-by: TimGuo <timguo@zhaoxin.com>
---
 arch/x86/kernel/cpu/centaur.c | 4 ++++
 drivers/acpi/processor_idle.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index 68bc6d9..c578cd2 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -106,6 +106,10 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
 #ifdef CONFIG_X86_64
        set_cpu_cap(c, X86_FEATURE_SYSENTER32);
 #endif
+       if (c->x86_power & (1 << 8)) {
+               set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
+               set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
+       }
 }

 static void init_centaur(struct cpuinfo_x86 *c)
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index d50a7b6..5f0071c 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -207,6 +207,7 @@ static void tsc_check_state(int state)
        switch (boot_cpu_data.x86_vendor) {
        case X86_VENDOR_AMD:
        case X86_VENDOR_INTEL:
+       case X86_VENDOR_CENTAUR:
                /*
                 * AMD Fam10h TSC will tick in all
                 * C/P/S0/S1 states when this bit is set.
--
1.9.1



保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.

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

* Re: [PATCH] x86/centaur: Mark TSC invariant
  2018-01-15  1:35 [PATCH] x86/centaur: Mark TSC invariant TimGuo
@ 2018-01-15  9:49 ` Thomas Gleixner
  2018-01-24 18:26 ` Alan Cox
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2018-01-15  9:49 UTC (permalink / raw)
  To: TimGuo
  Cc: mingo, hpa, mingo, x86, linux-pm, linux-kernel, brucechang,
	cooperyan, qiyuanwang, benjaminpan

On Mon, 15 Jan 2018, TimGuo wrote:

> Centaur CPU has a constant frequency TSC and that TSC does not stop in C-States.
> But because the flags are not set for that CPU, the TSC is treated as non constant
> frequency and assumed to stop in C-States, which makes it an unreliable and unusable
> clock source. Setting those flags tells the kernel that the TSC is usable, so it
> will select it over HPET. The effect of this is that reading time stamps (from kernel
> or userspace) will be faster and more efficient.
> 
> Signed-off-by: TimGuo <timguo@zhaoxin.com>
> ---
>  arch/x86/kernel/cpu/centaur.c | 4 ++++
>  drivers/acpi/processor_idle.c | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
> index 68bc6d9..c578cd2 100644
> --- a/arch/x86/kernel/cpu/centaur.c
> +++ b/arch/x86/kernel/cpu/centaur.c
> @@ -106,6 +106,10 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
>  #ifdef CONFIG_X86_64
>         set_cpu_cap(c, X86_FEATURE_SYSENTER32);

This is still white space damaged, i.e. TAB is converted to spaces.

Please talk to your IT departement.

Thanks,

	tglx

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

* Re: [PATCH] x86/centaur: Mark TSC invariant
  2018-01-15  1:35 [PATCH] x86/centaur: Mark TSC invariant TimGuo
  2018-01-15  9:49 ` Thomas Gleixner
@ 2018-01-24 18:26 ` Alan Cox
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Cox @ 2018-01-24 18:26 UTC (permalink / raw)
  To: TimGuo
  Cc: tglx, mingo, hpa, mingo, x86, linux-pm, linux-kernel, brucechang,
	cooperyan, qiyuanwang, benjaminpan

On Mon, 15 Jan 2018 09:35:45 +0800
TimGuo <timguo@zhaoxin.com> wrote:

> Centaur CPU has a constant frequency TSC and that TSC does not stop in C-States.
> But because the flags are not set for that CPU, the TSC is treated as non constant
> frequency and assumed to stop in C-States, which makes it an unreliable and unusable
> clock source. Setting those flags tells the kernel that the TSC is usable, so it
> will select it over HPET. The effect of this is that reading time stamps (from kernel
> or userspace) will be faster and more efficient.

And this is true for all processors back to  IDT WinChip ?

Alan

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

* [PATCH] x86/centaur: Mark TSC invariant
@ 2018-01-22 10:14 davidwang
  0 siblings, 0 replies; 5+ messages in thread
From: davidwang @ 2018-01-22 10:14 UTC (permalink / raw)
  To: tglx, mingo, hpa, mingo, x86, linux-pm, linux-kernel
  Cc: brucechang, cooperyan, qiyuanwang, benjaminpan, davidwang

Centaur CPU has a constant frequency TSC and that TSC does not stop in
C-States. But because the flags are not set for that CPU, the TSC is
treated as not constant frequency and assumed to stop in C-States, which
makes it an unreliable and unusable clock source. Setting those flags
tells the kernel that the TSC is usable, so it will select it over HPET.
The effect of this is that reading time stamps (from kernel or user space)
will be faster and more efficent.

Signed-off-by: davidwang <davidwang@zhaoxin.com>
---
 arch/x86/kernel/cpu/centaur.c | 4 ++++
 drivers/acpi/processor_idle.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index 68bc6d9..c578cd2 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -106,6 +106,10 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
 #ifdef CONFIG_X86_64
 	set_cpu_cap(c, X86_FEATURE_SYSENTER32);
 #endif
+	if (c->x86_power & (1 << 8)) {
+		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
+		set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
+	}
 }
 
 static void init_centaur(struct cpuinfo_x86 *c)
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index d50a7b6..5f0071c 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -207,6 +207,7 @@ static void tsc_check_state(int state)
 	switch (boot_cpu_data.x86_vendor) {
 	case X86_VENDOR_AMD:
 	case X86_VENDOR_INTEL:
+	case X86_VENDOR_CENTAUR:
 		/*
 		 * AMD Fam10h TSC will tick in all
 		 * C/P/S0/S1 states when this bit is set.
-- 
1.9.1

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

* Re: [PATCH] x86/centaur: Mark TSC invariant
  2018-01-10 10:27 TimGuo
@ 2018-01-14 12:06 ` Thomas Gleixner
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2018-01-14 12:06 UTC (permalink / raw)
  To: TimGuo
  Cc: mingo, hpa, mingo, x86, linux-pm, linux-kernel, brucechang,
	cooperyan, qiyuanwang, benjaminpan

On Wed, 10 Jan 2018, TimGuo wrote:

Please be more careful when sending patches. The subject line
of you mail was empty....

Also this patch was copy pasted or whatever into the mail and got white
space damaged by your mail client, so it does not apply.

See Documentation/process/email-clients.txt

Thanks,

	tglx

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

end of thread, other threads:[~2018-01-24 18:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-15  1:35 [PATCH] x86/centaur: Mark TSC invariant TimGuo
2018-01-15  9:49 ` Thomas Gleixner
2018-01-24 18:26 ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2018-01-22 10:14 davidwang
2018-01-10 10:27 TimGuo
2018-01-14 12:06 ` [PATCH] x86/centaur: Mark TSC invariant Thomas Gleixner

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).