qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ppc/pnv: fix cores per chip for multiple cpus
@ 2017-09-06  8:27 Nikunj A Dadhania
  2017-09-08  6:38 ` Cédric Le Goater
  2017-09-09  7:02 ` David Gibson
  0 siblings, 2 replies; 39+ messages in thread
From: Nikunj A Dadhania @ 2017-09-06  8:27 UTC (permalink / raw)
  To: qemu-ppc, david; +Cc: qemu-devel, clg, bharata, benh, Nikunj A Dadhania

When the user does not provide the cpu topology, e.g. "-smp 4", machine fails to
initialize 4 cpus. Compute the chip per cores depending on the number of chips
and smt threads.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
---
 hw/ppc/pnv.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 9724719..3fbaafb 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -642,7 +642,7 @@ static void ppc_powernv_init(MachineState *machine)
     MemoryRegion *ram;
     char *fw_filename;
     long fw_size;
-    int i;
+    int i, cores_per_chip;
     char *chip_typename;
     PCIBus *pbus;
     bool has_gfx = false;
@@ -710,6 +710,22 @@ static void ppc_powernv_init(MachineState *machine)
     }
 
     pnv->chips = g_new0(PnvChip *, pnv->num_chips);
+
+    /* If user has specified number of cores, use it. Otherwise, compute it. */
+    if (smp_cores != 1) {
+        cores_per_chip = smp_cores;
+    } else {
+        cores_per_chip = smp_cpus / (smp_threads * pnv->num_chips);
+    }
+
+    if (smp_cpus != (smp_threads * pnv->num_chips * cores_per_chip)) {
+        error_report("cpu topology not balanced: "
+                     "chips (%u) * cores (%u) * threads (%u) != "
+                     "number of cpus (%u)",
+                     pnv->num_chips, cores_per_chip, smp_threads, smp_cpus);
+        exit(1);
+    }
+
     for (i = 0; i < pnv->num_chips; i++) {
         char chip_name[32];
         Object *chip = object_new(chip_typename);
@@ -728,7 +744,7 @@ static void ppc_powernv_init(MachineState *machine)
         object_property_add_child(OBJECT(pnv), chip_name, chip, &error_fatal);
         object_property_set_int(chip, PNV_CHIP_HWID(i), "chip-id",
                                 &error_fatal);
-        object_property_set_int(chip, smp_cores, "nr-cores", &error_fatal);
+        object_property_set_int(chip, cores_per_chip, "nr-cores", &error_fatal);
         object_property_set_int(chip, 1, "num-phbs", &error_fatal);
         object_property_set_bool(chip, true, "realized", &error_fatal);
     }
-- 
2.9.3

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

end of thread, other threads:[~2017-09-22 12:00 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06  8:27 [Qemu-devel] [PATCH] ppc/pnv: fix cores per chip for multiple cpus Nikunj A Dadhania
2017-09-08  6:38 ` Cédric Le Goater
2017-09-09  7:02 ` David Gibson
2017-09-11  5:10   ` Nikunj A Dadhania
2017-09-13  7:35     ` David Gibson
2017-09-14  5:12       ` Nikunj A Dadhania
2017-09-15  6:48         ` David Gibson
2017-09-15  8:23           ` Nikunj A Dadhania
2017-09-15  8:51             ` David Gibson
2017-09-15  9:09               ` Nikunj A Dadhania
2017-09-19  8:24                 ` David Gibson
2017-09-20  4:20                   ` Nikunj A Dadhania
2017-09-20  4:55                     ` David Gibson
2017-09-20  5:13                       ` Nikunj A Dadhania
2017-09-20  6:17                         ` David Gibson
2017-09-20  6:40                           ` Nikunj A Dadhania
2017-09-20  6:50                             ` Nikunj A Dadhania
2017-09-20  6:57                             ` David Gibson
2017-09-20  7:18                               ` Nikunj A Dadhania
2017-09-20  8:12                                 ` Cédric Le Goater
2017-09-20 11:53                                 ` David Gibson
2017-09-21  3:54                                   ` Nikunj A Dadhania
2017-09-21  5:31                                     ` David Gibson
2017-09-22  6:00                                       ` Nikunj A Dadhania
2017-09-22  6:07                                         ` Cédric Le Goater
2017-09-22 10:12                                           ` David Gibson
2017-09-22 10:46                                             ` Cédric Le Goater
2017-09-22 11:20                                               ` David Gibson
2017-09-22 11:37                                                 ` Cédric Le Goater
2017-09-22 11:49                                                   ` David Gibson
2017-09-22 11:46                                                 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-09-22 10:56                                         ` [Qemu-devel] " Cédric Le Goater
2017-09-22 11:06                                           ` Nikunj A Dadhania
2017-09-22 11:36                                           ` David Gibson
2017-09-21  6:04                                     ` Cédric Le Goater
2017-09-21  7:42                                       ` Igor Mammedov
2017-09-22 10:09                                         ` David Gibson
2017-09-22 10:08                                       ` David Gibson
2017-09-22 10:52                                         ` Cédric Le Goater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).