From nobody Mon Feb 9 01:29:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578655329; cv=none; d=zohomail.com; s=zohoarc; b=SZKhQwCqAONnVTwuXn7ooIJ5veX8jOXwO/hLMde6e+LSdp0JjpAM1ohxAF7rrr+PX9XOdr3vdIT0eAt7COWoT1x+2rcjDBU7FGyH5rBNqss7EQdSlH9jNBL0keT4VuEqQaLN13K8oyoZSjxARpzh3loggxRUCL+JvM9O5W9nhSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578655329; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c4LGoNdTCOJ109Q5+1QWU/ffyX1OnDV0xoGAAgT/RL8=; b=Nomz9wkQr+5IHND+TRWmSFmgWm36T5Y6/AKnqT/9N942jkVaBPRgumzsjyqfXRiqARzhraE2BOEoq8YJkZ/xh1qKGAlKHv9sGjgSeA/IZE3hcYwKi2yDsc9sR7o20zKkQja4c1wMo/AWaE1UlaHukUB9l5DOA0NJVEzbLnfS01E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578655329176386.32614134674816; Fri, 10 Jan 2020 03:22:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-Rciowh5lMd-O2QOT5_z13g-1; Fri, 10 Jan 2020 06:21:28 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1AD1801E7E; Fri, 10 Jan 2020 11:21:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD2525DA60; Fri, 10 Jan 2020 11:21:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 78875503D8; Fri, 10 Jan 2020 11:21:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00ABLH8J005613 for ; Fri, 10 Jan 2020 06:21:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5A8D21001B08; Fri, 10 Jan 2020 11:21:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08C3D1001B00; Fri, 10 Jan 2020 11:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578655328; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=c4LGoNdTCOJ109Q5+1QWU/ffyX1OnDV0xoGAAgT/RL8=; b=hJQHS6fsDN7Me6N7zrskaVyhGOnu1BmKK+OkQLg1+CJoOVj5JEGhaMGcsCYnAWVf+suY9C WvfvlwzZ5neuVVH0j3CYIjmA5HlhUzi/Hge9urtzL1cGI2Io3cwO2kN7zB2+CPoHS8HZut qzUem6GPDA96IQyqhqY3ifmMWxySF/Y= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 10 Jan 2020 11:21:02 +0000 Message-Id: <20200110112103.4017410-5-berrange@redhat.com> In-Reply-To: <20200110112103.4017410-1-berrange@redhat.com> References: <20200110112103.4017410-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Jiri Denemark , Daniel Henrique Barboza Subject: [libvirt] [PATCH v2 4/5] hostcpu: add support for reporting die_id in NUMA topology X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: Rciowh5lMd-O2QOT5_z13g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Update the host CPU code to report the die_id in the NUMA topology capabilities. On systems with multiple dies, this fixes the bug where CPU cores can't be distinguished: Notice how core_id is repeated within the scope of the same socket_id. It now reports So core_id is now unique within a (socket_id, die_id) pair. Reviewed-by: Daniel Henrique Barboza Reviewed-by: Jiri Denemark Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/schemas/capability.rng | 3 ++ src/conf/capabilities.c | 5 ++- src/conf/capabilities.h | 1 + src/libvirt_linux.syms | 1 + src/util/virhostcpu.c | 16 ++++++++++ src/util/virhostcpu.h | 1 + .../vircaps2xmldata/vircaps-aarch64-basic.xml | 32 +++++++++---------- .../vircaps2xmldata/vircaps-x86_64-basic.xml | 32 +++++++++---------- .../vircaps2xmldata/vircaps-x86_64-caches.xml | 16 +++++----- .../vircaps-x86_64-resctrl-cdp.xml | 24 +++++++------- .../vircaps-x86_64-resctrl-cmt.xml | 24 +++++++------- .../vircaps-x86_64-resctrl-fake-feature.xml | 24 +++++++------- .../vircaps-x86_64-resctrl-skx-twocaches.xml | 2 +- .../vircaps-x86_64-resctrl-skx.xml | 2 +- .../vircaps-x86_64-resctrl.xml | 24 +++++++------- 15 files changed, 116 insertions(+), 91 deletions(-) diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index 91ee523116..031c55bf20 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -265,6 +265,9 @@ + + + diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index bf1d9936ed..4bbc79334e 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -874,8 +874,9 @@ virCapabilitiesHostNUMAFormat(virCapsHostNUMAPtr caps, return -1; =20 virBufferAsprintf(buf, - " socket_id=3D'%d' core_id=3D'%d' siblin= gs=3D'%s'", + " socket_id=3D'%d' die_id=3D'%d' core_id= =3D'%d' siblings=3D'%s'", cell->cpus[j].socket_id, + cell->cpus[j].die_id, cell->cpus[j].core_id, siblings); VIR_FREE(siblings); @@ -1463,6 +1464,7 @@ virCapabilitiesFillCPUInfo(int cpu_id G_GNUC_UNUSED, cpu->id =3D cpu_id; =20 if (virHostCPUGetSocket(cpu_id, &cpu->socket_id) < 0 || + virHostCPUGetDie(cpu_id, &cpu->die_id) < 0 || virHostCPUGetCore(cpu_id, &cpu->core_id) < 0) return -1; =20 @@ -1591,6 +1593,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr ca= ps) goto error; if (tmp) { cpus[cid].id =3D id; + cpus[cid].die_id =3D 0; cpus[cid].socket_id =3D s; cpus[cid].core_id =3D c; if (!(cpus[cid].siblings =3D virBitmapNew(ncpus))) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 4a49e94aa5..75f29666c9 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -88,6 +88,7 @@ struct _virCapsGuest { struct _virCapsHostNUMACellCPU { unsigned int id; unsigned int socket_id; + unsigned int die_id; unsigned int core_id; virBitmapPtr siblings; }; diff --git a/src/libvirt_linux.syms b/src/libvirt_linux.syms index 5fa2c790ef..55649ae39c 100644 --- a/src/libvirt_linux.syms +++ b/src/libvirt_linux.syms @@ -4,6 +4,7 @@ =20 # util/virhostcpu.h virHostCPUGetCore; +virHostCPUGetDie; virHostCPUGetInfoPopulateLinux; virHostCPUGetSiblingsList; virHostCPUGetSocket; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 7f14340f49..0ed2c9e9b4 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -218,6 +218,22 @@ virHostCPUGetSocket(unsigned int cpu, unsigned int *so= cket) return 0; } =20 +int +virHostCPUGetDie(unsigned int cpu, unsigned int *die) +{ + int ret =3D virFileReadValueUint(die, + "%s/cpu/cpu%u/topology/die_id", + SYSFS_SYSTEM_PATH, cpu); + + /* If the file is not there, it's 0 */ + if (ret =3D=3D -2) + *die =3D 0; + else if (ret < 0) + return -1; + + return 0; +} + int virHostCPUGetCore(unsigned int cpu, unsigned int *core) { diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index d95d380d4a..9be2e51a38 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -65,6 +65,7 @@ int virHostCPUStatsAssign(virNodeCPUStatsPtr param, =20 #ifdef __linux__ int virHostCPUGetSocket(unsigned int cpu, unsigned int *socket); +int virHostCPUGetDie(unsigned int cpu, unsigned int *die); int virHostCPUGetCore(unsigned int cpu, unsigned int *core); =20 virBitmapPtr virHostCPUGetSiblingsList(unsigned int cpu); diff --git a/tests/vircaps2xmldata/vircaps-aarch64-basic.xml b/tests/vircap= s2xmldata/vircaps-aarch64-basic.xml index 50466f9162..0a04052c40 100644 --- a/tests/vircaps2xmldata/vircaps-aarch64-basic.xml +++ b/tests/vircaps2xmldata/vircaps-aarch64-basic.xml @@ -16,10 +16,10 @@ 4096 6144 - - - - + + + + @@ -28,10 +28,10 @@ 6144 8192 - - - - + + + + @@ -40,10 +40,10 @@ 8192 10240 - - - - + + + + @@ -52,10 +52,10 @@ 10240 12288 - - - - + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-basic.xml b/tests/vircaps= 2xmldata/vircaps-x86_64-basic.xml index e7be6def3e..4da09f889c 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-basic.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-basic.xml @@ -14,10 +14,10 @@ 4096 6144 - - - - + + + + @@ -26,10 +26,10 @@ 6144 8192 - - - - + + + + @@ -38,10 +38,10 @@ 8192 10240 - - - - + + + + @@ -50,10 +50,10 @@ 10240 12288 - - - - + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml b/tests/vircap= s2xmldata/vircaps-x86_64-caches.xml index ca671a1640..28f00c0a90 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml @@ -17,14 +17,14 @@ 4096 6144 - - - - - - - - + + + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml b/tests/v= ircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml index 1d3df318c5..ee26fe9464 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml @@ -17,12 +17,12 @@ 4096 6144 - - - - - - + + + + + + @@ -31,12 +31,12 @@ 6144 8192 - - - - - - + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cmt.xml b/tests/v= ircaps2xmldata/vircaps-x86_64-resctrl-cmt.xml index 6a8cd0e909..acdd97ec58 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cmt.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cmt.xml @@ -17,12 +17,12 @@ 4096 6144 - - - - - - + + + + + + @@ -31,12 +31,12 @@ 6144 8192 - - - - - - + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-fake-feature.xml = b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-fake-feature.xml index 4e46ead616..5f3678e072 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-fake-feature.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-fake-feature.xml @@ -17,12 +17,12 @@ 4096 6144 - - - - - - + + + + + + @@ -31,12 +31,12 @@ 6144 8192 - - - - - - + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml= b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml index 44c1042afe..6769bd0591 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx-twocaches.xml @@ -17,7 +17,7 @@ 4096 6144 - + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml b/tests/v= ircaps2xmldata/vircaps-x86_64-resctrl-skx.xml index 8382a26c7a..bc52480905 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml @@ -17,7 +17,7 @@ 4096 6144 - + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml b/tests/virca= ps2xmldata/vircaps-x86_64-resctrl.xml index a27b3e247e..c386edd4b0 100644 --- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml +++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml @@ -17,12 +17,12 @@ 4096 6144 - - - - - - + + + + + + @@ -31,12 +31,12 @@ 6144 8192 - - - - - - + + + + + + --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list