Received: by 10.25.0.6 with SMTP id 6csp425920lfa; Fri, 26 May 2017 11:25:34 -0700 (PDT) X-Received: by 10.200.53.4 with SMTP id y4mr4071253qtb.136.1495823134637; Fri, 26 May 2017 11:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495823134; cv=none; d=google.com; s=arc-20160816; b=FNSzk2uqvDzqNSdEhd/+lcLjWeKAKyGdLkO6RZYwUgsGOe1OZiaFfl5+nHP3gnigdD P6dREXGW9EjYGKrT5t/k8SbGiqSEYZgg670GjTiTbGxMELlxQL6I+/oulHKI8GNtPkEA LqSh0L4HmizX/slqiEzcnxaNVx0xHfWM3c711/BlURzmDIUR3ghlhK9ZuOyX+4HKERUc 2OOHVlhTEDpibIuNyPAPYQ2FYxSEs/OuohkpothzWEYgjffBPht+kyJNSg2S+u6CaHvf LqGDg30F9hgam1ocoRmax2PFNivHqXyXFWs4eO0IplAySC+1JOGsJeokgDVYk514neVv /sxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:to:from:date :dkim-filter:dmarc-filter:arc-authentication-results; bh=RdhQFDkXzjaaQFazKc3jbdc1QYDaITT1brNE5/wNs98=; b=prQ7L09fbsnSf46yuJ/CJJ6TrFWL56mCr6yKvTZ7JpYN1M7e/B4axiauhL5m3/c6xi nxLxUd9GPc9QEOmH87PmqjpnHdrZYIPoGU7ybS71JAV7yzDdtSrW0Q6IMzzVOxGNjRB4 cQ3dBGuIHEGvvMiOjy6IecBW/VEZ9LYCDi//9y3RKHJazef8EjVF4WSYddhk7rXiIDMb 3Aul+8ZWVieYtykzDzBT60N7yk7XvCF25atfxrZBJ5hnN52YZ8jV6CujupD2jmIPwVZo GXBws30trfOx53sRVnhtIaPhO5wd8gBihW9IO7kad/gM5N0wmlb0Uu8R0UPvb3z+l+IT HYlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z46si1407686qtg.63.2017.05.26.11.25.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 26 May 2017 11:25:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:37885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEJva-00041b-5r for alex.bennee@linaro.org; Fri, 26 May 2017 14:25:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEJvW-00041K-Ds for qemu-arm@nongnu.org; Fri, 26 May 2017 14:25:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEJvS-0000gX-As for qemu-arm@nongnu.org; Fri, 26 May 2017 14:25:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dEJvS-0000gT-19; Fri, 26 May 2017 14:25:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86E74448D98; Fri, 26 May 2017 18:25:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 86E74448D98 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 86E74448D98 Received: from localhost (ovpn-116-57.gru2.redhat.com [10.97.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB31660462; Fri, 26 May 2017 18:25:23 +0000 (UTC) Date: Fri, 26 May 2017 15:25:22 -0300 From: Eduardo Habkost To: Igor Mammedov Message-ID: <20170526182522.GV32274@thinpad.lan.raisama.net> References: <1495550330-34087-1-git-send-email-imammedo@redhat.com> <1495550330-34087-6-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1495550330-34087-6-git-send-email-imammedo@redhat.com> X-Fnord: you can see the fnord User-Agent: Mutt/1.8.0 (2017-02-23) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 26 May 2017 18:25:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-arm] [PATCH v2 5/5] numa: move numa_node from CPUState into target specific classes X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: 1Zdc9AFy6dfj On Tue, May 23, 2017 at 04:38:50PM +0200, Igor Mammedov wrote: > Move vcpu's assocciated numa_node field out of generic CPUState > into inherited classes that actually care about cpu<->numa mapping, > i.e: ARMCPU, PowerPCCPU, X86CPU. > > Signed-off-by: Igor Mammedov > --- > include/qom/cpu.h | 2 -- > target/arm/cpu.h | 2 ++ > target/i386/cpu.h | 1 + > target/ppc/cpu.h | 1 + > hw/ppc/spapr.c | 24 +++++++++++------------- > hw/ppc/spapr_cpu_core.c | 4 +++- > monitor.c | 11 +++++++---- > target/arm/cpu.c | 2 +- > target/i386/cpu.c | 2 +- > 9 files changed, 27 insertions(+), 22 deletions(-) > > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 55214ce..89ddb68 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -265,7 +265,6 @@ struct qemu_work_item; > * @cpu_index: CPU index (informative). > * @nr_cores: Number of cores within this CPU package. > * @nr_threads: Number of threads within this CPU. > - * @numa_node: NUMA node this CPU is belonging to. > * @host_tid: Host thread ID. > * @running: #true if CPU is currently running (lockless). > * @has_waiter: #true if a CPU is currently waiting for the cpu_exec_end; > @@ -314,7 +313,6 @@ struct CPUState { > > int nr_cores; > int nr_threads; > - int numa_node; > > struct QemuThread *thread; > #ifdef _WIN32 > diff --git a/target/arm/cpu.h b/target/arm/cpu.h > index 048faed..5ffc9d8 100644 > --- a/target/arm/cpu.h > +++ b/target/arm/cpu.h > @@ -703,6 +703,8 @@ struct ARMCPU { > > ARMELChangeHook *el_change_hook; > void *el_change_hook_opaque; > + > + int32_t node_id; /* NUMA node this CPU is belonging to */ > }; > > static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) > diff --git a/target/i386/cpu.h b/target/i386/cpu.h > index c4602ca..00f35a0 100644 > --- a/target/i386/cpu.h > +++ b/target/i386/cpu.h > @@ -1278,6 +1278,7 @@ struct X86CPU { > int32_t socket_id; > int32_t core_id; > int32_t thread_id; > + int32_t node_id; /* NUMA node this CPU is belonging to */ I suggest placing this before socket_id, so it follows the logical topology order: node, socket, core, thread. > }; > > static inline X86CPU *x86_env_get_cpu(CPUX86State *env) > diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h > index 401e10e..31c052d 100644 > --- a/target/ppc/cpu.h > +++ b/target/ppc/cpu.h > @@ -1205,6 +1205,7 @@ struct PowerPCCPU { > uint32_t compat_pvr; > PPCVirtualHypervisor *vhyp; > Object *intc; > + int32_t node_id; /* NUMA node this CPU is belonging to */ > > /* Fields related to migration compatibility hacks */ > bool pre_2_8_migration; > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index c7fee8b..96a2a74 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -178,25 +178,19 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, > return ret; > } > > -static int spapr_fixup_cpu_numa_dt(void *fdt, int offset, CPUState *cs) > +static int spapr_fixup_cpu_numa_dt(void *fdt, int offset, PowerPCCPU *cpu) > { > - int ret = 0; > - PowerPCCPU *cpu = POWERPC_CPU(cs); > int index = ppc_get_vcpu_dt_id(cpu); > uint32_t associativity[] = {cpu_to_be32(0x5), > cpu_to_be32(0x0), > cpu_to_be32(0x0), > cpu_to_be32(0x0), > - cpu_to_be32(cs->numa_node), > + cpu_to_be32(cpu->node_id), > cpu_to_be32(index)}; > > /* Advertise NUMA via ibm,associativity */ > - if (nb_numa_nodes > 1) { > - ret = fdt_setprop(fdt, offset, "ibm,associativity", associativity, Commit message says we're just moving fields to other structs. If you want to change the existing logic, please do it in a separate patch. > + return fdt_setprop(fdt, offset, "ibm,associativity", associativity, > sizeof(associativity)); > - } > - > - return ret; > } > > /* Populate the "ibm,pa-features" property */ > @@ -321,9 +315,11 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr) > return ret; > } > > - ret = spapr_fixup_cpu_numa_dt(fdt, offset, cs); > - if (ret < 0) { > - return ret; > + if (nb_numa_nodes > 1) { > + ret = spapr_fixup_cpu_numa_dt(fdt, offset, cpu); Ditto. > + if (ret < 0) { > + return ret; > + } > } > > ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt); > @@ -538,7 +534,9 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, > _FDT((fdt_setprop(fdt, offset, "ibm,pft-size", > pft_size_prop, sizeof(pft_size_prop)))); > > - _FDT(spapr_fixup_cpu_numa_dt(fdt, offset, cs)); > + if (nb_numa_nodes > 1) { Ditto. > + _FDT(spapr_fixup_cpu_numa_dt(fdt, offset, cpu)); > + } > > _FDT(spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt)); > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > index a17ea07..60baf02 100644 > --- a/hw/ppc/spapr_cpu_core.c > +++ b/hw/ppc/spapr_cpu_core.c > @@ -183,15 +183,17 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) > for (i = 0; i < cc->nr_threads; i++) { > char id[32]; > CPUState *cs; > + PowerPCCPU *cpu; > > obj = sc->threads + i * size; > > object_initialize(obj, size, typename); > cs = CPU(obj); > + cpu = POWERPC_CPU(cs); > cs->cpu_index = cc->core_id + i; > > /* Set NUMA node for the threads belonged to core */ > - cs->numa_node = sc->node_id; > + cpu->node_id = sc->node_id; > > snprintf(id, sizeof(id), "thread[%d]", i); > object_property_add_child(OBJECT(sc), id, obj, &local_err); > diff --git a/monitor.c b/monitor.c > index afbacfe..b053c40 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -1697,23 +1697,26 @@ static void hmp_info_mtree(Monitor *mon, const QDict *qdict) > static void hmp_info_numa(Monitor *mon, const QDict *qdict) > { > int i; > - CPUState *cpu; > uint64_t *node_mem; > + CpuInfoList *cpu_list, *cpu; > > + cpu_list = qmp_query_cpus(&error_abort); > node_mem = g_new0(uint64_t, nb_numa_nodes); > query_numa_node_mem(node_mem); > monitor_printf(mon, "%d nodes\n", nb_numa_nodes); > for (i = 0; i < nb_numa_nodes; i++) { > monitor_printf(mon, "node %d cpus:", i); > - CPU_FOREACH(cpu) { > - if (cpu->numa_node == i) { > - monitor_printf(mon, " %d", cpu->cpu_index); > + for (cpu = cpu_list; cpu; cpu = cpu->next) { > + if (cpu->value->has_props && cpu->value->props->has_node_id && > + cpu->value->props->node_id == i) { > + monitor_printf(mon, " %" PRIi64, cpu->value->CPU); I suggest moving this to a separate patch, too. > } > } > monitor_printf(mon, "\n"); > monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i, > node_mem[i] >> 20); > } > + qapi_free_CpuInfoList(cpu_list); > g_free(node_mem); > } > > diff --git a/target/arm/cpu.c b/target/arm/cpu.c > index c185eb1..09ef3a6 100644 > --- a/target/arm/cpu.c > +++ b/target/arm/cpu.c > @@ -1573,7 +1573,7 @@ static Property arm_cpu_properties[] = { > DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0), > DEFINE_PROP_UINT64("mp-affinity", ARMCPU, > mp_affinity, ARM64_AFFINITY_INVALID), > - DEFINE_PROP_INT32("node-id", CPUState, numa_node, CPU_UNSET_NUMA_NODE_ID), > + DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), > DEFINE_PROP_END_OF_LIST() > }; > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index a41d595..ffb5267 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -3986,7 +3986,7 @@ static Property x86_cpu_properties[] = { > DEFINE_PROP_INT32("core-id", X86CPU, core_id, -1), > DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, -1), > #endif > - DEFINE_PROP_INT32("node-id", CPUState, numa_node, CPU_UNSET_NUMA_NODE_ID), > + DEFINE_PROP_INT32("node-id", X86CPU, node_id, CPU_UNSET_NUMA_NODE_ID), > DEFINE_PROP_BOOL("pmu", X86CPU, enable_pmu, false), > { .name = "hv-spinlocks", .info = &qdev_prop_spinlocks }, > DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false), > -- > 2.7.4 > -- Eduardo