pseries: Enforce homogeneous threads-per-core
PATCH v2 1/1 pseries: Enforce homogeneous threads-per-core
For reasons that may be useful in future, CPU core objects, as used on the pseries machine type have their own nr-threads property, potentially allowing cores with different numbers of threads in the same system.
If the user/management uses the values specified in query-hotpluggable-cpus as they're expected to do, this will never matter in pratice. But that's not actually enforced - it's possible to manually specify a core with a different number of threads from that in -smp. That will confuse the platform - most immediately, this can be used to create a CPU thread with index above max_cpus which leads to an assertion failure in spapr_cpu_core_realize().
For now, enforce that all cores must have the same, standard, number of threads.
--- hw/ppc/spapr.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/ppc/spapr.c +6 -0
@@ -2790,6 +2790,12 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, goto out; } +if (cc->nr_threads != smp_threads) { +error_setg (errp,"invalid nr-threads %d, must be %d" , + cc->nr_threads, smp_threads); +return ; + } + core_slot =spapr_find_cpu_slot (MACHINE (hotplug_dev), cc->core_id, &index);if (!core_slot) {error_setg (&local_err,"core id %d out of range" , cc->core_id);
Signature · 1 line
2.9.3
Quoted 37 lines · David Gibson
For reasons that may be useful in future, CPU core objects, as used on the pseries machine type have their own nr-threads property, potentially allowing cores with different numbers of threads in the same system.
If the user/management uses the values specified in query-hotpluggable-cpus as they're expected to do, this will never matter in pratice. But that's not actually enforced - it's possible to manually specify a core with a different number of threads from that in -smp. That will confuse the platform - most immediately, this can be used to create a CPU thread with index above
max_cpuswhich leads to an assertion failure inspapr_cpu_core_realize().For now, enforce that all cores must have the same, standard, number of threads.
Signed-off-by David Gibson <[email protected]>--- hw/ppc/spapr.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/ppc/spapr.c +6
-0@@ -2790,6 +2790,12 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, goto out; } +if (cc->nr_threads != smp_threads) { +error_setg (errp,"invalid nr-threads %d, must be %d" , + cc->nr_threads, smp_threads); +return ; + } + core_slot =spapr_find_cpu_slot (MACHINE (hotplug_dev), cc->core_id, &index);
Quoted 3 lines
if (!core_slot) {
error_setg(&local_err, "core id %d out of range", cc->core_id);