* Ido Yariv <[email protected]> wrote:
> From: Shai Fultheim <[email protected]>
>
> In case CONFIG_X86_VSMP is not set, limit the number of CPUs to the
> number of CPUs of the first board.
>
> Signed-off-by: Shai Fultheim <[email protected]>
> [[email protected]: rebased, fixed minor coding-style issues]
> Signed-off-by: Ido Yariv <[email protected]>
> ---
> arch/x86/kernel/vsmp_64.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 48 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
> index a1d804b..61571fd 100644
> --- a/arch/x86/kernel/vsmp_64.c
> +++ b/arch/x86/kernel/vsmp_64.c
> @@ -15,6 +15,7 @@
> #include <linux/init.h>
> #include <linux/pci_ids.h>
> #include <linux/pci_regs.h>
> +#include <linux/smp.h>
>
> #include <asm/apic.h>
> #include <asm/pci-direct.h>
> @@ -22,6 +23,8 @@
> #include <asm/paravirt.h>
> #include <asm/setup.h>
>
> +#define TOPOLOGY_REGISTER_OFFSET 0x10
> +
> #if defined CONFIG_PCI && defined CONFIG_PARAVIRT
> /*
> * Interrupt control on vSMPowered systems:
> @@ -149,12 +152,57 @@ int is_vsmp_box(void)
> return 0;
> }
> #endif
> +
> +#ifdef CONFIG_X86_VSMP
> +
> +static void __init vsmp_cap_cpus(void)
> +{
> + /* VSMP is enabled, no need to cap cpus */
> +}
> +
> +#else
Please move this int the vsmp_cap_cpus() function and you can
simplify the #ifdef block to:
#ifdef CONFIG_X86_VSMP
/* VSMP is enabled, no need to cap cpus */
return;
#endif
> +
> +static void __init vsmp_cap_cpus(void)
> +{
> + /*
> + * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
> + * ones present in the first board, unless explicitly overridden by
> + * setup_max_cpus
> + */
> + if (setup_max_cpus == NR_CPUS) {
you can simplify the function and save a level of indentation by
turning this into:
if (setup_max_cpus != NR_CPUS)
return;
> + void __iomem *address;
> + unsigned int cfg, topology, node_shift, maxcpus;
> +
> + /* Read the vSMP Foundation topology register */
> + cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
> + address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
> + if (WARN_ON(!address))
> + return;
> +
> + topology = readl(address);
> + node_shift = (topology >> 16) & 0x7;
> + if (!node_shift)
> + /* The value 0 should be decoded as 8 */
> + node_shift = 8;
> + maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
> +
> + printk(KERN_INFO "vSMP CTL: Capping CPUs to %d "
> + "(CONFIG_X86_VSMP is unset)\n", maxcpus);
Please don't break up format strings - just leave them long and
use pr_info().
> + setup_max_cpus = maxcpus;
> + early_iounmap(address, 4);
> + }
> +}
> +
> +#endif
Looks good and useful otherwise.
Thanks,
Ingo
From: Shai Fultheim <[email protected]>
In case CONFIG_X86_VSMP is not set, limit the number of CPUs to the
number of CPUs of the first board.
Signed-off-by: Shai Fultheim <[email protected]>
[[email protected]: rebased, fixed minor coding-style issues]
Signed-off-by: Ido Yariv <[email protected]>
---
Changes from v2:
- Addressed Ingo's comments
arch/x86/kernel/vsmp_64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index a1d804b..6aa0d59 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/pci_ids.h>
#include <linux/pci_regs.h>
+#include <linux/smp.h>
#include <asm/apic.h>
#include <asm/pci-direct.h>
@@ -22,6 +23,8 @@
#include <asm/paravirt.h>
#include <asm/setup.h>
+#define TOPOLOGY_REGISTER_OFFSET 0x10
+
#if defined CONFIG_PCI && defined CONFIG_PARAVIRT
/*
* Interrupt control on vSMPowered systems:
@@ -149,12 +152,52 @@ int is_vsmp_box(void)
return 0;
}
#endif
+
+static void __init vsmp_cap_cpus(void)
+{
+ void __iomem *address;
+ unsigned int cfg, topology, node_shift, maxcpus;
+
+#ifdef CONFIG_X86_VSMP
+ /* VSMP is enabled, no need to cap cpus */
+ return;
+#endif
+
+ /*
+ * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
+ * ones present in the first board, unless explicitly overridden by
+ * setup_max_cpus
+ */
+ if (setup_max_cpus != NR_CPUS)
+ return;
+
+ /* Read the vSMP Foundation topology register */
+ cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
+ address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
+ if (WARN_ON(!address))
+ return;
+
+ topology = readl(address);
+ node_shift = (topology >> 16) & 0x7;
+ if (!node_shift)
+ /* The value 0 should be decoded as 8 */
+ node_shift = 8;
+ maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
+
+ pr_info("vSMP CTL: Capping CPUs to %d (CONFIG_X86_VSMP is unset)\n",
+ maxcpus);
+ setup_max_cpus = maxcpus;
+ early_iounmap(address, 4);
+}
+
void __init vsmp_init(void)
{
detect_vsmp_box();
if (!is_vsmp_box())
return;
+ vsmp_cap_cpus();
+
set_vsmp_pv_ops();
return;
}
--
1.7.6.5
Commit-ID: 824a6ae65f085255464155760cb9628a2f0deb29
Gitweb: http://git.kernel.org/tip/824a6ae65f085255464155760cb9628a2f0deb29
Author: Shai Fultheim <[email protected]>
AuthorDate: Tue, 8 May 2012 10:34:15 +0300
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 8 May 2012 11:24:45 +0200
vsmp: Fix number of CPUs when vsmp is disabled
In case CONFIG_X86_VSMP is not set, limit the number of CPUs to
the number of CPUs of the first board.
Signed-off-by: Shai Fultheim <[email protected]>
[[email protected]: rebased, fixed minor coding-style issues]
Signed-off-by: Ido Yariv <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/vsmp_64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index a1d804b..6aa0d59 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/pci_ids.h>
#include <linux/pci_regs.h>
+#include <linux/smp.h>
#include <asm/apic.h>
#include <asm/pci-direct.h>
@@ -22,6 +23,8 @@
#include <asm/paravirt.h>
#include <asm/setup.h>
+#define TOPOLOGY_REGISTER_OFFSET 0x10
+
#if defined CONFIG_PCI && defined CONFIG_PARAVIRT
/*
* Interrupt control on vSMPowered systems:
@@ -149,12 +152,52 @@ int is_vsmp_box(void)
return 0;
}
#endif
+
+static void __init vsmp_cap_cpus(void)
+{
+ void __iomem *address;
+ unsigned int cfg, topology, node_shift, maxcpus;
+
+#ifdef CONFIG_X86_VSMP
+ /* VSMP is enabled, no need to cap cpus */
+ return;
+#endif
+
+ /*
+ * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
+ * ones present in the first board, unless explicitly overridden by
+ * setup_max_cpus
+ */
+ if (setup_max_cpus != NR_CPUS)
+ return;
+
+ /* Read the vSMP Foundation topology register */
+ cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
+ address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
+ if (WARN_ON(!address))
+ return;
+
+ topology = readl(address);
+ node_shift = (topology >> 16) & 0x7;
+ if (!node_shift)
+ /* The value 0 should be decoded as 8 */
+ node_shift = 8;
+ maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
+
+ pr_info("vSMP CTL: Capping CPUs to %d (CONFIG_X86_VSMP is unset)\n",
+ maxcpus);
+ setup_max_cpus = maxcpus;
+ early_iounmap(address, 4);
+}
+
void __init vsmp_init(void)
{
detect_vsmp_box();
if (!is_vsmp_box())
return;
+ vsmp_cap_cpus();
+
set_vsmp_pv_ops();
return;
}
* tip-bot for Shai Fultheim <[email protected]> wrote:
> Commit-ID: 824a6ae65f085255464155760cb9628a2f0deb29
> Gitweb: http://git.kernel.org/tip/824a6ae65f085255464155760cb9628a2f0deb29
> Author: Shai Fultheim <[email protected]>
> AuthorDate: Tue, 8 May 2012 10:34:15 +0300
> Committer: Ingo Molnar <[email protected]>
> CommitDate: Tue, 8 May 2012 11:24:45 +0200
>
> vsmp: Fix number of CPUs when vsmp is disabled
>
> In case CONFIG_X86_VSMP is not set, limit the number of CPUs to
> the number of CPUs of the first board.
>
> Signed-off-by: Shai Fultheim <[email protected]>
> [[email protected]: rebased, fixed minor coding-style issues]
> Signed-off-by: Ido Yariv <[email protected]>
> Link: http://lkml.kernel.org/r/[email protected]
> Signed-off-by: Ingo Molnar <[email protected]>
> ---
> arch/x86/kernel/vsmp_64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 43 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
> index a1d804b..6aa0d59 100644
> --- a/arch/x86/kernel/vsmp_64.c
> +++ b/arch/x86/kernel/vsmp_64.c
> @@ -15,6 +15,7 @@
> #include <linux/init.h>
> #include <linux/pci_ids.h>
> #include <linux/pci_regs.h>
> +#include <linux/smp.h>
>
> #include <asm/apic.h>
> #include <asm/pci-direct.h>
> @@ -22,6 +23,8 @@
> #include <asm/paravirt.h>
> #include <asm/setup.h>
>
> +#define TOPOLOGY_REGISTER_OFFSET 0x10
> +
> #if defined CONFIG_PCI && defined CONFIG_PARAVIRT
> /*
> * Interrupt control on vSMPowered systems:
> @@ -149,12 +152,52 @@ int is_vsmp_box(void)
> return 0;
> }
> #endif
> +
> +static void __init vsmp_cap_cpus(void)
> +{
> + void __iomem *address;
> + unsigned int cfg, topology, node_shift, maxcpus;
> +
> +#ifdef CONFIG_X86_VSMP
> + /* VSMP is enabled, no need to cap cpus */
> + return;
> +#endif
> +
> + /*
> + * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
> + * ones present in the first board, unless explicitly overridden by
> + * setup_max_cpus
> + */
> + if (setup_max_cpus != NR_CPUS)
> + return;
> +
> + /* Read the vSMP Foundation topology register */
> + cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
> + address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
> + if (WARN_ON(!address))
> + return;
> +
> + topology = readl(address);
> + node_shift = (topology >> 16) & 0x7;
> + if (!node_shift)
> + /* The value 0 should be decoded as 8 */
> + node_shift = 8;
> + maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
> +
> + pr_info("vSMP CTL: Capping CPUs to %d (CONFIG_X86_VSMP is unset)\n",
> + maxcpus);
> + setup_max_cpus = maxcpus;
> + early_iounmap(address, 4);
On !CONFIG_SMP this produces the following build failure:
arch/x86/kernel/vsmp_64.c:171:6: error: ‘setup_max_cpus’ undeclared (first use in this function)
Do you want to keep vSMP on UP? If not then you could add a
'depends on SMP' to the vSMP Kconfig entry, avoiding the whole
UP problem space.
Thanks,
Ingo
Hi Ingo,
On Tue, May 08, 2012 at 02:25:49PM +0200, Ingo Molnar wrote:
>
> On !CONFIG_SMP this produces the following build failure:
>
> arch/x86/kernel/vsmp_64.c:171:6: error: ‘setup_max_cpus’ undeclared (first use in this function)
>
> Do you want to keep vSMP on UP? If not then you could add a
> 'depends on SMP' to the vSMP Kconfig entry, avoiding the whole
> UP problem space.
Oops, sorry for that.
vsmp_64.c is built even if CONFIG_X86_VSMP is not set, so even if we set
this dependency, it will not fix this issue.
How about the following CONFIG_SMP check instead?
Thanks,
Ido.
>From b3c6d985b101364dd74f0efaf42c6b34fc7615f9 Mon Sep 17 00:00:00 2001
From: Shai Fultheim <[email protected]>
Date: Mon, 16 Apr 2012 10:39:35 +0300
Subject: [PATCH] vsmp: Fix number of CPUs when vsmp is disabled
In case CONFIG_X86_VSMP is not set, limit the number of CPUs to the
number of CPUs of the first board.
Signed-off-by: Shai Fultheim <[email protected]>
[[email protected]: rebased, fixed minor coding-style issues]
Signed-off-by: Ido Yariv <[email protected]>
---
arch/x86/kernel/vsmp_64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index a1d804b..06779b7 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/pci_ids.h>
#include <linux/pci_regs.h>
+#include <linux/smp.h>
#include <asm/apic.h>
#include <asm/pci-direct.h>
@@ -22,6 +23,8 @@
#include <asm/paravirt.h>
#include <asm/setup.h>
+#define TOPOLOGY_REGISTER_OFFSET 0x10
+
#if defined CONFIG_PCI && defined CONFIG_PARAVIRT
/*
* Interrupt control on vSMPowered systems:
@@ -149,12 +152,52 @@ int is_vsmp_box(void)
return 0;
}
#endif
+
+static void __init vsmp_cap_cpus(void)
+{
+ void __iomem *address;
+ unsigned int cfg, topology, node_shift, maxcpus;
+
+#ifdef CONFIG_X86_VSMP
+ /* VSMP is enabled, no need to cap cpus */
+ return;
+#elif CONFIG_SMP
+ /*
+ * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
+ * ones present in the first board, unless explicitly overridden by
+ * setup_max_cpus
+ */
+ if (setup_max_cpus != NR_CPUS)
+ return;
+
+ /* Read the vSMP Foundation topology register */
+ cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
+ address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
+ if (WARN_ON(!address))
+ return;
+
+ topology = readl(address);
+ node_shift = (topology >> 16) & 0x7;
+ if (!node_shift)
+ /* The value 0 should be decoded as 8 */
+ node_shift = 8;
+ maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
+
+ pr_info("vSMP CTL: Capping CPUs to %d (CONFIG_X86_VSMP is unset)\n",
+ maxcpus);
+ setup_max_cpus = maxcpus;
+ early_iounmap(address, 4);
+#endif
+}
+
void __init vsmp_init(void)
{
detect_vsmp_box();
if (!is_vsmp_box())
return;
+ vsmp_cap_cpus();
+
set_vsmp_pv_ops();
return;
}
--
1.7.6.5
On Wed, May 09, 2012 at 11:03:35AM +0300, Ido Yariv wrote:
> +#ifdef CONFIG_X86_VSMP
> + /* VSMP is enabled, no need to cap cpus */
> + return;
> +#elif CONFIG_SMP
I've missed a 'defined' here. I'll send a new version right away.
Thanks,
Ido.
From: Shai Fultheim <[email protected]>
In case CONFIG_X86_VSMP is not set, limit the number of CPUs to the
number of CPUs of the first board.
Signed-off-by: Shai Fultheim <[email protected]>
[[email protected]: rebased, fixed minor coding-style issues]
Signed-off-by: Ido Yariv <[email protected]>
---
Changes from v3:
- Don't reference setup_max_cpus if CONFIG_SMP isn't set
arch/x86/kernel/vsmp_64.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index a1d804b..5234c83 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/pci_ids.h>
#include <linux/pci_regs.h>
+#include <linux/smp.h>
#include <asm/apic.h>
#include <asm/pci-direct.h>
@@ -22,6 +23,8 @@
#include <asm/paravirt.h>
#include <asm/setup.h>
+#define TOPOLOGY_REGISTER_OFFSET 0x10
+
#if defined CONFIG_PCI && defined CONFIG_PARAVIRT
/*
* Interrupt control on vSMPowered systems:
@@ -149,12 +152,52 @@ int is_vsmp_box(void)
return 0;
}
#endif
+
+static void __init vsmp_cap_cpus(void)
+{
+ void __iomem *address;
+ unsigned int cfg, topology, node_shift, maxcpus;
+
+#ifdef CONFIG_X86_VSMP
+ /* VSMP is enabled, no need to cap cpus */
+ return;
+#elif defined(CONFIG_SMP)
+ /*
+ * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
+ * ones present in the first board, unless explicitly overridden by
+ * setup_max_cpus
+ */
+ if (setup_max_cpus != NR_CPUS)
+ return;
+
+ /* Read the vSMP Foundation topology register */
+ cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
+ address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
+ if (WARN_ON(!address))
+ return;
+
+ topology = readl(address);
+ node_shift = (topology >> 16) & 0x7;
+ if (!node_shift)
+ /* The value 0 should be decoded as 8 */
+ node_shift = 8;
+ maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
+
+ pr_info("vSMP CTL: Capping CPUs to %d (CONFIG_X86_VSMP is unset)\n",
+ maxcpus);
+ setup_max_cpus = maxcpus;
+ early_iounmap(address, 4);
+#endif
+}
+
void __init vsmp_init(void)
{
detect_vsmp_box();
if (!is_vsmp_box())
return;
+ vsmp_cap_cpus();
+
set_vsmp_pv_ops();
return;
}
--
1.7.6.5
* Ido Yariv <[email protected]> wrote:
> Hi Ingo,
>
> On Tue, May 08, 2012 at 02:25:49PM +0200, Ingo Molnar wrote:
> >
> > On !CONFIG_SMP this produces the following build failure:
> >
> > arch/x86/kernel/vsmp_64.c:171:6: error: ‘setup_max_cpus’ undeclared (first use in this function)
> >
> > Do you want to keep vSMP on UP? If not then you could add a
> > 'depends on SMP' to the vSMP Kconfig entry, avoiding the whole
> > UP problem space.
>
> Oops, sorry for that.
>
> vsmp_64.c is built even if CONFIG_X86_VSMP is not set, so even
> if we set this dependency, it will not fix this issue.
Well, then fix the Makefile rule as well. Is there any point to
using vSMP specific glue on UP kernels?
> How about the following CONFIG_SMP check instead?
Looks pretty ugly, because it just increases the config jungle
instead of reducing it.
Thanks,
Ingo
Ingo Molnar wrote:
> Well, then fix the Makefile rule as well. Is there any point to
> using vSMP specific glue on UP kernels?
Yes - vsmp_64.c is needed even on UP kernel.
This allows single CPU kernels, running on vSMP Foundation (such as installer kernels), to make use of the other virtualization-specific (under CONFIG_PARAVIRT )codes such as set_vsmp_pv_ops().
... thinking about it, I do not see other way to resolve this rather than Ido's suggestion.
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m????????????I?
* Ido Yariv <[email protected]> wrote:
> +static void __init vsmp_cap_cpus(void)
> +{
> + void __iomem *address;
> + unsigned int cfg, topology, node_shift, maxcpus;
> +
> +#ifdef CONFIG_X86_VSMP
> + /* VSMP is enabled, no need to cap cpus */
> + return;
> +#elif defined(CONFIG_SMP)
> + /*
> + * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
I suspect this will throw compiler warnings in the
CONFIG_X86_VSMP && !CONFIG_SMP case.
Why not do something like:
static void __init vsmp_cap_cpus(void)
{
#if !defined(CONFIG_X86_VSMP) && defined(CONFIG_SMP)
...
#endif
}
This keeps the #ifdef complexity reasonably concentrated.
Thanks,
Ingo
On 05/09/2012 08:44 AM, Ingo Molnar wrote:
>
> * Ido Yariv <[email protected]> wrote:
>
>> +static void __init vsmp_cap_cpus(void)
>> +{
>> + void __iomem *address;
>> + unsigned int cfg, topology, node_shift, maxcpus;
>> +
>> +#ifdef CONFIG_X86_VSMP
>> + /* VSMP is enabled, no need to cap cpus */
>> + return;
>> +#elif defined(CONFIG_SMP)
>> + /*
>> + * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
>
> I suspect this will throw compiler warnings in the
> CONFIG_X86_VSMP && !CONFIG_SMP case.
>
What on Earth is the point of allowing that combination? Why not make
X86_VSMP depend on SMP and reduce the testing matrix?
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
Hi,
On Wed, May 09, 2012 at 08:55:54AM -0700, H. Peter Anvin wrote:
> On 05/09/2012 08:44 AM, Ingo Molnar wrote:
> >
> > * Ido Yariv <[email protected]> wrote:
> >
> >> +static void __init vsmp_cap_cpus(void)
> >> +{
> >> + void __iomem *address;
> >> + unsigned int cfg, topology, node_shift, maxcpus;
> >> +
> >> +#ifdef CONFIG_X86_VSMP
> >> + /* VSMP is enabled, no need to cap cpus */
> >> + return;
> >> +#elif defined(CONFIG_SMP)
> >> + /*
> >> + * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
> >
> > I suspect this will throw compiler warnings in the
> > CONFIG_X86_VSMP && !CONFIG_SMP case.
> >
>
> What on Earth is the point of allowing that combination? Why not make
> X86_VSMP depend on SMP and reduce the testing matrix?
CONFIG_X86_VSMP shouldn't be used without CONFIG_SMP, so we can safely
add this dependency.
Ingo's suggestion will still fix unreferenced variables warnings, so how
about the following patch?
Thanks,
Ido.
>From 6fa023be44749092088618379f13d7a3e086d692 Mon Sep 17 00:00:00 2001
From: Shai Fultheim <[email protected]>
Date: Mon, 16 Apr 2012 10:39:35 +0300
Subject: [PATCH v5] vsmp: Fix number of CPUs when vsmp is disabled
In case CONFIG_X86_VSMP is not set, limit the number of CPUs to the
number of CPUs of the first board.
Also make CONFIG_X86_VSMP depend on CONFIG_SMP, as there's little
point in having a vsmp machine with a single CPU.
Signed-off-by: Shai Fultheim <[email protected]>
[[email protected]: rebased, fixed minor coding-style issues]
Signed-off-by: Ido Yariv <[email protected]>
---
arch/x86/Kconfig | 1 +
arch/x86/kernel/vsmp_64.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c9866b0..b1e98c9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -374,6 +374,7 @@ config X86_VSMP
select PARAVIRT
depends on X86_64 && PCI
depends on X86_EXTENDED_PLATFORM
+ depends on SMP
---help---
Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
supposed to run on these EM64T-based machines. Only choose this option
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index a1d804b..8eeb55a 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/pci_ids.h>
#include <linux/pci_regs.h>
+#include <linux/smp.h>
#include <asm/apic.h>
#include <asm/pci-direct.h>
@@ -22,6 +23,8 @@
#include <asm/paravirt.h>
#include <asm/setup.h>
+#define TOPOLOGY_REGISTER_OFFSET 0x10
+
#if defined CONFIG_PCI && defined CONFIG_PARAVIRT
/*
* Interrupt control on vSMPowered systems:
@@ -149,12 +152,49 @@ int is_vsmp_box(void)
return 0;
}
#endif
+
+static void __init vsmp_cap_cpus(void)
+{
+#if !defined(CONFIG_X86_VSMP) && defined(CONFIG_SMP)
+ void __iomem *address;
+ unsigned int cfg, topology, node_shift, maxcpus;
+
+ /*
+ * CONFIG_X86_VSMP is not configured, so limit the number CPUs to the
+ * ones present in the first board, unless explicitly overridden by
+ * setup_max_cpus
+ */
+ if (setup_max_cpus != NR_CPUS)
+ return;
+
+ /* Read the vSMP Foundation topology register */
+ cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
+ address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
+ if (WARN_ON(!address))
+ return;
+
+ topology = readl(address);
+ node_shift = (topology >> 16) & 0x7;
+ if (!node_shift)
+ /* The value 0 should be decoded as 8 */
+ node_shift = 8;
+ maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
+
+ pr_info("vSMP CTL: Capping CPUs to %d (CONFIG_X86_VSMP is unset)\n",
+ maxcpus);
+ setup_max_cpus = maxcpus;
+ early_iounmap(address, 4);
+#endif
+}
+
void __init vsmp_init(void)
{
detect_vsmp_box();
if (!is_vsmp_box())
return;
+ vsmp_cap_cpus();
+
set_vsmp_pv_ops();
return;
}
--
1.7.6.5
Looks good.
--Shai
> -----Original Message-----
> From: Ido Yariv [mailto:[email protected]]
> Sent: Friday, May 11, 2012 12:27
> To: H. Peter Anvin
> Cc: Ingo Molnar; [email protected]; Ingo Molnar; Thomas
> Gleixner; Shai Fultheim ([email protected])
> Subject: Re: [PATCH v4] vsmp: Fix number of CPUs when vsmp is disabled
>
> Hi,
>
> On Wed, May 09, 2012 at 08:55:54AM -0700, H. Peter Anvin wrote:
> > On 05/09/2012 08:44 AM, Ingo Molnar wrote:
> > >
> > > * Ido Yariv <[email protected]> wrote:
> > >
> > >> +static void __init vsmp_cap_cpus(void)
> > >> +{
> > >> + void __iomem *address;
> > >> + unsigned int cfg, topology, node_shift, maxcpus;
> > >> +
> > >> +#ifdef CONFIG_X86_VSMP
> > >> + /* VSMP is enabled, no need to cap cpus */
> > >> + return;
> > >> +#elif defined(CONFIG_SMP)
> > >> + /*
> > >> + * CONFIG_X86_VSMP is not configured, so limit the number CPUs to
> the
> > >
> > > I suspect this will throw compiler warnings in the
> > > CONFIG_X86_VSMP && !CONFIG_SMP case.
> > >
> >
> > What on Earth is the point of allowing that combination? Why not make
> > X86_VSMP depend on SMP and reduce the testing matrix?
>
> CONFIG_X86_VSMP shouldn't be used without CONFIG_SMP, so we can
> safely
> add this dependency.
> Ingo's suggestion will still fix unreferenced variables warnings, so how
> about the following patch?
>
> Thanks,
> Ido.
>
> From 6fa023be44749092088618379f13d7a3e086d692 Mon Sep 17 00:00:00
> 2001
> From: Shai Fultheim <[email protected]>
> Date: Mon, 16 Apr 2012 10:39:35 +0300
> Subject: [PATCH v5] vsmp: Fix number of CPUs when vsmp is disabled
>
> In case CONFIG_X86_VSMP is not set, limit the number of CPUs to the
> number of CPUs of the first board.
>
> Also make CONFIG_X86_VSMP depend on CONFIG_SMP, as there's little
> point in having a vsmp machine with a single CPU.
>
> Signed-off-by: Shai Fultheim <[email protected]>
> [[email protected]: rebased, fixed minor coding-style issues]
> Signed-off-by: Ido Yariv <[email protected]>
> ---
> arch/x86/Kconfig | 1 +
> arch/x86/kernel/vsmp_64.c | 40
> ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index c9866b0..b1e98c9 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -374,6 +374,7 @@ config X86_VSMP
> select PARAVIRT
> depends on X86_64 && PCI
> depends on X86_EXTENDED_PLATFORM
> + depends on SMP
> ---help---
> Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
> supposed to run on these EM64T-based machines. Only choose this
> option
> diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
> index a1d804b..8eeb55a 100644
> --- a/arch/x86/kernel/vsmp_64.c
> +++ b/arch/x86/kernel/vsmp_64.c
> @@ -15,6 +15,7 @@
> #include <linux/init.h>
> #include <linux/pci_ids.h>
> #include <linux/pci_regs.h>
> +#include <linux/smp.h>
>
> #include <asm/apic.h>
> #include <asm/pci-direct.h>
> @@ -22,6 +23,8 @@
> #include <asm/paravirt.h>
> #include <asm/setup.h>
>
> +#define TOPOLOGY_REGISTER_OFFSET 0x10
> +
> #if defined CONFIG_PCI && defined CONFIG_PARAVIRT
> /*
> * Interrupt control on vSMPowered systems:
> @@ -149,12 +152,49 @@ int is_vsmp_box(void)
> return 0;
> }
> #endif
> +
> +static void __init vsmp_cap_cpus(void)
> +{
> +#if !defined(CONFIG_X86_VSMP) && defined(CONFIG_SMP)
> + void __iomem *address;
> + unsigned int cfg, topology, node_shift, maxcpus;
> +
> + /*
> + * CONFIG_X86_VSMP is not configured, so limit the number CPUs to
> the
> + * ones present in the first board, unless explicitly overridden by
> + * setup_max_cpus
> + */
> + if (setup_max_cpus != NR_CPUS)
> + return;
> +
> + /* Read the vSMP Foundation topology register */
> + cfg = read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0);
> + address = early_ioremap(cfg + TOPOLOGY_REGISTER_OFFSET, 4);
> + if (WARN_ON(!address))
> + return;
> +
> + topology = readl(address);
> + node_shift = (topology >> 16) & 0x7;
> + if (!node_shift)
> + /* The value 0 should be decoded as 8 */
> + node_shift = 8;
> + maxcpus = (topology & ((1 << node_shift) - 1)) + 1;
> +
> + pr_info("vSMP CTL: Capping CPUs to %d (CONFIG_X86_VSMP is
> unset)\n",
> + maxcpus);
> + setup_max_cpus = maxcpus;
> + early_iounmap(address, 4);
> +#endif
> +}
> +
> void __init vsmp_init(void)
> {
> detect_vsmp_box();
> if (!is_vsmp_box())
> return;
>
> + vsmp_cap_cpus();
> +
> set_vsmp_pv_ops();
> return;
> }
> --
> 1.7.6.5