Received: by 2002:a17:505:3501:b0:1be9:327d:8ee3 with SMTP id mc1csp2336502njb; Tue, 15 Oct 2024 03:01:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXfQEH1YUyc73jRlKUHtd5FZhXP0NNAANrijRNhohVvASusLpF3cWtdycCL5Doke0aUNBXJh3oMiBV9FA==@linaro.org X-Google-Smtp-Source: AGHT+IEuPyr2pDo/JRPAP/H0AzRSDkxtpBrHOZgB35YAw7ZE8our6+x+NB7CDp2MOpBu7zlXMgnm X-Received: by 2002:a5d:6703:0:b0:37d:498a:a23b with SMTP id ffacd0b85a97d-37d551d5242mr10487452f8f.21.1728986484813; Tue, 15 Oct 2024 03:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728986484; cv=none; d=google.com; s=arc-20240605; b=Ol/iiJDUitKYLiXq0k1NcbXHIQepttz5nXiWF8jM8+TkErFXLNzI99vn911dDbMJ4e ELd7m3LCoDS1ZsiWSZFTTRb6LGFW2oyj7cH4L8yY33GQTLztu2vHZ0d5FKEw309cedVW RjKRNPdeCyD+zt9EJ6cUC4NArEn60eT7clULhV++qDgnIrn4tmCPxoiha+tuMA73LQb/ m2akcg3Xbx01tNu20g9wZuDtgMUWq9xFb29M1OO9UbBJeHRDsb2PA9fwwu+nBxOw1NIG j3a947+/1hrLsohZA199C2tC7Ze20Mb9438WXKgB+uz9+qj/qMeG6ZOwbedVMNW+MHBA bZXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=zxDtKPZEL/JqjiJirmW+pkiB7dR4pb0LIfaYpoaxUEs=; fh=f7aqOn0Aylihzqer4hTA2kHSEaA8DU6KE1VFtniI5w4=; b=F4yIIWLZSlSRs3ncwW5+KTXfzHpq4kqx7/8xWHRvpaxjKr28+ZbE0hSdp9f1wwZrqY Ok6dAr0A2l4HIn3HOuq6kzAwRSKikSr04nlxh3SphjSQTCXKmy+Blu0spoOmXpkM45uG mUOlB6IHpPrkFhioQIBfbjCoLjO97NaZOSo26VfpIbKQm99bq5waHvSk4kGxusJpRLgq K0Uqqlj1eu4jxE2ZzJ4YlqrbbKRdZNHKaUwlcwpvfHbLeTjRg9suQKWpotntDtt36JpF ydnr8iVBfi7oeHCvTtC1jJsIvc3XAAE9Plur14J7LiE4AdQCGIJVcRS+eV9rPaoA3gCk aV3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of salil.mehta@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=salil.mehta@huawei.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from frasgout.his.huawei.com (frasgout.his.huawei.com. [185.176.79.56]) by mx.google.com with ESMTPS id ffacd0b85a97d-37d7fc9ed41si507736f8f.314.2024.10.15.03.01.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Oct 2024 03:01:24 -0700 (PDT) Received-SPF: pass (google.com: domain of salil.mehta@huawei.com designates 185.176.79.56 as permitted sender) client-ip=185.176.79.56; Authentication-Results: mx.google.com; spf=pass (google.com: domain of salil.mehta@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=salil.mehta@huawei.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XSTyv2qdFz6D9Sl; Tue, 15 Oct 2024 17:56:55 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id B47E9140AA7; Tue, 15 Oct 2024 18:01:23 +0800 (CST) Received: from 00293818-MRGF.huawei.com (10.48.146.149) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 15 Oct 2024 12:01:03 +0200 From: Salil Mehta To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH RFC V5 01/30] arm/virt,target/arm: Add new ARMCPU {socket,cluster,core,thread}-id property Date: Tue, 15 Oct 2024 10:59:43 +0100 Message-ID: <20241015100012.254223-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015100012.254223-1-salil.mehta@huawei.com> References: <20241015100012.254223-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.48.146.149] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To frapeml500007.china.huawei.com (7.182.85.172) X-TUID: KtUlTaV3tyBA This shall be used to store user specified topology{socket,cluster,core,thread} and shall be converted to a unique 'vcpu-id' which is used as slot-index during hot(un)plug of vCPU. Co-developed-by: Keqian Zhu Signed-off-by: Keqian Zhu Signed-off-by: Salil Mehta --- hw/arm/virt.c | 10 ++++++++++ include/hw/arm/virt.h | 28 ++++++++++++++++++++++++++++ target/arm/cpu.c | 4 ++++ target/arm/cpu.h | 4 ++++ 4 files changed, 46 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8b2b991d97..8ff7e109dd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2242,6 +2242,14 @@ static void machvirt_init(MachineState *machine) &error_fatal); aarch64 &= object_property_get_bool(cpuobj, "aarch64", NULL); + object_property_set_int(cpuobj, "socket-id", + virt_get_socket_id(machine, n), NULL); + object_property_set_int(cpuobj, "cluster-id", + virt_get_cluster_id(machine, n), NULL); + object_property_set_int(cpuobj, "core-id", + virt_get_core_id(machine, n), NULL); + object_property_set_int(cpuobj, "thread-id", + virt_get_thread_id(machine, n), NULL); if (!vms->secure) { object_property_set_bool(cpuobj, "has_el3", false, NULL); @@ -2765,6 +2773,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) { int n; unsigned int max_cpus = ms->smp.max_cpus; + unsigned int smp_threads = ms->smp.threads; VirtMachineState *vms = VIRT_MACHINE(ms); MachineClass *mc = MACHINE_GET_CLASS(vms); @@ -2778,6 +2787,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus->len = max_cpus; for (n = 0; n < ms->possible_cpus->len; n++) { ms->possible_cpus->cpus[n].type = ms->cpu_type; + ms->possible_cpus->cpus[n].vcpus_count = smp_threads; ms->possible_cpus->cpus[n].arch_id = virt_cpu_mp_affinity(vms, n); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index aca4f8061b..db3e2aebb9 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -214,4 +214,32 @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) vms->highmem_redists) ? 2 : 1; } +static inline int virt_get_socket_id(const MachineState *ms, int cpu_index) +{ + assert(cpu_index >= 0 && cpu_index < ms->possible_cpus->len); + + return ms->possible_cpus->cpus[cpu_index].props.socket_id; +} + +static inline int virt_get_cluster_id(const MachineState *ms, int cpu_index) +{ + assert(cpu_index >= 0 && cpu_index < ms->possible_cpus->len); + + return ms->possible_cpus->cpus[cpu_index].props.cluster_id; +} + +static inline int virt_get_core_id(const MachineState *ms, int cpu_index) +{ + assert(cpu_index >= 0 && cpu_index < ms->possible_cpus->len); + + return ms->possible_cpus->cpus[cpu_index].props.core_id; +} + +static inline int virt_get_thread_id(const MachineState *ms, int cpu_index) +{ + assert(cpu_index >= 0 && cpu_index < ms->possible_cpus->len); + + return ms->possible_cpus->cpus[cpu_index].props.thread_id; +} + #endif /* QEMU_ARM_VIRT_H */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 19191c2391..bda95366d1 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2622,6 +2622,10 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_UINT64("mp-affinity", ARMCPU, mp_affinity, ARM64_AFFINITY_INVALID), DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), + DEFINE_PROP_INT32("socket-id", ARMCPU, socket_id, 0), + DEFINE_PROP_INT32("cluster-id", ARMCPU, cluster_id, 0), + DEFINE_PROP_INT32("core-id", ARMCPU, core_id, 0), + DEFINE_PROP_INT32("thread-id", ARMCPU, thread_id, 0), DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1), /* True to default to the backward-compat old CNTFRQ rather than 1Ghz */ DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false), diff --git a/target/arm/cpu.h b/target/arm/cpu.h index f065756c5c..1277a0ddfc 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1086,6 +1086,10 @@ struct ArchCPU { QLIST_HEAD(, ARMELChangeHook) el_change_hooks; int32_t node_id; /* NUMA node this CPU belongs to */ + int32_t socket_id; + int32_t cluster_id; + int32_t core_id; + int32_t thread_id; /* Used to synchronize KVM and QEMU in-kernel device levels */ uint8_t device_irq_level; -- 2.34.1