Everytime, a DLPAR CPU event happens on a shared LPAR, the number of
entitled_cores, and virtual processors allotted to the LPAR can change.
Hence available_cores has to be updated to be in sync.

Signed-off-by: Srikar Dronamraju <[email protected]>
---
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 6 ++++++
 arch/powerpc/platforms/pseries/pseries.h     | 1 +
 arch/powerpc/platforms/pseries/smp.c         | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c 
b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index bc6926dbf148..4ba8cc049b5b 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -284,6 +284,9 @@ static int pseries_add_processor(struct device_node *np)
 
 out:
        cpu_maps_update_done();
+#ifdef CONFIG_PPC_SPLPAR
+       pseries_num_available_cores();
+#endif
        free_cpumask_var(cpu_mask);
        return rc;
 }
@@ -323,6 +326,9 @@ static void pseries_remove_processor(struct device_node *np)
                               "with physical id 0x%x\n", thread);
        }
        cpu_maps_update_done();
+#ifdef CONFIG_PPC_SPLPAR
+       pseries_num_available_cores();
+#endif
 }
 
 static int dlpar_offline_cpu(struct device_node *dn)
diff --git a/arch/powerpc/platforms/pseries/pseries.h 
b/arch/powerpc/platforms/pseries/pseries.h
index 2527c2049e74..1eed08752a03 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -121,6 +121,7 @@ extern u32 pseries_security_flavor;
 void pseries_setup_security_mitigations(void);
 #ifdef CONFIG_PPC_SPLPAR
 void trigger_softoffline(unsigned long steal_ratio);
+unsigned int pseries_num_available_cores(void);
 #endif
 
 #ifdef CONFIG_PPC_64S_HASH_MMU
diff --git a/arch/powerpc/platforms/pseries/smp.c 
b/arch/powerpc/platforms/pseries/smp.c
index 69e209880b6f..a3daac4c3e1e 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -293,7 +293,7 @@ static unsigned int entitled_cores __read_mostly;
 static unsigned int available_cores;
 
 /* Get pseries soft entitlement limit */
-static unsigned int pseries_num_available_cores(void)
+unsigned int pseries_num_available_cores(void)
 {
        unsigned int present_cores = num_present_cpus() / threads_per_core;
        unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
-- 
2.43.7


Reply via email to