Skip to contentSkip to conversation

pseries/hotplug: Add CPU-to-node mappings for all present CPUs

PATCH In review Srikar Dronamraju 3 participants 3 messages Oct 12 – Oct 16 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pseries/hotplug: Add CPU-to-node mappings for all present CPUs

When cores are added while the system is running in a lower SMT mode, some threads of those cores remain offline. Moving the system to a higher SMT mode later fails to online those threads.

For example, on a system with four cores:

1. ppc64_cpu --smt=off
2. nproc
expected: 4
3. ppc64_cpu --smt
expected/actual: "SMT is off"
4. drmgr -c cpu -a -q 4
5. ppc64_cpu --smt
expected/actual: "SMT is off"
6. ppc64_cpu --smt=8
7. ppc64_cpu --smt

       expected: SMT=8
       actual:   SMT=1: 4-7; SMT=8: 0-3

8. nproc
expected: 64
actual: 36

Post commit d1099e2276df ("powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs"), when new CPUs are added, the CPU-to-node mapping is currently updated only for CPUs that are immediately onlined. CPUs that are made present but remain offline due to the current SMT mode therefore do not get a CPU-to-node mapping.

When those CPUs are subsequently onlined after switching to a higher SMT mode, the online operation fails because the required CPU-to-node mapping is missing.

Update the CPU-to-node mapping before applying the SMT restrictions so that all newly present CPUs have a node mapping, including CPUs that remain offline in the current SMT mode.

Fixes d1099e2276df ("powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs")
---
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/hotplug-cpu.c +1 -1
index bc6926dbf148..b5dc942eec63 100644
@@ -402,6 +402,7 @@ static int dlpar_online_cpu(struct device_node *dn)
 			if (get_hard_smp_processor_id(cpu) != thread)
 				continue;
 
+			find_and_update_cpu_nid(cpu);
 			if (!topology_is_primary_thread(cpu)) {
 				if (cpu_smt_control != CPU_SMT_ENABLED)
 					break;
@@ -410,7 +411,6 @@ static int dlpar_online_cpu(struct device_node *dn)
 			}
 
 			cpu_maps_update_done();
-			find_and_update_cpu_nid(cpu);
 			rc = device_online(get_cpu_device(cpu));
 			if (rc) {
 				dlpar_offline_cpu(dn);
Signature · 1 line
2.43.7
#1 lore raw

arch/powerpc/platforms/pseries/hotplug-cpu.c static int dlpar_online_cpu(struct device_node *dn) · line 408

Quoted 12 lines · Srikar Dronamraju
arch/powerpc/platforms/pseries/hotplug-cpu.c +1 -0
index bc6926dbf148..b5dc942eec63 100644
@@ -402,6 +402,7 @@ static int dlpar_online_cpu(struct device_node *dn)
 			if (get_hard_smp_processor_id(cpu) != thread)
 				continue;
 
+			find_and_update_cpu_nid(cpu);
 			if (!topology_is_primary_thread(cpu)) {
 				if (cpu_smt_control != CPU_SMT_ENABLED)
 					break;

The fix looks correct to me. As an improvement, would limiting only the primary thread to making the H_HOME_NODE_ASSOCIATIVITY hcall perhaps be quicker? The primary thread can then update the nid of its sibling threads?

--Nysal

Tested-by on v1 1/1
#2 lore raw
In reply to Srikar Dronamraju

Hello Srikar,

Quoted 56 lines · Srikar Dronamraju

When cores are added while the system is running in a lower SMT mode, some threads of those cores remain offline. Moving the system to a higher SMT mode later fails to online those threads.

For example, on a system with four cores:

1. ppc64_cpu --smt=off
2. nproc
expected: 4
3. ppc64_cpu --smt
expected/actual: "SMT is off"
4. drmgr -c cpu -a -q 4
5. ppc64_cpu --smt
expected/actual: "SMT is off"
6. ppc64_cpu --smt=8
7. ppc64_cpu --smt

        expected: SMT=8
        actual:   SMT=1: 4-7; SMT=8: 0-3

8. nproc
expected: 64
actual: 36

Post commit d1099e2276df ("powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs"), when new CPUs are added, the CPU-to-node mapping is currently updated only for CPUs that are immediately onlined. CPUs that are made present but remain offline due to the current SMT mode therefore do not get a CPU-to-node mapping.

When those CPUs are subsequently onlined after switching to a higher SMT mode, the online operation fails because the required CPU-to-node mapping is missing.

Update the CPU-to-node mapping before applying the SMT restrictions so that all newly present CPUs have a node mapping, including CPUs that remain offline in the current SMT mode.

Fixes d1099e2276df ("powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs")
---
  arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/hotplug-cpu.c +1 -0
index bc6926dbf148..b5dc942eec63 100644
@@ -402,6 +402,7 @@ static int dlpar_online_cpu(struct device_node *dn)
  			if (get_hard_smp_processor_id(cpu) != thread)
  				continue;
 
+			find_and_update_cpu_nid(cpu);
  			if (!topology_is_primary_thread(cpu)) {
  				if (cpu_smt_control != CPU_SMT_ENABLED)
  					break;

arch/powerpc/platforms/pseries/hotplug-cpu.c static int dlpar_online_cpu(struct device_node *dn) · line 416

Quoted 7 lines
arch/powerpc/platforms/pseries/hotplug-cpu.c +0 -1
@@ -410,7 +411,6 @@ static int dlpar_online_cpu(struct device_node *dn)
  			}
 
  			cpu_maps_update_done();
-			find_and_update_cpu_nid(cpu);
  			rc = device_online(get_cpu_device(cpu));
  			if (rc) {
  				dlpar_offline_cpu(dn);

I have verified the patch, and no issues were observed during testing. The patch has been tested successfully.

Please add the following Tested-by tag:

Thank you for the fix!

Regards,
Samir