All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] x86,cpu-hotplug: assign same CPU number to readded CPU
@ 2014-07-23  3:22 Yasuaki Ishimatsu
  2014-07-28  4:18 ` Yasuaki Ishimatsu
  0 siblings, 1 reply; 9+ messages in thread
From: Yasuaki Ishimatsu @ 2014-07-23  3:22 UTC (permalink / raw)
  To: tglx, mingo, hpa, bp, gong.chen, tony.luck, toshi.kani
  Cc: x86, imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, umgwanakikbuti, peterz

llc_shared_map is not cleared even if CPU is offline or hot removed.
So when hot-plugging CPU and assigning new CPU number to hot-added CPU,
the mask has wrong value. The mask is used by CSF schduler to create
sched_domain. So it breaks CFS scheduler.

Here is a example on my system.
My system has 4 sockets and each socket has 15 cores and HT is enabled.
In this case, each core of sockes is numbered as follows:

          | CPU#
Socket#0 | 0-14 , 60-74
Socket#1 | 15-29, 75-89
Socket#2 | 30-44, 90-104
Socket#3 | 45-59, 105-119

Then llc_shared_mask of CPU#30 has 0x3fff80000001fffc0000000.
It means that last level cache of Socket#2 is shared with
CPU#30-44 and 90-104.

When hot-removing socket#2 and #3, each core of sockets is numbered
as follows:

          | CPU#
Socket#0 | 0-14 , 60-74
Socket#1 | 15-29, 75-89

But llc_shared_mask is not cleared. So llc_shared_mask of CPU#30 remains
having 0x3fff80000001fffc0000000.

After that, when hot-adding socket#2 and #3, each core of sockets is
numbered as follows:

          | CPU#
Socket#0 | 0-14 , 60-74
Socket#1 | 15-29, 75-89
Socket#2 | 30-59
Socket#3 | 90-119

Then llc_shared_mask of CPU#30 becomes 0x3fff8000fffffffc0000000.
It means that last level cache of Socket#2 is shared with CPU#30-59
and 90-104. So the mask has wrong value.

At first, I cleared hot-removed CPU number's bit from llc_shared_map
when hot removing CPU. But Borislav suggested that the problem will
disappear if readded CPU is assigned same CPU number. And llc_shared_map
must not be changed.

So the patch assigns same CPU number to readded CPU by linking CPU
number to APIC ID. And by the patch, the problem disappers.

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Suggested-by: Borislav Petkov <bp@alien8.de>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
---
v2: change cpuid to cpunum
v3: fix Borislav's email address of Suggested-by
     fix typo (ACPI ID to APIC ID)
v4: change cpu_used_xxx to cpu_number_xxx
---
  arch/x86/kernel/apic/apic.c | 33 ++++++++++++++++++++++++++++++++-
  1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index ad28db7..5cecc3b 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -220,6 +220,23 @@ static void apic_pm_activate(void);
  static unsigned long apic_phys;

  /*
+ * Bind APIC ID to Logical CPU number
+ * Logical CPU number to APIC ID does not change by this array
+ * even if CPU is hotplugged. So don't clear the array even if
+ * CPU is hot-removed
+ */
+static int apicid_to_cpunum[MAX_LOCAL_APIC] = {
+	[0 ... MAX_LOCAL_APIC-1] = -1,
+};
+
+/*
+ * Represent Logical CPU number bound to APIC ID
+ * Don't clear a bit even if CPU is hot-removed
+ */
+static DECLARE_BITMAP(cpu_number_bits, CONFIG_NR_CPUS);
+static struct cpumask *const cpu_number_mask = to_cpumask(cpu_number_bits);
+
+/*
   * Get the LAPIC version
   */
  static inline int lapic_get_version(void)
@@ -2122,6 +2139,17 @@ void disconnect_bsp_APIC(int virt_wire_setup)
  	apic_write(APIC_LVT1, value);
  }

+static int get_cpunum(int apicid)
+{
+	int cpu;
+
+	cpu = apicid_to_cpunum[apicid];
+	if (cpu < 0)
+		cpu = cpumask_next_zero(-1, cpu_number_mask);
+
+	return cpu;
+}
+
  int generic_processor_info(int apicid, int version)
  {
  	int cpu, max = nr_cpu_ids;
@@ -2199,7 +2227,9 @@ int generic_processor_info(int apicid, int version)
  		 */
  		cpu = 0;
  	} else
-		cpu = cpumask_next_zero(-1, cpu_present_mask);
+		cpu = get_cpunum(apicid);
+
+	apicid_to_cpunum[apicid] = cpu;

  	/*
  	 * Validate version
@@ -2228,6 +2258,7 @@ int generic_processor_info(int apicid, int version)
  	early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
  		apic->x86_32_early_logical_apicid(cpu);
  #endif
+	cpumask_set_cpu(cpu, cpu_number_mask);
  	set_cpu_possible(cpu, true);
  	set_cpu_present(cpu, true);


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

* Re: [PATCH v4] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-07-23  3:22 [PATCH v4] x86,cpu-hotplug: assign same CPU number to readded CPU Yasuaki Ishimatsu
@ 2014-07-28  4:18 ` Yasuaki Ishimatsu
  2014-09-04  2:46   ` [PATCH v5] " Yasuaki Ishimatsu
  0 siblings, 1 reply; 9+ messages in thread
From: Yasuaki Ishimatsu @ 2014-07-28  4:18 UTC (permalink / raw)
  To: tglx, mingo, hpa, bp, gong.chen, tony.luck, toshi.kani
  Cc: x86, imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, umgwanakikbuti, peterz

Ping.

(2014/07/23 12:22), Yasuaki Ishimatsu wrote:
> llc_shared_map is not cleared even if CPU is offline or hot removed.
> So when hot-plugging CPU and assigning new CPU number to hot-added CPU,
> the mask has wrong value. The mask is used by CSF schduler to create
> sched_domain. So it breaks CFS scheduler.
>
> Here is a example on my system.
> My system has 4 sockets and each socket has 15 cores and HT is enabled.
> In this case, each core of sockes is numbered as follows:
>
>           | CPU#
> Socket#0 | 0-14 , 60-74
> Socket#1 | 15-29, 75-89
> Socket#2 | 30-44, 90-104
> Socket#3 | 45-59, 105-119
>
> Then llc_shared_mask of CPU#30 has 0x3fff80000001fffc0000000.
> It means that last level cache of Socket#2 is shared with
> CPU#30-44 and 90-104.
>
> When hot-removing socket#2 and #3, each core of sockets is numbered
> as follows:
>
>           | CPU#
> Socket#0 | 0-14 , 60-74
> Socket#1 | 15-29, 75-89
>
> But llc_shared_mask is not cleared. So llc_shared_mask of CPU#30 remains
> having 0x3fff80000001fffc0000000.
>
> After that, when hot-adding socket#2 and #3, each core of sockets is
> numbered as follows:
>
>           | CPU#
> Socket#0 | 0-14 , 60-74
> Socket#1 | 15-29, 75-89
> Socket#2 | 30-59
> Socket#3 | 90-119
>
> Then llc_shared_mask of CPU#30 becomes 0x3fff8000fffffffc0000000.
> It means that last level cache of Socket#2 is shared with CPU#30-59
> and 90-104. So the mask has wrong value.
>
> At first, I cleared hot-removed CPU number's bit from llc_shared_map
> when hot removing CPU. But Borislav suggested that the problem will
> disappear if readded CPU is assigned same CPU number. And llc_shared_map
> must not be changed.
>
> So the patch assigns same CPU number to readded CPU by linking CPU
> number to APIC ID. And by the patch, the problem disappers.
>
> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Reviewed-by: Toshi Kani <toshi.kani@hp.com>
> ---
> v2: change cpuid to cpunum
> v3: fix Borislav's email address of Suggested-by
>      fix typo (ACPI ID to APIC ID)
> v4: change cpu_used_xxx to cpu_number_xxx
> ---
>   arch/x86/kernel/apic/apic.c | 33 ++++++++++++++++++++++++++++++++-
>   1 file changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> index ad28db7..5cecc3b 100644
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -220,6 +220,23 @@ static void apic_pm_activate(void);
>   static unsigned long apic_phys;
>
>   /*
> + * Bind APIC ID to Logical CPU number
> + * Logical CPU number to APIC ID does not change by this array
> + * even if CPU is hotplugged. So don't clear the array even if
> + * CPU is hot-removed
> + */
> +static int apicid_to_cpunum[MAX_LOCAL_APIC] = {
> +    [0 ... MAX_LOCAL_APIC-1] = -1,
> +};
> +
> +/*
> + * Represent Logical CPU number bound to APIC ID
> + * Don't clear a bit even if CPU is hot-removed
> + */
> +static DECLARE_BITMAP(cpu_number_bits, CONFIG_NR_CPUS);
> +static struct cpumask *const cpu_number_mask = to_cpumask(cpu_number_bits);
> +
> +/*
>    * Get the LAPIC version
>    */
>   static inline int lapic_get_version(void)
> @@ -2122,6 +2139,17 @@ void disconnect_bsp_APIC(int virt_wire_setup)
>       apic_write(APIC_LVT1, value);
>   }
>
> +static int get_cpunum(int apicid)
> +{
> +    int cpu;
> +
> +    cpu = apicid_to_cpunum[apicid];
> +    if (cpu < 0)
> +        cpu = cpumask_next_zero(-1, cpu_number_mask);
> +
> +    return cpu;
> +}
> +
>   int generic_processor_info(int apicid, int version)
>   {
>       int cpu, max = nr_cpu_ids;
> @@ -2199,7 +2227,9 @@ int generic_processor_info(int apicid, int version)
>            */
>           cpu = 0;
>       } else
> -        cpu = cpumask_next_zero(-1, cpu_present_mask);
> +        cpu = get_cpunum(apicid);
> +
> +    apicid_to_cpunum[apicid] = cpu;
>
>       /*
>        * Validate version
> @@ -2228,6 +2258,7 @@ int generic_processor_info(int apicid, int version)
>       early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
>           apic->x86_32_early_logical_apicid(cpu);
>   #endif
> +    cpumask_set_cpu(cpu, cpu_number_mask);
>       set_cpu_possible(cpu, true);
>       set_cpu_present(cpu, true);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



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

* [PATCH v5] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-07-28  4:18 ` Yasuaki Ishimatsu
@ 2014-09-04  2:46   ` Yasuaki Ishimatsu
  2014-09-11  7:21     ` Yasuaki Ishimatsu
  0 siblings, 1 reply; 9+ messages in thread
