From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNDiT-0001wp-6O for qemu-devel@nongnu.org; Thu, 06 Aug 2015 01:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNDiO-0007wV-7u for qemu-devel@nongnu.org; Thu, 06 Aug 2015 01:27:45 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:52566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNDiN-0007vk-LH for qemu-devel@nongnu.org; Thu, 06 Aug 2015 01:27:40 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Aug 2015 10:57:38 +0530 From: Bharata B Rao Date: Thu, 6 Aug 2015 10:57:15 +0530 Message-Id: <1438838837-28504-10-git-send-email-bharata@linux.vnet.ibm.com> In-Reply-To: <1438838837-28504-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1438838837-28504-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC PATCH v4 09/11] spapr: Support topologies with unfilled cores List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, Bharata B Rao , mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au QEMU currently supports CPU topologies where there can be cores which are not completely filled with all the threads as per the specifed SMT mode. Restore support for such topologies (Eg -smp 15,cores=4,threads=4) The last core will always have the deficit even when -device options are used to cold-plug the cores. Signed-off-by: Bharata B Rao --- hw/ppc/spapr.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 74637b3..004a8e1 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -94,6 +94,8 @@ #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) +static int smp_remaining_cpus; + static XICSState *try_create_xics(const char *type, int nr_servers, int nr_irqs, Error **errp) { @@ -1700,6 +1702,7 @@ static void ppc_spapr_init(MachineState *machine) int smp_max_cores = DIV_ROUND_UP(max_cpus, smp_threads); int smp_cores = DIV_ROUND_UP(smp_cpus, smp_threads); + smp_remaining_cpus = smp_cpus; msi_supported = true; QLIST_INIT(&spapr->phbs); @@ -2202,6 +2205,7 @@ static void spapr_cpu_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error *local_err = NULL; void *fdt = NULL; int i, fdt_offset = 0; + int threads_per_core; /* Set NUMA node for the added CPUs */ for (i = 0; i < nb_numa_nodes; i++) { @@ -2224,8 +2228,22 @@ static void spapr_cpu_plug(HotplugHandler *hotplug_dev, DeviceState *dev, return; } + /* Create SMT threads of the core. + * + * Support topologies like -smp 15,cores=4,threads=4 where one core + * will have less than the specified SMT threads. The last core will + * always have the deficit even when -device options are used to + * cold-plug the cores. + */ + if ((smp_remaining_cpus > 0) && (smp_remaining_cpus < smp_threads)) { + threads_per_core = smp_remaining_cpus; + } else { + threads_per_core = smp_threads; + } + smp_remaining_cpus -= threads_per_core; + /* Create SMT threads of the core. */ - for (i = 1; i < smp_threads; i++) { + for (i = 1; i < threads_per_core; i++) { cpu = cpu_ppc_init(current_machine->cpu_model); if (!cpu) { error_report("Unable to find PowerPC CPU definition: %s", -- 2.1.0