From patchwork Fri Sep 6 19:11:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11135849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44A0E13BD for ; Fri, 6 Sep 2019 19:13:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AD512070C for ; Fri, 6 Sep 2019 19:13:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="hHD/kyqP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AD512070C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Jfb-0003Ph-NN for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Sep 2019 15:13:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42160) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Je7-0001fi-1s for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Je5-00040O-Ka for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:11:46 -0400 Received: from mail-eopbgr750075.outbound.protection.outlook.com ([40.107.75.75]:28505 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6Je5-000402-Fh for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:11:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M8LhSlGnf3mhEC3duSLE9QXSXCxwB/Nul7h9aivRlmHmLEAhZk7hFHJ4oX9bhTRdVhfE+1F6b9hZBV8h2gtmLvMRv5b2ZuaJH/XsahukLdFk4UlRlu8sda6kVmrtjkt8ZmmBJzjHfcEWC53DOA0w6hMrR7YPsAgtPkxDrsvAzo8MDtZEwaou5j4JY6m1PAvg12oHqHFtkTu6A5qhyhzeyDoU/r/Pw4wHaopNoh5w6EGtMxqhpcorVtlWw5XRR9lRswyJ2uWceZrB7ECLddk5v6K8Reo62enHvYdYoW1yN8Hdqd4SVa+naXWtlOeoYmg8pl8Tgr8U+yghem9Wm1yeGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hk/AupXYEr+Yg8Z7QLU2GssScqp1oDFwEnjwMz/d4pg=; b=oB2WqbYXXrGa3gj0onIV2wNFXCAof3ml8KGsxDJB26mys6ClbDeAzCSbecc0Ea649/S/E+pDtCH3zEK38Mzx+qhmsy3ZLFy4jkypl+Q6dKc//uBkMgQGvLEPtW+LGsrgSsRLID1xUF31u6DPMDjw2/R5/DV6ldGdCxW8kRYVhmFB4itv8Pkdq6SPNFB+lRZwIhuBRDL4mtRzNpiHULlieQc1uTZ7GioBEBqYfXKmDzn3wXGtSmwXUlidzD/H2Y8s7tjJuPLYZWmtuKyTawrLddKN8EZWoEeSsVCjtwm6+YCcp6G3yCMkdpY/7lLovBQ3ZoxuBMUk3A5eax3TE0l//g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hk/AupXYEr+Yg8Z7QLU2GssScqp1oDFwEnjwMz/d4pg=; b=hHD/kyqP/aG5+xPXTsCO+MagKNlPdRVQJP5v3pgu3aYnRYg/ZYeJfeZbCB51mOOo/6CEUlACUM6S+pIPHJ0CGHnLc3y9LblDukVxhUkaIQNS8DpiaO+enfYfsktRY8WSqOdgiNsqT68f0ZGcm1MWVRabusjxeEeFUTC1RP9oiqk= Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB1145.namprd12.prod.outlook.com (10.168.238.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2241.14; Fri, 6 Sep 2019 19:11:43 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8%3]) with mapi id 15.20.2220.022; Fri, 6 Sep 2019 19:11:43 +0000 From: "Moger, Babu" To: ssg.sos.staff , "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "eblake@redhat.com" , "armbru@redhat.com" , "imammedo@redhat.com" Thread-Topic: [RFC 2 PATCH 01/16] numa: Split the numa functionality Thread-Index: AQHVZObrnLDTbxd9bUifE1lwjy5LPg== Date: Fri, 6 Sep 2019 19:11:43 +0000 Message-ID: <156779710184.21957.13351592831416903368.stgit@localhost.localdomain> References: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> In-Reply-To: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0401CA0009.namprd04.prod.outlook.com (2603:10b6:803:21::19) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 88a7dc72-dd9c-4a9c-4aef-08d732fe0ddd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB1145; x-ms-traffictypediagnostic: DM5PR12MB1145: x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 0152EBA40F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(396003)(366004)(39860400002)(136003)(346002)(199004)(189003)(2201001)(71190400001)(305945005)(7736002)(9686003)(52116002)(86362001)(71200400001)(6116002)(8936002)(6512007)(3846002)(6436002)(11346002)(103116003)(99286004)(6506007)(6486002)(26005)(4326008)(14454004)(5660300002)(386003)(476003)(102836004)(2906002)(25786009)(76176011)(2501003)(53936002)(8676002)(66446008)(446003)(186003)(66556008)(486006)(66946007)(66476007)(64756008)(110136005)(81166006)(81156014)(478600001)(66066001)(256004)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1145; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: snComlcKZ6V0zX9isGmMPx/7KVtPNbtRN6B8baGfb6DedYFRrVU39wvAd0enfuo6InRXDpXUg7g+dXlVdk/J9uHjPxa8QVe7WI2zA6uTQ/6JRRs0fY2ivpDExyi3ZdpZ9F23bNbyRsDQESUCqZFBSvNoIDelE0JT6c0/kW2EZoW3pgUqVoKx8gi9xn+eSXx/WyafkIlIFR5YyLSwaePvkttkTiWl0dGco/obMOk7MVkwzwttwsSg1Z500PyJ0lzSjfGkNCGjlmm0zUmilEmGCcETDl2B3ms7vlJ+SOWhGwtWml7Z3/lynPPH/GwSLY+ovuXm5TnHc1WKxyF2VVebT4WRLE66Va1MCR4W+ow/2tH41vOyYAUbiyAJOAUo4Ee+EZObGNrYZXSWItZzrU6p/T/HS28ZPLYS0Riw2PPQdmY= Content-ID: <91D5F778E86AEB43B30783D33CC5C9E0@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88a7dc72-dd9c-4a9c-4aef-08d732fe0ddd X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2019 19:11:43.6660 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rgCdITV5mHNMCirgQEn8v8l+GO4yB6a/7gcX2OMib16a+MLv6IaEj1HMUTnIrECW X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1145 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.75.75 Subject: [Qemu-devel] [RFC 2 PATCH 01/16] numa: Split the numa functionality X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" To support new epyc mode, we need to know the number of numa nodes in advance to generate apic id correctly. So, split the numa initialization into two. The function parse_numa initializes numa_info and updates nb_numa_nodes. And then parse_numa_node does the numa node initialization. Signed-off-by: Babu Moger --- hw/core/numa.c | 106 +++++++++++++++++++++++++++++++++++-------------- include/sysemu/numa.h | 2 + vl.c | 2 + 3 files changed, 80 insertions(+), 30 deletions(-) diff --git a/hw/core/numa.c b/hw/core/numa.c index a11431483c..27fa6b5e1d 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -55,14 +55,10 @@ bool have_numa_distance; NodeInfo numa_info[MAX_NODES]; -static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, +static void parse_numa_info(MachineState *ms, NumaNodeOptions *node, Error **errp) { - Error *err = NULL; uint16_t nodenr; - uint16List *cpus = NULL; - MachineClass *mc = MACHINE_GET_CLASS(ms); - unsigned int max_cpus = ms->smp.max_cpus; if (node->has_nodeid) { nodenr = node->nodeid; @@ -81,29 +77,6 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, return; } - if (!mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id) { - error_setg(errp, "NUMA is not supported by this machine-type"); - return; - } - for (cpus = node->cpus; cpus; cpus = cpus->next) { - CpuInstanceProperties props; - if (cpus->value >= max_cpus) { - error_setg(errp, - "CPU index (%" PRIu16 ")" - " should be smaller than maxcpus (%d)", - cpus->value, max_cpus); - return; - } - props = mc->cpu_index_to_instance_props(ms, cpus->value); - props.node_id = nodenr; - props.has_node_id = true; - machine_set_cpu_numa_node(ms, &props, &err); - if (err) { - error_propagate(errp, err); - return; - } - } - have_memdevs = have_memdevs ? : node->has_memdev; have_mem = have_mem ? : node->has_mem; if ((node->has_mem && have_memdevs) || (node->has_memdev && have_mem)) { @@ -177,7 +150,7 @@ void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) switch (object->type) { case NUMA_OPTIONS_TYPE_NODE: - parse_numa_node(ms, &object->u.node, &err); + parse_numa_info(ms, &object->u.node, &err); if (err) { goto end; } @@ -242,6 +215,73 @@ end: return 0; } +void set_numa_node_options(MachineState *ms, NumaOptions *object, Error **errp) +{ + MachineClass *mc = MACHINE_GET_CLASS(ms); + NumaNodeOptions *node = &object->u.node; + unsigned int max_cpus = ms->smp.max_cpus; + uint16List *cpus = NULL; + Error *err = NULL; + uint16_t nodenr; + + if (node->has_nodeid) { + nodenr = node->nodeid; + } else { + error_setg(errp, "NUMA node information is not available"); + } + + if (!mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id) { + error_setg(errp, "NUMA is not supported by this machine-type"); + return; + } + + for (cpus = node->cpus; cpus; cpus = cpus->next) { + CpuInstanceProperties props; + if (cpus->value >= max_cpus) { + error_setg(errp, + "CPU index (%" PRIu16 ")" + " should be smaller than maxcpus (%d)", + cpus->value, max_cpus); + return; + } + props = mc->cpu_index_to_instance_props(ms, cpus->value); + props.node_id = nodenr; + props.has_node_id = true; + machine_set_cpu_numa_node(ms, &props, &err); + if (err) { + error_propagate(errp, err); + return; + } + } +} + +static int parse_numa_node(void *opaque, QemuOpts *opts, Error **errp) +{ + NumaOptions *object = NULL; + MachineState *ms = MACHINE(opaque); + Error *err = NULL; + Visitor *v = opts_visitor_new(opts); + + visit_type_NumaOptions(v, NULL, &object, &err); + visit_free(v); + if (err) { + goto end; + } + + if (object->type == NUMA_OPTIONS_TYPE_NODE) { + set_numa_node_options(ms, object, &err); + } + +end: + qapi_free_NumaOptions(object); + if (err) { + error_propagate(errp, err); + return -1; + } + + return 0; +} + /* If all node pair distances are symmetric, then only distances * in one direction are enough. If there is even one asymmetric * pair, though, then all distances must be provided. The @@ -368,7 +408,7 @@ void numa_complete_configuration(MachineState *ms) if (ms->ram_slots > 0 && nb_numa_nodes == 0 && mc->auto_enable_numa_with_memhp) { NumaNodeOptions node = { }; - parse_numa_node(ms, &node, &error_abort); + parse_numa_info(ms, &node, &error_abort); } assert(max_numa_nodeid <= MAX_NODES); @@ -448,6 +488,12 @@ void parse_numa_opts(MachineState *ms) qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, &error_fatal); } +void parse_numa_node_opts(MachineState *ms) +{ + qemu_opts_foreach(qemu_find_opts("numa"), parse_numa_node, + ms, &error_fatal); +} + void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp) { int node_id = object_property_get_int(OBJECT(dev), "node-id", &error_abort); diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 01a263eba2..ca109adaa6 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -24,7 +24,9 @@ struct NumaNodeMem { extern NodeInfo numa_info[MAX_NODES]; void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp); +void set_numa_node_options(MachineState *ms, NumaOptions *object, Error **errp); void parse_numa_opts(MachineState *ms); +void parse_numa_node_opts(MachineState *ms); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[]); extern QemuOptsList qemu_numa_opts; diff --git a/vl.c b/vl.c index b426b32134..711d2ae5da 100644 --- a/vl.c +++ b/vl.c @@ -4339,6 +4339,8 @@ int main(int argc, char **argv, char **envp) } parse_numa_opts(current_machine); + parse_numa_node_opts(current_machine); + /* do monitor/qmp handling at preconfig state if requested */ main_loop();