From nobody Mon Feb 9 02:52:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621857853; cv=none; d=zohomail.com; s=zohoarc; b=NnlgfvS20h1b9MPD9J5vKwd57FaM7TnERBvpaTMHujodVikeoIM/KNODI2vEr6XnW7RgU5fi6HQ1f7leubRTW6AHAQ+TPubBpZMI1b5Pgeh9HUVZevWerrZevFAXjlKviExUOqej1S64iJpqN+Z5oVo/47Vr7jWgu8HA0BriDaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621857853; h=Content-Type:Content-Transfer-Encoding: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=oiRvwMZ9hPZTcRIA7LRJ1wrpv7VkX29s6sxw7vPORZc=; b=f5o2mki1dY61OwT95YAL3kw6CCR1ExzkH5hhmJGBEO+V5s+r+62zRn4oKuHncNjw+mGz8cu8TMvLKIiqlrYqJNN+Q1cqQMaTss+21+mLecwY+mHG6rM5YiMLwPOowvTNahntVHHdpLv2os0ZoDXe+CXPyi3uX9uuPQdP4NH1QSE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1621857853597903.1371653188972; Mon, 24 May 2021 05:04:13 -0700 (PDT) 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-481--wKKyGHGN9qqXeLAWUrAVw-1; Mon, 24 May 2021 08:04:10 -0400 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 549F0107ACC7; Mon, 24 May 2021 12:04:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31EFA5D9D3; Mon, 24 May 2021 12:04:04 +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 ED0811800FFC; Mon, 24 May 2021 12:04:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14OC3olh006068 for ; Mon, 24 May 2021 08:03:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CD0C60861; Mon, 24 May 2021 12:03:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 103D660855 for ; Mon, 24 May 2021 12:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621857852; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=oiRvwMZ9hPZTcRIA7LRJ1wrpv7VkX29s6sxw7vPORZc=; b=UtMkVF/w9zqYIuW7QcLZ8cY/VV1qhP1Q6LlyFT2DqPncRVBZ0kfTnhQjx7heWhipngukQm WJF2ED5KbbVsh9XIqrG8OwV/9GMzwYNY4DSK8ypCGtGQK5IwKvdcuKvKtkF0xagx2ammNO H7qDUAG6fstydj2wD3IS4JdbuRrNeXI= X-MC-Unique: -wKKyGHGN9qqXeLAWUrAVw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/4] conf: Deduplicate NUMA distance code Date: Mon, 24 May 2021 14:03:09 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" After previous patches we have two structures: virCapsHostNUMACellDistance and virNumaDistance which express the same thing. And have the exact same members (modulo their names). Drop the former in favor of the latter. This change means that distances with value of 0 are no longer printed out into capabilities XML, because domain XML code allows partial distance specification and thus threats value of 0 as unspecified by user (see virDomainNumaGetNodeDistance() which returns the default LOCAL/REMOTE distance for value of 0). Also, from ACPI 6.1 specification, section 5.2.17 System Locality Distance Information Table (SLIT): Distance values of 0-9 are reserved and have no meaning. Thus we shouldn't be ever reporting 0 in neither domain nor capabilities XML. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- diff to v1: - Filled in justification to stop reporting 0 distance in capabilities XML (which we never did anyway). - Change capabilities RNG to make it obvious that NUMA distances are the same in domain and capabilities XMLs. docs/schemas/capability.rng | 13 +++---------- src/conf/capabilities.c | 26 ++++++++------------------ src/conf/capabilities.h | 11 +++-------- src/conf/virconftypes.h | 2 -- src/libxl/libxl_capabilities.c | 8 ++++---- 5 files changed, 18 insertions(+), 42 deletions(-) diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index c4cafc47ee..fb8203ad6d 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -157,16 +157,9 @@ =20 - - - - - - - - - - + + + =20 diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 926ecb5a24..1290c9c15d 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -349,7 +349,7 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps, int ncpus, virCapsHostNUMACellCPU **cpus, int ndistances, - virCapsHostNUMACellDistance **distances, + virNumaDistance **distances, int npageinfo, virCapsHostNUMACellPageInfo **pageinfo) { @@ -833,17 +833,7 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf, cell->pageinfo[j].avail); } =20 - if (cell->ndistances) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - for (j =3D 0; j < cell->ndistances; j++) { - virBufferAsprintf(buf, "\= n", - cell->distances[j].node, - cell->distances[j].distance); - } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + virNumaDistanceFormat(buf, cell->distances, cell->ndistances); =20 virBufferAsprintf(buf, "\n", cell->ncpus); virBufferAdjustIndent(buf, 2); @@ -1457,10 +1447,10 @@ virCapabilitiesFillCPUInfo(int cpu_id G_GNUC_UNUSED, =20 static int virCapabilitiesGetNUMADistances(int node, - virCapsHostNUMACellDistance **distancesRet, + virNumaDistance **distancesRet, int *ndistancesRet) { - virCapsHostNUMACellDistance *tmp =3D NULL; + virNumaDistance *tmp =3D NULL; int tmp_size =3D 0; int ret =3D -1; int *distances =3D NULL; @@ -1476,14 +1466,14 @@ virCapabilitiesGetNUMADistances(int node, return 0; } =20 - tmp =3D g_new0(virCapsHostNUMACellDistance, ndistances); + tmp =3D g_new0(virNumaDistance, ndistances); =20 for (i =3D 0; i < ndistances; i++) { if (!distances[i]) continue; =20 - tmp[tmp_size].node =3D i; - tmp[tmp_size].distance =3D distances[i]; + tmp[tmp_size].cellid =3D i; + tmp[tmp_size].value =3D distances[i]; tmp_size++; } =20 @@ -1607,7 +1597,7 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) =20 for (n =3D 0; n <=3D max_node; n++) { g_autoptr(virBitmap) cpumap =3D NULL; - g_autofree virCapsHostNUMACellDistance *distances =3D NULL; + g_autofree virNumaDistance *distances =3D NULL; int ndistances =3D 0; g_autofree virCapsHostNUMACellPageInfo *pageinfo =3D NULL; int npageinfo; diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index f11471ef6c..4d4ac476ea 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -94,11 +94,6 @@ struct _virCapsHostNUMACellCPU { virBitmap *siblings; }; =20 -struct _virCapsHostNUMACellDistance { - int node; /* foreign NUMA node */ - unsigned int distance; /* distance to the node */ -}; - struct _virCapsHostNUMACellPageInfo { unsigned int size; /* page size in kibibytes */ unsigned long long avail; /* the size of pool */ @@ -109,8 +104,8 @@ struct _virCapsHostNUMACell { int ncpus; unsigned long long mem; /* in kibibytes */ virCapsHostNUMACellCPU *cpus; - int ndistances; - virCapsHostNUMACellDistance *distances; + size_t ndistances; + virNumaDistance *distances; int npageinfo; virCapsHostNUMACellPageInfo *pageinfo; }; @@ -256,7 +251,7 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps, int ncpus, virCapsHostNUMACellCPU **cpus, int ndistances, - virCapsHostNUMACellDistance **distances, + virNumaDistance **distances, int npageinfo, virCapsHostNUMACellPageInfo **pageinfo); =20 diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index d21d5a1be3..b21068486e 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -60,8 +60,6 @@ typedef struct _virCapsHostNUMACellCPU virCapsHostNUMACel= lCPU; =20 typedef struct _virCapsHostNUMACellPageInfo virCapsHostNUMACellPageInfo; =20 -typedef struct _virCapsHostNUMACellDistance virCapsHostNUMACellDistance; - typedef struct _virCapsHostSecModel virCapsHostSecModel; =20 typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel; diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index d1a1241279..a73f13f829 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -249,7 +249,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps) libxl_cputopology *cpu_topo =3D NULL; int nr_nodes =3D 0, nr_cpus =3D 0, nr_distances =3D 0; virCapsHostNUMACellCPU **cpus =3D NULL; - virCapsHostNUMACellDistance *distances =3D NULL; + virNumaDistance *distances =3D NULL; int *nr_cpus_node =3D NULL; size_t i; int ret =3D -1; @@ -320,11 +320,11 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps) if (nr_distances) { size_t j; =20 - distances =3D g_new0(virCapsHostNUMACellDistance, nr_distances= ); + distances =3D g_new0(virNumaDistance, nr_distances); =20 for (j =3D 0; j < nr_distances; j++) { - distances[j].node =3D j; - distances[j].distance =3D numa_info[i].dists[j]; + distances[j].cellid =3D j; + distances[j].value =3D numa_info[i].dists[j]; } } =20 --=20 2.26.3