From nobody Fri May 17 04:49:25 2024 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=1621524969; cv=none; d=zohomail.com; s=zohoarc; b=PFcdGFod4dStVvP5wF3gXu1zyh+HSgDpG3wKebRbNn6E7mT9PAQ2i/H8eVKTRjvYeHZs76grsaiaBtEdYg/wREx7qrpqlIwklyPNvxR9SYttWjrDjPkVsOrAIBWekmdLz1LIiX2vBtg9UAhfv3coOINpfZusxiJ5AyuW/j5X03Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621524969; 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=/OMNkrFqJC34OjQpYhVfHsg0vQlAcAdPvTLBN1LPumA=; b=FOAqyaRGROhTf5fThqGgHSaPsC/zweswKaGb1YNUPI9P43wycZaQjgOZeGrbtGARoEtTOXdYARJ7iCeEapSgIutjfX+/42FFqKNBJzawxGOxv+DuIlRBTas/q5JoKtxkcItNMGH2OyloQ7GClBCaye6P7u4qudone7DMVPeAIqU= 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 1621524969498860.5539761432442; Thu, 20 May 2021 08:36:09 -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-603-mgoHivqfPVmyGBui09kptA-1; Thu, 20 May 2021 11:36:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8FF8086ABCE; Thu, 20 May 2021 15:35:59 +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 8AF92687DB; Thu, 20 May 2021 15:35:57 +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 53F4944A5D; Thu, 20 May 2021 15:35:55 +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 14KFPVsp018220 for ; Thu, 20 May 2021 11:25:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 103CB687EC; Thu, 20 May 2021 15:25:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 616486A045 for ; Thu, 20 May 2021 15:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621524968; 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=/OMNkrFqJC34OjQpYhVfHsg0vQlAcAdPvTLBN1LPumA=; b=cQbvPFMtyWc5s5d/8229r82e1h1DfXwXQJkar2IzY/8L/FnGaFmJKYBzUhNELwMrfq4UJz grCMf90D5Y2MLWgmThGVUP7SaQcf7HbeOyPvHbYOMih+vxwhemBO90b7jEfe/mZOYSsR2f Jenqc3fsp38SEZ3UMxknGkrYr6hyhXU= X-MC-Unique: mgoHivqfPVmyGBui09kptA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] capabilities: Rename siblings to distances Date: Thu, 20 May 2021 17:24:53 +0200 Message-Id: <908346aa387b071848b2731a8aff233e35c9dc05.1621524173.git.mprivozn@redhat.com> 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.13 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" The virCapsHostNUMACellSiblingInfo structure really represents distance to other NUMA node. Rename the structure and variables of that type to make it more obvious. Signed-off-by: Michal Privoznik --- src/conf/capabilities.c | 52 +++++++++++++++++----------------- src/conf/capabilities.h | 10 +++---- src/conf/virconftypes.h | 2 +- src/libxl/libxl_capabilities.c | 20 ++++++------- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 7fe282ad3a..926ecb5a24 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -119,7 +119,7 @@ virCapabilitiesFreeHostNUMACell(virCapsHostNUMACell *ce= ll) virCapabilitiesClearHostNUMACellCPUTopology(cell->cpus, cell->ncpus); =20 g_free(cell->cpus); - g_free(cell->siblings); + g_free(cell->distances); g_free(cell->pageinfo); g_free(cell); } @@ -331,8 +331,8 @@ virCapabilitiesSetNetPrefix(virCaps *caps, * @mem: Total size of memory in the NUMA node (in KiB) * @ncpus: number of CPUs in cell * @cpus: array of CPU definition structures - * @nsiblings: number of sibling NUMA nodes - * @siblings: info on sibling NUMA nodes + * @ndistances: number of sibling NUMA nodes + * @distances: NUMA distances to other nodes * @npageinfo: number of pages at node @num * @pageinfo: info on each single memory page * @@ -348,8 +348,8 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps, unsigned long long mem, int ncpus, virCapsHostNUMACellCPU **cpus, - int nsiblings, - virCapsHostNUMACellSiblingInfo **siblings, + int ndistances, + virCapsHostNUMACellDistance **distances, int npageinfo, virCapsHostNUMACellPageInfo **pageinfo) { @@ -361,9 +361,9 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps, cell->ncpus =3D ncpus; cell->cpus =3D g_steal_pointer(cpus); } - if (siblings) { - cell->nsiblings =3D nsiblings; - cell->siblings =3D g_steal_pointer(siblings); + if (distances) { + cell->ndistances =3D ndistances; + cell->distances =3D g_steal_pointer(distances); } if (pageinfo) { cell->npageinfo =3D npageinfo; @@ -833,13 +833,13 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf, cell->pageinfo[j].avail); } =20 - if (cell->nsiblings) { + if (cell->ndistances) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - for (j =3D 0; j < cell->nsiblings; j++) { + for (j =3D 0; j < cell->ndistances; j++) { virBufferAsprintf(buf, "\= n", - cell->siblings[j].node, - cell->siblings[j].distance); + cell->distances[j].node, + cell->distances[j].distance); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -1456,11 +1456,11 @@ virCapabilitiesFillCPUInfo(int cpu_id G_GNUC_UNUSED, } =20 static int -virCapabilitiesGetNUMASiblingInfo(int node, - virCapsHostNUMACellSiblingInfo **sibling= s, - int *nsiblings) +virCapabilitiesGetNUMADistances(int node, + virCapsHostNUMACellDistance **distancesRet, + int *ndistancesRet) { - virCapsHostNUMACellSiblingInfo *tmp =3D NULL; + virCapsHostNUMACellDistance *tmp =3D NULL; int tmp_size =3D 0; int ret =3D -1; int *distances =3D NULL; @@ -1471,12 +1471,12 @@ virCapabilitiesGetNUMASiblingInfo(int node, goto cleanup; =20 if (!distances) { - *siblings =3D NULL; - *nsiblings =3D 0; + *distancesRet =3D NULL; + *ndistancesRet =3D 0; return 0; } =20 - tmp =3D g_new0(virCapsHostNUMACellSiblingInfo, ndistances); + tmp =3D g_new0(virCapsHostNUMACellDistance, ndistances); =20 for (i =3D 0; i < ndistances; i++) { if (!distances[i]) @@ -1489,8 +1489,8 @@ virCapabilitiesGetNUMASiblingInfo(int node, =20 VIR_REALLOC_N(tmp, tmp_size); =20 - *nsiblings =3D tmp_size; - *siblings =3D g_steal_pointer(&tmp); + *ndistancesRet =3D tmp_size; + *distancesRet =3D g_steal_pointer(&tmp); tmp_size =3D 0; ret =3D 0; cleanup: @@ -1607,8 +1607,8 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) =20 for (n =3D 0; n <=3D max_node; n++) { g_autoptr(virBitmap) cpumap =3D NULL; - g_autofree virCapsHostNUMACellSiblingInfo *siblings =3D NULL; - int nsiblings =3D 0; + g_autofree virCapsHostNUMACellDistance *distances =3D NULL; + int ndistances =3D 0; g_autofree virCapsHostNUMACellPageInfo *pageinfo =3D NULL; int npageinfo; unsigned long long memory; @@ -1632,8 +1632,8 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) } } =20 - if (virCapabilitiesGetNUMASiblingInfo(n, &siblings, &nsiblings) < = 0) - goto cleanup; + if (virCapabilitiesGetNUMADistances(n, &distances, &ndistances) < = 0) + return -1; =20 if (virCapabilitiesGetNUMAPagesInfo(n, &pageinfo, &npageinfo) < 0) goto cleanup; @@ -1644,7 +1644,7 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps) =20 virCapabilitiesHostNUMAAddCell(caps, n, memory, ncpus, &cpus, - nsiblings, &siblings, + ndistances, &distances, npageinfo, &pageinfo); } =20 diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index ba863447c0..f11471ef6c 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -94,7 +94,7 @@ struct _virCapsHostNUMACellCPU { virBitmap *siblings; }; =20 -struct _virCapsHostNUMACellSiblingInfo { +struct _virCapsHostNUMACellDistance { int node; /* foreign NUMA node */ unsigned int distance; /* distance to the node */ }; @@ -109,8 +109,8 @@ struct _virCapsHostNUMACell { int ncpus; unsigned long long mem; /* in kibibytes */ virCapsHostNUMACellCPU *cpus; - int nsiblings; - virCapsHostNUMACellSiblingInfo *siblings; + int ndistances; + virCapsHostNUMACellDistance *distances; int npageinfo; virCapsHostNUMACellPageInfo *pageinfo; }; @@ -255,8 +255,8 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps, unsigned long long mem, int ncpus, virCapsHostNUMACellCPU **cpus, - int nsiblings, - virCapsHostNUMACellSiblingInfo **siblings, + int ndistances, + virCapsHostNUMACellDistance **distances, int npageinfo, virCapsHostNUMACellPageInfo **pageinfo); =20 diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index ff5d8145c3..d21d5a1be3 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -60,7 +60,7 @@ typedef struct _virCapsHostNUMACellCPU virCapsHostNUMACel= lCPU; =20 typedef struct _virCapsHostNUMACellPageInfo virCapsHostNUMACellPageInfo; =20 -typedef struct _virCapsHostNUMACellSiblingInfo virCapsHostNUMACellSiblingI= nfo; +typedef struct _virCapsHostNUMACellDistance virCapsHostNUMACellDistance; =20 typedef struct _virCapsHostSecModel virCapsHostSecModel; =20 diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index ea4f370a6d..d1a1241279 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -247,9 +247,9 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps) { libxl_numainfo *numa_info =3D NULL; libxl_cputopology *cpu_topo =3D NULL; - int nr_nodes =3D 0, nr_cpus =3D 0, nr_siblings =3D 0; + int nr_nodes =3D 0, nr_cpus =3D 0, nr_distances =3D 0; virCapsHostNUMACellCPU **cpus =3D NULL; - virCapsHostNUMACellSiblingInfo *siblings =3D NULL; + virCapsHostNUMACellDistance *distances =3D NULL; int *nr_cpus_node =3D NULL; size_t i; int ret =3D -1; @@ -316,22 +316,22 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps) if (numa_info[i].size =3D=3D LIBXL_NUMAINFO_INVALID_ENTRY) continue; =20 - nr_siblings =3D numa_info[i].num_dists; - if (nr_siblings) { + nr_distances =3D numa_info[i].num_dists; + if (nr_distances) { size_t j; =20 - siblings =3D g_new0(virCapsHostNUMACellSiblingInfo, nr_sibling= s); + distances =3D g_new0(virCapsHostNUMACellDistance, nr_distances= ); =20 - for (j =3D 0; j < nr_siblings; j++) { - siblings[j].node =3D j; - siblings[j].distance =3D numa_info[i].dists[j]; + for (j =3D 0; j < nr_distances; j++) { + distances[j].node =3D j; + distances[j].distance =3D numa_info[i].dists[j]; } } =20 virCapabilitiesHostNUMAAddCell(caps->host.numa, i, numa_info[i].size / 1024, nr_cpus_node[i], &cpus[i], - nr_siblings, &siblings, + nr_distances, &distances, 0, NULL); =20 /* This is safe, as the CPU list is now stored in the NUMA cell */ @@ -348,7 +348,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps) virCapabilitiesHostNUMAUnref(caps->host.numa); caps->host.numa =3D NULL; } - VIR_FREE(siblings); + VIR_FREE(distances); } =20 VIR_FREE(cpus); --=20 2.26.3 From nobody Fri May 17 04:49:25 2024 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=1621524983; cv=none; d=zohomail.com; s=zohoarc; b=YMg/q741bxQIYJQgn9kYmvHU3d77s3krPl8jMy0rr1ioLeSkuvHFsvgSWwFNvSQ+3Rk7q/rbAdzNir9WXYrNd8PieKbME1wfeZrIHTIbMSuqCMVT0ezcl8PtDOe04b0+GYsQB+fV1MI3DRD178nWBwzJI3hZjOgXPKgaq7rOpYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621524983; 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=b4ie9n1v8Za8zYa5wNnoCibFRsN3BOBlVuvDfzEeaqE=; b=KlVysUkYJrigHaMOYKnc8pk0VV0mL9LG0OjyWbNUfusQ6E+pk5rGRCJRj39Nw3CZLcOIFfGd6VtaD7DsvoYWXc4VHtfZB5eL5ss8mLBbK2pQA87ml7o86DIuPmdIVysNeo0u/XlYrOQiUHaaA4qWaYWiTdYvTYgRc0VKXJy9g5s= 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 1621524983798559.9709421686737; Thu, 20 May 2021 08:36:23 -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-109-4D7XyBKaNkaIIXkwnhbHyQ-1; Thu, 20 May 2021 11:36:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86024593C3; Thu, 20 May 2021 15:36:13 +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 50B9760C03; Thu, 20 May 2021 15:36:13 +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 1579C55355; Thu, 20 May 2021 15:36:13 +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 14KFPV4P018226 for ; Thu, 20 May 2021 11:25:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC451687F0; Thu, 20 May 2021 15:25:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60A25687EC for ; Thu, 20 May 2021 15:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621524982; 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=b4ie9n1v8Za8zYa5wNnoCibFRsN3BOBlVuvDfzEeaqE=; b=e8GvBYm49v2q7x2OrD1ID2Kdj9Rc35F6NGnUnLN++O9DwrF3iUwGKwZO3VUTkZSL43/rgd goAIfVK9QZ0/6bJ1tMO1ZO5GB2BKfeap/dTbefD1l32Ouln3DPHMluH40qFSDaD9N0N9W7 uXQHTCVj4sFsPHji3qHvo0CwOo1IYeA= X-MC-Unique: 4D7XyBKaNkaIIXkwnhbHyQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] numa_conf: Rename virDomainNumaDistance to virNumaDistance Date: Thu, 20 May 2021 17:24:54 +0200 Message-Id: <2b70d8e3350616177b191287e06142298bb62fbc.1621524173.git.mprivozn@redhat.com> 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.13 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" There's nothing domain specific about NUMA distances. Rename the virDomainNumaDistance structure to just virNumaDistance. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/numa_conf.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 537e515b5a..fa39c1ccc0 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -82,7 +82,7 @@ VIR_ENUM_IMPL(virDomainMemoryLatency, "write" ); =20 -typedef struct _virDomainNumaDistance virDomainNumaDistance; +typedef struct _virNumaDistance virNumaDistance; =20 typedef struct _virDomainNumaCache virDomainNumaCache; =20 @@ -106,7 +106,7 @@ struct _virDomainNuma { virDomainMemoryAccess memAccess; /* shared memory access configura= tion */ virTristateBool discard; /* discard-data for memory-backend-file */ =20 - struct _virDomainNumaDistance { + struct _virNumaDistance { unsigned int value; /* locality value for node i->j or j->i */ unsigned int cellid; } *distances; /* remote node distances */ @@ -759,8 +759,8 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def, } =20 for (i =3D 0; i < sibling; i++) { - virDomainNumaDistance *ldist; - virDomainNumaDistance *rdist; + virNumaDistance *ldist; + virNumaDistance *rdist; unsigned int sibling_id, sibling_value; =20 if (virXMLPropUInt(nodes[i], "id", 10, VIR_XML_PROP_REQUIRED, @@ -799,7 +799,7 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def, /* Apply the local / remote distance */ ldist =3D def->mem_nodes[cur_cell].distances; if (!ldist) { - ldist =3D g_new0(virDomainNumaDistance, ndistances); + ldist =3D g_new0(virNumaDistance, ndistances); ldist[cur_cell].value =3D LOCAL_DISTANCE; ldist[cur_cell].cellid =3D cur_cell; def->mem_nodes[cur_cell].ndistances =3D ndistances; @@ -812,7 +812,7 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def, /* Apply symmetry if none given */ rdist =3D def->mem_nodes[sibling_id].distances; if (!rdist) { - rdist =3D g_new0(virDomainNumaDistance, ndistances); + rdist =3D g_new0(virNumaDistance, ndistances); rdist[sibling_id].value =3D LOCAL_DISTANCE; rdist[sibling_id].cellid =3D sibling_id; def->mem_nodes[sibling_id].ndistances =3D ndistances; @@ -1133,7 +1133,7 @@ virDomainNumaDefFormatXML(virBuffer *buf, virTristateBoolTypeToString(discard)); =20 if (def->mem_nodes[i].ndistances) { - virDomainNumaDistance *distances =3D def->mem_nodes[i].distanc= es; + virNumaDistance *distances =3D def->mem_nodes[i].distances; =20 virBufferAddLit(&childBuf, "\n"); virBufferAdjustIndent(&childBuf, 2); @@ -1501,7 +1501,7 @@ virDomainNumaGetNodeDistance(virDomainNuma *numa, size_t node, size_t cellid) { - virDomainNumaDistance *distances =3D NULL; + virNumaDistance *distances =3D NULL; =20 if (node < numa->nmem_nodes) distances =3D numa->mem_nodes[node].distances; @@ -1526,7 +1526,7 @@ virDomainNumaSetNodeDistance(virDomainNuma *numa, size_t cellid, unsigned int value) { - virDomainNumaDistance *distances; + virNumaDistance *distances; =20 if (node >=3D numa->nmem_nodes) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1579,7 +1579,7 @@ virDomainNumaSetNodeDistanceCount(virDomainNuma *numa, size_t node, size_t ndistances) { - virDomainNumaDistance *distances; + virNumaDistance *distances; =20 distances =3D numa->mem_nodes[node].distances; if (distances) { @@ -1589,7 +1589,7 @@ virDomainNumaSetNodeDistanceCount(virDomainNuma *numa, return 0; } =20 - distances =3D g_new0(struct _virDomainNumaDistance, ndistances); + distances =3D g_new0(virNumaDistance, ndistances); =20 numa->mem_nodes[node].distances =3D distances; numa->mem_nodes[node].ndistances =3D ndistances; --=20 2.26.3 From nobody Fri May 17 04:49:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1621524986; cv=none; d=zohomail.com; s=zohoarc; b=AL0w9vtJ/jQeysevCXE4bMdCVRcZ233Qy/z4jHOVZHSla5UfLP8293e7VcO/wfkALX06IvsZf3bhuMtSn1DuMIZNYiDcNB+8LWIdbhqO5gBpQZibylKgJ98Boz/4MEfTdqphsb19DmMP18gn5gqg7nL6dok20zpho9PrRQ0Cy4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621524986; 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=WQYh90HZ6OcE5HeiVdTYYX/rbtvayBR4i1mguh9EmFE=; b=BHtF12aAA4EL8BHFIdjAwPEcnh6FNUYgJ+nhsArW7KzKV+Se0PewBfslVElfhT84q5WOaWm2xvzcL5F9Ot4bG1gHf8Y5hynhmdLI1TqojKc/56H7nUs1vX9UTmXh1ynWJEre/WREEqODcEeZ6MINLNQrLP+u+Udm41sQpmbPW2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621524986142428.93188232006185; Thu, 20 May 2021 08:36:26 -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-408-adRcStbSOTij1tx7-41I0A-1; Thu, 20 May 2021 11:36:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEEBF100C61D; Thu, 20 May 2021 15:36:16 +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 9CAA35C23E; Thu, 20 May 2021 15:36:16 +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 578D355355; Thu, 20 May 2021 15:36:16 +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 14KFPW3s018235 for ; Thu, 20 May 2021 11:25:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id B259F687F0; Thu, 20 May 2021 15:25:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37A94687EC for ; Thu, 20 May 2021 15:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621524985; 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=WQYh90HZ6OcE5HeiVdTYYX/rbtvayBR4i1mguh9EmFE=; b=SeQJUYqcH6IcoU2hhr1dJGzcB0t0S9XXFUVNiVGjmo45e+WYuC6K93Uh2pd2daf3XQ26H1 aQghWB6DcPHDUPFBwM6TUjjSiI9i6jyu/mw3qezwth1ULPNd9rPx2rpsXACFsyepF9ioJT svsdMX9R+12PyDgInzjQlb9VrE7+Bl0= X-MC-Unique: adRcStbSOTij1tx7-41I0A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] numa_conf: Expose virNumaDistance formatter Date: Thu, 20 May 2021 17:24:55 +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.16 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" Expose virNumaDistance XML formatter so that it can be re-used by other parts of the code. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/numa_conf.c | 47 +++++++++++++++++++++------------------- src/conf/numa_conf.h | 10 +++++++++ src/libvirt_private.syms | 1 + 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index fa39c1ccc0..8fd5635aca 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -82,8 +82,6 @@ VIR_ENUM_IMPL(virDomainMemoryLatency, "write" ); =20 -typedef struct _virNumaDistance virNumaDistance; - typedef struct _virDomainNumaCache virDomainNumaCache; =20 typedef struct _virDomainNumaInterconnect virDomainNumaInterconnect; @@ -106,10 +104,7 @@ struct _virDomainNuma { virDomainMemoryAccess memAccess; /* shared memory access configura= tion */ virTristateBool discard; /* discard-data for memory-backend-file */ =20 - struct _virNumaDistance { - unsigned int value; /* locality value for node i->j or j->i */ - unsigned int cellid; - } *distances; /* remote node distances */ + virNumaDistance *distances; /* remote node distances */ size_t ndistances; =20 struct _virDomainNumaCache { @@ -1132,22 +1127,9 @@ virDomainNumaDefFormatXML(virBuffer *buf, virBufferAsprintf(&attrBuf, " discard=3D'%s'", virTristateBoolTypeToString(discard)); =20 - if (def->mem_nodes[i].ndistances) { - virNumaDistance *distances =3D def->mem_nodes[i].distances; - - virBufferAddLit(&childBuf, "\n"); - virBufferAdjustIndent(&childBuf, 2); - for (j =3D 0; j < def->mem_nodes[i].ndistances; j++) { - if (distances[j].value) { - virBufferAddLit(&childBuf, "\n"); - } - } - virBufferAdjustIndent(&childBuf, -2); - virBufferAddLit(&childBuf, "\n"); - } + virNumaDistanceFormat(&childBuf, + def->mem_nodes[i].distances, + def->mem_nodes[i].ndistances); =20 for (j =3D 0; j < def->mem_nodes[i].ncaches; j++) { virDomainNumaCache *cache =3D &def->mem_nodes[i].caches[j]; @@ -1836,3 +1818,24 @@ virDomainNumaGetInterconnect(const virDomainNuma *nu= ma, *value =3D l->value; return 0; } + + +void +virNumaDistanceFormat(virBuffer *buf, + const virNumaDistance *distances, + size_t ndistances) +{ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + size_t i; + + for (i =3D 0; i < ndistances; i++) { + if (distances[i].value =3D=3D 0) + continue; + virBufferAddLit(&childBuf, "\n"); + } + + virXMLFormatElement(buf, "distances", NULL, &childBuf); +} diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 8f6597b0b7..6682580ded 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -249,3 +249,13 @@ int virDomainNumaGetInterconnect(const virDomainNuma *= numa, unsigned int *cache, virDomainMemoryLatency *accessType, unsigned long *value); + +typedef struct _virNumaDistance virNumaDistance; +struct _virNumaDistance { + unsigned int value; /* locality value for node i->j or j->i */ + unsigned int cellid; +}; + +void virNumaDistanceFormat(virBuffer *buf, + const virNumaDistance *distances, + size_t ndistances); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6fbdee4124..fcf833429b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -913,6 +913,7 @@ virDomainNumatunePlacementTypeFromString; virDomainNumatunePlacementTypeToString; virDomainNumatuneSet; virDomainNumatuneSpecifiedMaxNode; +virNumaDistanceFormat; =20 =20 # conf/nwfilter_conf.h --=20 2.26.3 From nobody Fri May 17 04:49:25 2024 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=1621525033; cv=none; d=zohomail.com; s=zohoarc; b=Mt4IIB0k1kZ/VV7rO8YYHoFb2wmJ70zApvcni2sdEZ5yz/nL/WT4ustQ7d4xIbKZQ3eo5gpRUQsWXXVs2/d1KkXbQbmobknyWRBaYFOvrxZG5KsNd+vvBw4CUYJbPYZwbcOJCZaFFnNxkG23UFtb0kaN3xQfE062m2zxxQWPKgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621525033; 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=1mitbmAqIEDToCd4wt9go8i/nTnO1zuhDV5eUjSKnf8=; b=JQ7796q9oTJCNLxgARK9124QfFwvtCacT6bnRg7ril2tCa/A1mlaFppbGLmNkxjQgkD46/r/fxuEVbjuauHuxPmOdRko5JDg3Z9mP8zaWYxzxQs6uiX8HD27WEFUdQH1i+WCwx5ZPjPlz48YQFoqXTpqDcID11xYLuFh67Nyfio= 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 1621525033390316.76519376215003; Thu, 20 May 2021 08:37: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-597-KebfFyvlP8Gnd6Tvy3XcTg-1; Thu, 20 May 2021 11:36:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F65B1012D97; Thu, 20 May 2021 15:36:21 +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 3C8535C276; Thu, 20 May 2021 15:36:21 +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 07CB31800BB8; Thu, 20 May 2021 15:36:21 +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 14KFPXgN018240 for ; Thu, 20 May 2021 11:25:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8935C687F0; Thu, 20 May 2021 15:25:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E402687EC for ; Thu, 20 May 2021 15:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621525032; 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=1mitbmAqIEDToCd4wt9go8i/nTnO1zuhDV5eUjSKnf8=; b=Og4Ngzl77cTJeKKrCiw8pLCoJFkkx89RRv66ETYXc8FLiPu50Z/PkmFbS+8d8jxFRbwFQA U6Ucb903AW0co/Jn2bmOxmjSUUHd9ZcDhrZHlq06kS/CDlL09qrlJU/7FBD6oStnBG12U8 OC9eEl/fEcNE5WJ+NVu0Px1ECKqkBrE= X-MC-Unique: KebfFyvlP8Gnd6Tvy3XcTg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] conf: Deduplicate NUMA distance code Date: Thu, 20 May 2021 17:24:56 +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.16 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. Signed-off-by: Michal Privoznik --- src/conf/capabilities.c | 26 ++++++++------------------ src/conf/capabilities.h | 11 +++-------- src/conf/virconftypes.h | 2 -- src/libxl/libxl_capabilities.c | 8 ++++---- 4 files changed, 15 insertions(+), 32 deletions(-) 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 From nobody Fri May 17 04:49:25 2024 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