From nobody Thu May 2 04:44:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1576670301; cv=none; d=zohomail.com; s=zohoarc; b=BPjvxw3KWobfRRkNoUrFiLRW0vANa1+2fk6eXNxdXJ9Fd2ROvyXFPiDiHvv2H9gDfHQQZ23PfkTbIAaLVvpkquk8ACxho162jt7+xGBBDEslGZANSx2FTBPb6aqMG3KTYB+3xIGrLFPCqJe7R7CjPZh+619eJJ7wMK55aP4hUl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576670301; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=QyuwouAZCYo6Ut3M+k2aDhxZLtW0xadIKBux+pwsVfc=; b=iMk4FVpyFzVmmMcfk4Qdid1CsrrvZ512+EOfifpLctybP9qAm6Uy0n+uCDeZvdEHEwr48hCZpkwZzQOsV93cjTEQsp4AmykZe+0uU9fSkGqMHmMCbeyC0TnpESXpvZGUY13j9E0g5QgfGawpdzIi4Qvpr5ifAq+/RZE4PaT+jBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1576670301662376.0717111581946; Wed, 18 Dec 2019 03:58:21 -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-256-EomTufaiNdeoHSuftZkizA-1; Wed, 18 Dec 2019 06:58:18 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E0FA107ACC4; Wed, 18 Dec 2019 11:58:13 +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 173B66888B; Wed, 18 Dec 2019 11:58: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 71B9718089CF; Wed, 18 Dec 2019 11:58:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBIBwBdn001800 for ; Wed, 18 Dec 2019 06:58:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9D1F768887; Wed, 18 Dec 2019 11:58:11 +0000 (UTC) Received: from wlan-5-103.fab.redhat.com (wlan-5-103.fab.redhat.com [10.33.5.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBF471891F; Wed, 18 Dec 2019 11:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576670300; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QyuwouAZCYo6Ut3M+k2aDhxZLtW0xadIKBux+pwsVfc=; b=h7KG6aPo3KaXtlNXgNZRaggp6S/s/pSu+Nkvor7sGB06z6lPH94maC7o/bAb8pgHlchKOs OH3ashd98mrMiyzgrqvyDKhjaFWQDj5qAK71heeMTv7o9iJjWATQEkV9b/oWmnOj2KvJcD MkkWcqwO8+/F+XGghjbLWzNwx8RZ09E= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 18 Dec 2019 11:58:06 +0000 Message-Id: <20191218115806.760875-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] conf: fix populating of fake NUMA in multi-node hosts 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.15 X-MC-Unique: EomTufaiNdeoHSuftZkizA-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) If the host OS doesn't have NUMA present, we fallback to populating fake NUMA info and the code thus assumes only a single NUMA node. Unfortunately we also fallback to fake NUMA if numactl-devel was not present, and in this case we can still have multiple NUMA nodes. In this case we create all CPUs, but only the CPUs in the first node have any data filled in, resulting in capabilities like: 15977572 With this new code we get something slightly less broken 15977572 15977572 The topology at least now reflects what 'virsh nodeinfo' reports. The main bug is that the CPU "id" values won't match what the Linux host actually uses. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/conf/capabilities.c | 67 ++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 81a2004dba..2a183d7070 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1593,7 +1593,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr ca= ps) virNodeInfo nodeinfo; virCapsHostNUMACellCPUPtr cpus; int ncpus; - int s, c, t; + int n, s, c, t; int id, cid; int onlinecpus G_GNUC_UNUSED; bool tmp; @@ -1602,47 +1602,52 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr = caps) return -1; =20 ncpus =3D VIR_NODEINFO_MAXCPUS(nodeinfo); - onlinecpus =3D nodeinfo.cpus; =20 - if (VIR_ALLOC_N(cpus, ncpus) < 0) - return -1; =20 - id =3D cid =3D 0; - for (s =3D 0; s < nodeinfo.sockets; s++) { - for (c =3D 0; c < nodeinfo.cores; c++) { - for (t =3D 0; t < nodeinfo.threads; t++) { - if (virHostCPUGetOnline(id, &tmp) < 0) - goto error; - if (tmp) { - cpus[cid].id =3D id; - cpus[cid].socket_id =3D s; - cpus[cid].core_id =3D c; - if (!(cpus[cid].siblings =3D virBitmapNew(ncpus))) + id =3D 0; + for (n =3D 0; n < nodeinfo.nodes; n++) { + int nodecpus =3D nodeinfo.sockets * nodeinfo.cores * nodeinfo.thre= ads; + cid =3D 0; + + if (VIR_ALLOC_N(cpus, nodecpus) < 0) + return -1; + + for (s =3D 0; s < nodeinfo.sockets; s++) { + for (c =3D 0; c < nodeinfo.cores; c++) { + g_autoptr(virBitmap) siblings =3D virBitmapNew(ncpus); + for (t =3D 0; t < nodeinfo.threads; t++) + ignore_value(virBitmapSetBit(siblings, id + t)); + + for (t =3D 0; t < nodeinfo.threads; t++) { + if (virHostCPUGetOnline(id, &tmp) < 0) goto error; - ignore_value(virBitmapSetBit(cpus[cid].siblings, id)); - cid++; + if (tmp) { + cpus[cid].id =3D id; + cpus[cid].socket_id =3D s; + cpus[cid].core_id =3D c; + if (!(cpus[cid].siblings =3D virBitmapNew(ncpus))) + goto error; + virBitmapCopy(cpus[cid].siblings, siblings); + cid++; + } + + id++; } - - id++; } } - } =20 - virCapabilitiesHostNUMAAddCell(caps, 0, - nodeinfo.memory, -#ifdef __linux__ - onlinecpus, cpus, -#else - ncpus, cpus, -#endif - 0, NULL, - 0, NULL); + virCapabilitiesHostNUMAAddCell(caps, 0, + nodeinfo.memory, + cid, cpus, + 0, NULL, + 0, NULL); + } =20 return 0; =20 error: - for (; id >=3D 0; id--) - virBitmapFree(cpus[id].siblings); + for (; cid >=3D 0; cid--) + virBitmapFree(cpus[cid].siblings); VIR_FREE(cpus); return -1; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list