From: Yasuaki Ishimatsu @ 2014-09-04  2:46 UTC (permalink / raw)
  To: tglx, mingo, hpa, bp, gong.chen, tony.luck, toshi.kani
  Cc: x86, imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, umgwanakikbuti, peterz

llc_shared_map is not cleared even if CPU is offline or hot removed.
So when hot-plugging CPU and assigning new CPU number to hot-added CPU,
the mask has wrong value. The mask is used by CSF schduler to create
sched_domain. So it breaks CFS scheduler.

Here is a example on my system.
My system has 4 sockets and each socket has 15 cores and HT is enabled.
In this case, each core of sockes is numbered as follows:

          | CPU#
Socket#0 | 0-14 , 60-74
Socket#1 | 15-29, 75-89
Socket#2 | 30-44, 90-104
Socket#3 | 45-59, 105-119

Then llc_shared_mask of CPU#30 has 0x3fff80000001fffc0000000.
It means that last level cache of Socket#2 is shared with
CPU#30-44 and 90-104.

When hot-removing socket#2 and #3, each core of sockets is numbered
as follows:

          | CPU#
Socket#0 | 0-14 , 60-74
Socket#1 | 15-29, 75-89

But llc_shared_mask is not cleared. So llc_shared_mask of CPU#30 remains
having 0x3fff80000001fffc0000000.

