Remove invalid code which caused TSC to be declared as "unstable" on vSMP
Foundation box even if it was stable and let the kernel decide for itself.
When a vSMP Foundation box is detected, the function apic_cluster_num() counts
the number of APIC clusters found. If more than one found, a multi board
configuration is assumed, and TSC marked as unstable. This behavior is
incorrect as vSMP Foundation may use processors from single node only, attached
to memory of other nodes - and such node may have more than one APIC cluster
(typically any recent intel box has more than single APIC_CLUSTERID(x)).
To fix this, we simply remove the code which detects a vSMP Foundation box and
affects apic_is_clusted_box() return value. This can be done because later the
kernel checks by itself if the TSC is stable using the
check_tsc_sync_[source|target]() functions and marks TSC as unstable if needed.
Signed-off-by: Oren Twaig <[email protected]>
Acked-by: Shai Fultheim <[email protected]>
---
arch/x86/include/asm/apic.h | 8 ------
arch/x86/kernel/apic/apic.c | 60 +------------------------------------------
2 files changed, 1 insertion(+), 67 deletions(-)
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 19b0eba..c100694 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -85,14 +85,6 @@ static inline bool apic_from_smp_config(void)
#include <asm/paravirt.h>
#endif
-#ifdef CONFIG_X86_64
-extern int is_vsmp_box(void);
-#else
-static inline int is_vsmp_box(void)
-{
- return 0;
-}
-#endif
extern int setup_profiling_timer(unsigned int);
static inline void native_apic_mem_write(u32 reg, u32 v)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index ad28db7..2b85bb9 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2451,51 +2451,6 @@ static void apic_pm_activate(void) { }
#ifdef CONFIG_X86_64
-static int apic_cluster_num(void)
-{
- int i, clusters, zeros;
- unsigned id;
- u16 *bios_cpu_apicid;
- DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
-
- bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid);
- bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
-
- for (i = 0; i < nr_cpu_ids; i++) {
- /* are we being called early in kernel startup? */
- if (bios_cpu_apicid) {
- id = bios_cpu_apicid[i];
- } else if (i < nr_cpu_ids) {
- if (cpu_present(i))
- id = per_cpu(x86_bios_cpu_apicid, i);
- else
- continue;
- } else
- break;
-
- if (id != BAD_APICID)
- __set_bit(APIC_CLUSTERID(id), clustermap);
- }
-
- /* Problem: Partially populated chassis may not have CPUs in some of
- * the APIC clusters they have been allocated. Only present CPUs have
- * x86_bios_cpu_apicid entries, thus causing zeroes in the bitmap.
- * Since clusters are allocated sequentially, count zeros only if
- * they are bounded by ones.
- */
- clusters = 0;
- zeros = 0;
- for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
- if (test_bit(i, clustermap)) {
- clusters += 1 + zeros;
- zeros = 0;
- } else
- ++zeros;
- }
-
- return clusters;
-}
-
static int multi_checked;
static int multi;
@@ -2540,20 +2495,7 @@ static void dmi_check_multi(void)
int apic_is_clustered_box(void)
{
dmi_check_multi();
- if (multi)
- return 1;
-
- if (!is_vsmp_box())
- return 0;
-
- /*
- * ScaleMP vSMPowered boxes have one cluster per board and TSCs are
- * not guaranteed to be synced between boards
- */
- if (apic_cluster_num() > 1)
- return 1;
-
- return 0;
+ return multi;
}
#endif
On Mon, Jun 23, 2014 at 08:35:14AM +0300, Oren Twaig wrote:
> Remove invalid code which caused TSC to be declared as "unstable" on vSMP
> Foundation box even if it was stable and let the kernel decide for itself.
>
> When a vSMP Foundation box is detected, the function apic_cluster_num() counts
> the number of APIC clusters found. If more than one found, a multi board
> configuration is assumed, and TSC marked as unstable. This behavior is
> incorrect as vSMP Foundation may use processors from single node only, attached
> to memory of other nodes - and such node may have more than one APIC cluster
> (typically any recent intel box has more than single APIC_CLUSTERID(x)).
>
> To fix this, we simply remove the code which detects a vSMP Foundation box and
> affects apic_is_clusted_box() return value. This can be done because later the
> kernel checks by itself if the TSC is stable using the
> check_tsc_sync_[source|target]() functions and marks TSC as unstable if needed.
Looks good to me. Yes the APIC cluster check is obsolete.
-andi
ping
On 06/23/2014 08:35 AM, Oren Twaig wrote:
> Remove invalid code which caused TSC to be declared as "unstable" on vSMP
> Foundation box even if it was stable and let the kernel decide for itself.
>
> When a vSMP Foundation box is detected, the function apic_cluster_num() counts
> the number of APIC clusters found. If more than one found, a multi board
> configuration is assumed, and TSC marked as unstable. This behavior is
> incorrect as vSMP Foundation may use processors from single node only, attached
> to memory of other nodes - and such node may have more than one APIC cluster
> (typically any recent intel box has more than single APIC_CLUSTERID(x)).
>
> To fix this, we simply remove the code which detects a vSMP Foundation box and
> affects apic_is_clusted_box() return value. This can be done because later the
> kernel checks by itself if the TSC is stable using the
> check_tsc_sync_[source|target]() functions and marks TSC as unstable if needed.
>
> Signed-off-by: Oren Twaig <[email protected]>
> Acked-by: Shai Fultheim <[email protected]>
> ---
> arch/x86/include/asm/apic.h | 8 ------
> arch/x86/kernel/apic/apic.c | 60 +------------------------------------------
> 2 files changed, 1 insertion(+), 67 deletions(-)
>
> diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
> index 19b0eba..c100694 100644
> --- a/arch/x86/include/asm/apic.h
> +++ b/arch/x86/include/asm/apic.h
> @@ -85,14 +85,6 @@ static inline bool apic_from_smp_config(void)
> #include <asm/paravirt.h>
> #endif
>
> -#ifdef CONFIG_X86_64
> -extern int is_vsmp_box(void);
> -#else
> -static inline int is_vsmp_box(void)
> -{
> - return 0;
> -}
> -#endif
> extern int setup_profiling_timer(unsigned int);
>
> static inline void native_apic_mem_write(u32 reg, u32 v)
> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> index ad28db7..2b85bb9 100644
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -2451,51 +2451,6 @@ static void apic_pm_activate(void) { }
>
> #ifdef CONFIG_X86_64
>
> -static int apic_cluster_num(void)
> -{
> - int i, clusters, zeros;
> - unsigned id;
> - u16 *bios_cpu_apicid;
> - DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
> -
> - bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid);
> - bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
> -
> - for (i = 0; i < nr_cpu_ids; i++) {
> - /* are we being called early in kernel startup? */
> - if (bios_cpu_apicid) {
> - id = bios_cpu_apicid[i];
> - } else if (i < nr_cpu_ids) {
> - if (cpu_present(i))
> - id = per_cpu(x86_bios_cpu_apicid, i);
> - else
> - continue;
> - } else
> - break;
> -
> - if (id != BAD_APICID)
> - __set_bit(APIC_CLUSTERID(id), clustermap);
> - }
> -
> - /* Problem: Partially populated chassis may not have CPUs in some of
> - * the APIC clusters they have been allocated. Only present CPUs have
> - * x86_bios_cpu_apicid entries, thus causing zeroes in the bitmap.
> - * Since clusters are allocated sequentially, count zeros only if
> - * they are bounded by ones.
> - */
> - clusters = 0;
> - zeros = 0;
> - for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
> - if (test_bit(i, clustermap)) {
> - clusters += 1 + zeros;
> - zeros = 0;
> - } else
> - ++zeros;
> - }
> -
> - return clusters;
> -}
> -
> static int multi_checked;
> static int multi;
>
> @@ -2540,20 +2495,7 @@ static void dmi_check_multi(void)
> int apic_is_clustered_box(void)
> {
> dmi_check_multi();
> - if (multi)
> - return 1;
> -
> - if (!is_vsmp_box())
> - return 0;
> -
> - /*
> - * ScaleMP vSMPowered boxes have one cluster per board and TSCs are
> - * not guaranteed to be synced between boards
> - */
> - if (apic_cluster_num() > 1)
> - return 1;
> -
> - return 0;
> + return multi;
> }
> #endif
>
>
>
On 06/26/2014 10:05 PM, Oren Twaig wrote:
> ping
This patch conflicts with the changes on the tip:x86/apic branch. Could
you please rebase the patch on top of that branch?
-hpa
Hi,
There was actually a problem that the mailer which changed a '\t' to spaces.
This is why it conflicted with the tip:x86/apic branch. Any how, I've also
tested on the x86/apic branch and everything is ok.
Sent :
"[PATCH v2] x86, vsmp: Remove is_vsmp_box() from apic_is_clustered_box()"
Sorry for any troubles.
Thanks,
Oren.
On 06/27/2014 08:39 AM, H. Peter Anvin wrote:
> On 06/26/2014 10:05 PM, Oren Twaig wrote:
>> ping
>
> This patch conflicts with the changes on the tip:x86/apic branch. Could
> you please rebase the patch on top of that branch?
>
> -hpa
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>