From patchwork Mon Sep 21 01:06:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 520097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 29616140772 for ; Mon, 21 Sep 2015 11:16:44 +1000 (AEST) Received: from localhost ([::1]:54637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zdpik-0004zI-Cm for incoming@patchwork.ozlabs.org; Sun, 20 Sep 2015 21:16:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdpYl-00030f-Sa for qemu-devel@nongnu.org; Sun, 20 Sep 2015 21:06:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdpYi-000568-BS for qemu-devel@nongnu.org; Sun, 20 Sep 2015 21:06:23 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:47406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdpYh-0004yP-Vm; Sun, 20 Sep 2015 21:06:20 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 6DCFA140D4F; Mon, 21 Sep 2015 11:06:11 +1000 (AEST) From: David Gibson To: peter.maydell@linaro.org Date: Mon, 21 Sep 2015 11:06:27 +1000 Message-Id: <1442797588-26793-33-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442797588-26793-1-git-send-email-david@gibson.dropbear.id.au> References: <1442797588-26793-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2401:3900:2:1::2 Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson Subject: [Qemu-devel] [PULL 32/33] spapr: Fix default NUMA node allocation for threads X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org At present, if guest numa nodes are requested, but the cpus in each node are not specified, spapr just uses the default behaviour or assigning each vcpu round-robin to nodes. If smp_threads != 1, that will assign adjacent threads in a core to different NUMA nodes. As well as being just weird, that's a configuration that can't be represented in the device tree we give to the guest, which means the guest and qemu end up with different ideas of the NUMA topology. This patch implements mc->cpu_index_to_socket_id in the spapr code to make sure vcpus get assigned to nodes only at the socket granularity. Signed-off-by: David Gibson Reviewed-by: Alexey Kardashevskiy --- hw/ppc/spapr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 430fac4..6ccf26f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2162,6 +2162,13 @@ static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine, return NULL; } +static unsigned spapr_cpu_index_to_socket_id(unsigned cpu_index) +{ + /* Allocate to NUMA nodes on a "socket" basis (not that concept of + * socket means much for the paravirtualized PAPR platform) */ + return cpu_index / smp_threads / smp_cores; +} + static void spapr_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -2183,6 +2190,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->get_hotplug_handler = spapr_get_hotpug_handler; hc->plug = spapr_machine_device_plug; hc->unplug = spapr_machine_device_unplug; + mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id; smc->dr_lmb_enabled = false; fwc->get_dev_path = spapr_get_fw_dev_path;