After that, when hot-adding socket#2 and #3, each core of sockets is
numbered as follows:

          | CPU#
Socket#0 | 0-14 , 60-74
Socket#1 | 15-29, 75-89
Socket#2 | 30-59
Socket#3 | 90-119

Then llc_shared_mask of CPU#30 becomes 0x3fff8000fffffffc0000000.
It means that last level cache of Socket#2 is shared with CPU#30-59
and 90-104. So the mask has wrong value.

At first, I cleared hot-removed CPU number's bit from llc_shared_map
when hot removing CPU. But Borislav suggested that the problem will
disappear if readded CPU is assigned same CPU number. And llc_shared_map
must not be changed.

So the patch assigns same CPU number to readded CPU by linking CPU
number to APIC ID. And by the patch, the problem disappers.

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Suggested-by: Borislav Petkov <bp@alien8.de>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
---
v2: change cpuid to cpunum
v3: fix Borislav's email address of Suggested-by
     fix typo (ACPI ID to APIC ID)
v4: change cpu_used_xxx to cpu_number_xxx
v5: rebase to 3.17-rc3
---
  arch/x86/kernel/apic/apic.c | 33 ++++++++++++++++++++++++++++++++-
  1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 6776027..c476827 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -220,6 +220,23 @@ static void apic_pm_activate(void);
  static unsigned long apic_phys;

  /*
+ * Bind APIC ID to Logical CPU number
+ * Logical CPU number to APIC ID does not change by this array
+ * even if CPU is hotplugged. So don't clear the array even if
+ * CPU is hot-removed
+ */
+static int apicid_to_cpunum[MAX_LOCAL_APIC] = {
+	[0 ... MAX_LOCAL_APIC-1] = -1,
+};
+
+/*
+ * Represent Logical CPU number bound to APIC ID
+ * Don't clear a bit even if CPU is hot-removed
+ */
+static DECLARE_BITMAP(cpu_number_bits, CONFIG_NR_CPUS);
+static struct cpumask *const cpu_number_mask = to_cpumask(cpu_number_bits);
+
+/*
   * Get the LAPIC version
   */
  static inline int lapic_get_version(void)
@@ -2109,6 +2126,17 @@ void disconnect_bsp_APIC(int virt_wire_setup)
  	apic_write(APIC_LVT1, value);
  }

+static int get_cpunum(int apicid)
+{
+	int cpu;
+
+	cpu = apicid_to_cpunum[apicid];
+	if (cpu < 0)
+		cpu = cpumask_next_zero(-1, cpu_number_mask);
+
+	return cpu;
+}
+
  int generic_processor_info(int apicid, int version)
  {
  	int cpu, max = nr_cpu_ids;
@@ -2186,7 +2214,9 @@ int generic_processor_info(int apicid, int version)
  		 */
  		cpu = 0;
  	} else
-		cpu = cpumask_next_zero(-1, cpu_present_mask);
+		cpu = get_cpunum(apicid);
+
+	apicid_to_cpunum[apicid] = cpu;

  	/*
  	 * Validate version
@@ -2215,6 +2245,7 @@ int generic_processor_info(int apicid, int version)
  	early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
  		apic->x86_32_early_logical_apicid(cpu);
  #endif
+	cpumask_set_cpu(cpu, cpu_number_mask);
  	set_cpu_possible(cpu, true);
  	set_cpu_present(cpu, true);

-- 
1.8.3.1



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

* Re: [PATCH v5] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-09-04  2:46   ` [PATCH v5] " Yasuaki Ishimatsu
@ 2014-09-11  7:21     ` Yasuaki Ishimatsu
  2014-09-15  4:25       ` Mike Galbraith
  0 siblings, 1 reply; 9+ messages in thread
From: Yasuaki Ishimatsu @ 2014-09-11  7:21 UTC (permalink / raw)
  To: tglx, mingo, hpa, bp, gong.chen, tony.luck, toshi.kani
  Cc: x86, imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, umgwanakikbuti, peterz

There is no response for two months since posting v4.
What can I do for pushing the patch to upstream?

Thanks,
Yasuaki Ishimatsu

(2014/09/04 11:46), Yasuaki Ishimatsu wrote:
> llc_shared_map is not cleared even if CPU is offline or hot removed.
> So when hot-plugging CPU and assigning new CPU number to hot-added CPU,
> the mask has wrong value. The mask is used by CSF schduler to create
> sched_domain. So it breaks CFS scheduler.
>
> Here is a example on my system.
> My system has 4 sockets and each socket has 15 cores and HT is enabled.
> In this case, each core of sockes is numbered as follows:
>
>           | CPU#
> Socket#0 | 0-14 , 60-74
> Socket#1 | 15-29, 75-89
> Socket#2 | 30-44, 90-104
> Socket#3 | 45-59, 105-119
>
> Then llc_shared_mask of CPU#30 has 0x3fff80000001fffc0000000.
> It means that last level cache of Socket#2 is shared with
> CPU#30-44 and 90-104.
>
> When hot-removing socket#2 and #3, each core of sockets is numbered
> as follows:
>
>           | CPU#
> Socket#0 | 0-14 , 60-74
> Socket#1 | 15-29, 75-89
>
> But llc_shared_mask is not cleared. So llc_shared_mask of CPU#30 remains
> having 0x3fff80000001fffc0000000.
>
> After that, when hot-adding socket#2 and #3, each core of sockets is
> numbered as follows:
>
>           | CPU#
> Socket#0 | 0-14 , 60-74
> Socket#1 | 15-29, 75-89
> Socket#2 | 30-59
> Socket#3 | 90-119
>
> Then llc_shared_mask of CPU#30 becomes 0x3fff8000fffffffc0000000.
> It means that last level cache of Socket#2 is shared with CPU#30-59
> and 90-104. So the mask has wrong value.
>
> At first, I cleared hot-removed CPU number's bit from llc_shared_map
> when hot removing CPU. But Borislav suggested that the problem will
> disappear if readded CPU is assigned same CPU number. And llc_shared_map
> must not be changed.
>
> So the patch assigns same CPU number to readded CPU by linking CPU
> number to APIC ID. And by the patch, the problem disappers.
>
> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Reviewed-by: Toshi Kani <toshi.kani@hp.com>
> ---
> v2: change cpuid to cpunum
> v3: fix Borislav's email address of Suggested-by
>      fix typo (ACPI ID to APIC ID)
> v4: change cpu_used_xxx to cpu_number_xxx
> v5: rebase to 3.17-rc3
> ---
>   arch/x86/kernel/apic/apic.c | 33 ++++++++++++++++++++++++++++++++-
>   1 file changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> index 6776027..c476827 100644
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -220,6 +220,23 @@ static void apic_pm_activate(void);
>   static unsigned long apic_phys;
>
>   /*
> + * Bind APIC ID to Logical CPU number
> + * Logical CPU number to APIC ID does not change by this array
> + * even if CPU is hotplugged. So don't clear the array even if
> + * CPU is hot-removed
> + */
> +static int apicid_to_cpunum[MAX_LOCAL_APIC] = {
> +    [0 ... MAX_LOCAL_APIC-1] = -1,
> +};
> +
> +/*
> + * Represent Logical CPU number bound to APIC ID
> + * Don't clear a bit even if CPU is hot-removed
> + */
> +static DECLARE_BITMAP(cpu_number_bits, CONFIG_NR_CPUS);
> +static struct cpumask *const cpu_number_mask = to_cpumask(cpu_number_bits);
> +
> +/*
>    * Get the LAPIC version
>    */
>   static inline int lapic_get_version(void)
> @@ -2109,6 +2126,17 @@ void disconnect_bsp_APIC(int virt_wire_setup)
>       apic_write(APIC_LVT1, value);
>   }
>
> +static int get_cpunum(int apicid)
> +{
> +    int cpu;
> +
> +    cpu = apicid_to_cpunum[apicid];
> +    if (cpu < 0)
> +        cpu = cpumask_next_zero(-1, cpu_number_mask);
> +
> +    return cpu;
> +}
> +
>   int generic_processor_info(int apicid, int version)
>   {
>       int cpu, max = nr_cpu_ids;
> @@ -2186,7 +2214,9 @@ int generic_processor_info(int apicid, int version)
>            */
>           cpu = 0;
>       } else
> -        cpu = cpumask_next_zero(-1, cpu_present_mask);
> +        cpu = get_cpunum(apicid);
> +
> +    apicid_to_cpunum[apicid] = cpu;
>
>       /*
>        * Validate version
> @@ -2215,6 +2245,7 @@ int generic_processor_info(int apicid, int version)
>       early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
>           apic->x86_32_early_logical_apicid(cpu);
>   #endif
> +    cpumask_set_cpu(cpu, cpu_number_mask);
>       set_cpu_possible(cpu, true);
>       set_cpu_present(cpu, true);
>



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

* Re: [PATCH v5] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-09-11  7:21     ` Yasuaki Ishimatsu
@ 2014-09-15  4:25       ` Mike Galbraith
  2014-09-15 16:44         ` Toshi Kani
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Galbraith @ 2014-09-15  4:25 UTC (permalink / raw)
  To: Yasuaki Ishimatsu
  Cc: tglx, mingo, hpa, bp, gong.chen, tony.luck, toshi.kani, x86,
	imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, peterz, Wanpeng Li, Linn Crosetto

On Thu, 2014-09-11 at 16:21 +0900, Yasuaki Ishimatsu wrote: 
> There is no response for two months since posting v4.
> What can I do for pushing the patch to upstream?

Looks to me like we have two patches floating about for more or less the
same problem, this one, and...

https://lkml.org/lkml/2014/7/29/159

..this one, which you reviewed, and HP both reviewed and tested.

We seem to kinda stuck with Boris having said don't diddle the
cpu_llc_shared_map, but HP/Intel saying that this map diddling fixes
their explosions.  If your alternative is preferred over diddling
cpu_llc_shared_map, perhaps HP/Intel can test/confirm that their
explosions stay gone? 

> Thanks,
> Yasuaki Ishimatsu
> 
> (2014/09/04 11:46), Yasuaki Ishimatsu wrote:
> > llc_shared_map is not cleared even if CPU is offline or hot removed.
> > So when hot-plugging CPU and assigning new CPU number to hot-added CPU,
> > the mask has wrong value. The mask is used by CSF schduler to create
> > sched_domain. So it breaks CFS scheduler.
> >
> > Here is a example on my system.
> > My system has 4 sockets and each socket has 15 cores and HT is enabled.
> > In this case, each core of sockes is numbered as follows:
> >
> >           | CPU#
> > Socket#0 | 0-14 , 60-74
> > Socket#1 | 15-29, 75-89
> > Socket#2 | 30-44, 90-104
> > Socket#3 | 45-59, 105-119
> >
> > Then llc_shared_mask of CPU#30 has 0x3fff80000001fffc0000000.
> > It means that last level cache of Socket#2 is shared with
> > CPU#30-44 and 90-104.
> >
> > When hot-removing socket#2 and #3, each core of sockets is numbered
> > as follows:
> >
> >           | CPU#
> > Socket#0 | 0-14 , 60-74
> > Socket#1 | 15-29, 75-89
> >
> > But llc_shared_mask is not cleared. So llc_shared_mask of CPU#30 remains
> > having 0x3fff80000001fffc0000000.
> >
> > After that, when hot-adding socket#2 and #3, each core of sockets is
> > numbered as follows:
> >
> >           | CPU#
> > Socket#0 | 0-14 , 60-74
> > Socket#1 | 15-29, 75-89
> > Socket#2 | 30-59
> > Socket#3 | 90-119
> >
> > Then llc_shared_mask of CPU#30 becomes 0x3fff8000fffffffc0000000.
> > It means that last level cache of Socket#2 is shared with CPU#30-59
> > and 90-104. So the mask has wrong value.
> >
> > At first, I cleared hot-removed CPU number's bit from llc_shared_map
> > when hot removing CPU. But Borislav suggested that the problem will
> > disappear if readded CPU is assigned same CPU number. And llc_shared_map
> > must not be changed.
> >
> > So the patch assigns same CPU number to readded CPU by linking CPU
> > number to APIC ID. And by the patch, the problem disappers.
> >
> > Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> > Suggested-by: Borislav Petkov <bp@alien8.de>
> > Reviewed-by: Toshi Kani <toshi.kani@hp.com>
> > ---
> > v2: change cpuid to cpunum
> > v3: fix Borislav's email address of Suggested-by
> >      fix typo (ACPI ID to APIC ID)
> > v4: change cpu_used_xxx to cpu_number_xxx
> > v5: rebase to 3.17-rc3
> > ---
> >   arch/x86/kernel/apic/apic.c | 33 ++++++++++++++++++++++++++++++++-
> >   1 file changed, 32 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> > index 6776027..c476827 100644
> > --- a/arch/x86/kernel/apic/apic.c
> > +++ b/arch/x86/kernel/apic/apic.c
> > @@ -220,6 +220,23 @@ static void apic_pm_activate(void);
> >   static unsigned long apic_phys;
> >
> >   /*
> > + * Bind APIC ID to Logical CPU number
> > + * Logical CPU number to APIC ID does not change by this array
> > + * even if CPU is hotplugged. So don't clear the array even if
> > + * CPU is hot-removed
> > + */
> > +static int apicid_to_cpunum[MAX_LOCAL_APIC] = {
> > +    [0 ... MAX_LOCAL_APIC-1] = -1,
> > +};
> > +
> > +/*
> > + * Represent Logical CPU number bound to APIC ID
> > + * Don't clear a bit even if CPU is hot-removed
> > + */
> > +static DECLARE_BITMAP(cpu_number_bits, CONFIG_NR_CPUS);
> > +static struct cpumask *const cpu_number_mask = to_cpumask(cpu_number_bits);
> > +
> > +/*
> >    * Get the LAPIC version
> >    */
> >   static inline int lapic_get_version(void)
> > @@ -2109,6 +2126,17 @@ void disconnect_bsp_APIC(int virt_wire_setup)
> >       apic_write(APIC_LVT1, value);
> >   }
> >
> > +static int get_cpunum(int apicid)
> > +{
> > +    int cpu;
> > +
> > +    cpu = apicid_to_cpunum[apicid];
> > +    if (cpu < 0)
> > +        cpu = cpumask_next_zero(-1, cpu_number_mask);
> > +
> > +    return cpu;
> > +}
> > +
> >   int generic_processor_info(int apicid, int version)
> >   {
> >       int cpu, max = nr_cpu_ids;
> > @@ -2186,7 +2214,9 @@ int generic_processor_info(int apicid, int version)
> >            */
> >           cpu = 0;
> >       } else
> > -        cpu = cpumask_next_zero(-1, cpu_present_mask);
> > +        cpu = get_cpunum(apicid);
> > +
> > +    apicid_to_cpunum[apicid] = cpu;
> >
> >       /*
> >        * Validate version
> > @@ -2215,6 +2245,7 @@ int generic_processor_info(int apicid, int version)
> >       early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
> >           apic->x86_32_early_logical_apicid(cpu);
> >   #endif
> > +    cpumask_set_cpu(cpu, cpu_number_mask);
> >       set_cpu_possible(cpu, true);
> >       set_cpu_present(cpu, true);
> >
> 
> 



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

* Re: [PATCH v5] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-09-15  4:25       ` Mike Galbraith
@ 2014-09-15 16:44         ` Toshi Kani
  2014-09-16  3:56           ` Mike Galbraith
  0 siblings, 1 reply; 9+ messages in thread
From: Toshi Kani @ 2014-09-15 16:44 UTC (permalink / raw)
  To: Mike Galbraith
  Cc: Yasuaki Ishimatsu, tglx, mingo, hpa, bp, gong.chen, tony.luck,
	x86, imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, peterz, Wanpeng Li, Linn Crosetto

On Mon, 2014-09-15 at 06:25 +0200, Mike Galbraith wrote:
> On Thu, 2014-09-11 at 16:21 +0900, Yasuaki Ishimatsu wrote: 
> > There is no response for two months since posting v4.
> > What can I do for pushing the patch to upstream?
> 
> Looks to me like we have two patches floating about for more or less the
> same problem, this one, and...
> 
> https://lkml.org/lkml/2014/7/29/159
> 
> ..this one, which you reviewed, and HP both reviewed and tested.
> 
> We seem to kinda stuck with Boris having said don't diddle the
> cpu_llc_shared_map, but HP/Intel saying that this map diddling fixes
> their explosions.  If your alternative is preferred over diddling
> cpu_llc_shared_map, perhaps HP/Intel can test/confirm that their
> explosions stay gone? 

Well, Boris mentioned later in his email:
https://lkml.org/lkml/2014/7/22/201

And I agree with his assessment that both patches make sense.  

Thanks,
-Toshi



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

* Re: [PATCH v5] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-09-15 16:44         ` Toshi Kani
@ 2014-09-16  3:56           ` Mike Galbraith
  2014-09-16  9:53             ` Wanpeng Li
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Galbraith @ 2014-09-16  3:56 UTC (permalink / raw)
  To: Toshi Kani
  Cc: Yasuaki Ishimatsu, tglx, mingo, hpa, bp, gong.chen, tony.luck,
	x86, imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, peterz, Wanpeng Li, Linn Crosetto

On Mon, 2014-09-15 at 10:44 -0600, Toshi Kani wrote: 
> On Mon, 2014-09-15 at 06:25 +0200, Mike Galbraith wrote:
> > On Thu, 2014-09-11 at 16:21 +0900, Yasuaki Ishimatsu wrote: 
> > > There is no response for two months since posting v4.
> > > What can I do for pushing the patch to upstream?
> > 
> > Looks to me like we have two patches floating about for more or less the
> > same problem, this one, and...
> > 
> > https://lkml.org/lkml/2014/7/29/159
> > 
> > ..this one, which you reviewed, and HP both reviewed and tested.
> > 
> > We seem to kinda stuck with Boris having said don't diddle the
> > cpu_llc_shared_map, but HP/Intel saying that this map diddling fixes
> > their explosions.  If your alternative is preferred over diddling
> > cpu_llc_shared_map, perhaps HP/Intel can test/confirm that their
> > explosions stay gone? 
> 
> Well, Boris mentioned later in his email:
> https://lkml.org/lkml/2014/7/22/201
> 
> And I agree with his assessment that both patches make sense.  

Nonetheless, this just reeks of "department of redundancy department".
I have nothing against doing both really, but it does leave me wondering
if we would not then be merging the mask clearing "just because".

-Mike


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

* Re: [PATCH v5] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-09-16  3:56           ` Mike Galbraith
@ 2014-09-16  9:53             ` Wanpeng Li
  2014-09-16 10:00               ` Mike Galbraith
  0 siblings, 1 reply; 9+ messages in thread
From: Wanpeng Li @ 2014-09-16  9:53 UTC (permalink / raw)
  To: Mike Galbraith, Toshi Kani
  Cc: Yasuaki Ishimatsu, tglx, mingo, hpa, bp, gong.chen, tony.luck,
	x86, imammedo, huawei.libin, paul.gortmaker, linux-kernel,
	srivatsa.bhat, peterz, Wanpeng Li, Linn Crosetto

Hi Mike,

于 14-9-16 上午11:56, Mike Galbraith 写道:
> On Mon, 2014-09-15 at 10:44 -0600, Toshi Kani wrote:
>> On Mon, 2014-09-15 at 06:25 +0200, Mike Galbraith wrote:
>>> On Thu, 2014-09-11 at 16:21 +0900, Yasuaki Ishimatsu wrote:
>>>> There is no response for two months since posting v4.
>>>> What can I do for pushing the patch to upstream?
>>> Looks to me like we have two patches floating about for more or less the
>>> same problem, this one, and...
>>>
>>> https://lkml.org/lkml/2014/7/29/159
>>>
>>> ..this one, which you reviewed, and HP both reviewed and tested.
>>>
>>> We seem to kinda stuck with Boris having said don't diddle the
>>> cpu_llc_shared_map, but HP/Intel saying that this map diddling fixes
>>> their explosions.  If your alternative is preferred over diddling
>>> cpu_llc_shared_map, perhaps HP/Intel can test/confirm that their
>>> explosions stay gone?
>> Well, Boris mentioned later in his email:
>> https://lkml.org/lkml/2014/7/22/201
>>
>> And I agree with his assessment that both patches make sense.
> Nonetheless, this just reeks of "department of redundancy department".
> I have nothing against doing both really, but it does leave me wondering
> if we would not then be merging the mask clearing "just because".

Maybe you miss my reply.

https://lkml.org/lkml/2014/7/29/40

Regards,
Wanpeng Li

>
> -Mike
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH v5] x86,cpu-hotplug: assign same CPU number to readded CPU
  2014-09-16  9:53             ` Wanpeng Li
@ 2014-09-16 10:00               ` Mike Galbraith
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Galbraith @ 2014-09-16 10:00 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: Toshi Kani, Yasuaki Ishimatsu, tglx, mingo, hpa, bp, gong.chen,
	tony.luck, x86, imammedo, huawei.libin, paul.gortmaker,
	linux-kernel, srivatsa.bhat, peterz, Wanpeng Li, Linn Crosetto

On Tue, 2014-09-16 at 17:53 +0800, Wanpeng Li wrote: 
> Hi Mike,
> 
> 于 14-9-16 上午11:56, Mike Galbraith 写道:
> > On Mon, 2014-09-15 at 10:44 -0600, Toshi Kani wrote:
> >> On Mon, 2014-09-15 at 06:25 +0200, Mike Galbraith wrote:
> >>> On Thu, 2014-09-11 at 16:21 +0900, Yasuaki Ishimatsu wrote:
> >>>> There is no response for two months since posting v4.
> >>>> What can I do for pushing the patch to upstream?
> >>> Looks to me like we have two patches floating about for more or less the
> >>> same problem, this one, and...
> >>>
> >>> https://lkml.org/lkml/2014/7/29/159
> >>>
> >>> ..this one, which you reviewed, and HP both reviewed and tested.
> >>>
> >>> We seem to kinda stuck with Boris having said don't diddle the
> >>> cpu_llc_shared_map, but HP/Intel saying that this map diddling fixes
> >>> their explosions.  If your alternative is preferred over diddling
> >>> cpu_llc_shared_map, perhaps HP/Intel can test/confirm that their
> >>> explosions stay gone?
> >> Well, Boris mentioned later in his email:
> >> https://lkml.org/lkml/2014/7/22/201
> >>
> >> And I agree with his assessment that both patches make sense.
> > Nonetheless, this just reeks of "department of redundancy department".
> > I have nothing against doing both really, but it does leave me wondering
> > if we would not then be merging the mask clearing "just because".
> 
> Maybe you miss my reply.
> 
> https://lkml.org/lkml/2014/7/29/40

Yes, I did.  Thanks.

-Mike


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

end of thread, other threads:[~2014-09-16 10:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23  3:22 [PATCH v4] x86,cpu-hotplug: assign same CPU number to readded CPU Yasuaki Ishimatsu
2014-07-28  4:18 ` Yasuaki Ishimatsu
2014-09-04  2:46   ` [PATCH v5] " Yasuaki Ishimatsu
2014-09-11  7:21     ` Yasuaki Ishimatsu
2014-09-15  4:25       ` Mike Galbraith
2014-09-15 16:44         ` Toshi Kani
2014-09-16  3:56           ` Mike Galbraith
2014-09-16  9:53             ` Wanpeng Li
2014-09-16 10:00               ` Mike Galbraith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.