From nobody Sun May 5 13:09:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1598022967; cv=none; d=zohomail.com; s=zohoarc; b=I/NLH+XMK9mzO6HlqIkX1BYDEwTLlAv7Sx37Bn0Zf2qivOTo6jS5ZZUBWGmgnp29bj7qq6Kg2fn92HhXLl6lubSe+HTAO7H7c7BQ2H9ScSGfeUo+6iUDIsnuSrCwaPo/q51HgG374DoHQEFzOHQzRLv5SSxlfe6adc3kgUeracY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598022967; 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=T+bBNu2qin9Pn0bZ8c2xBOKhApurAu+0ILblswXDVY4=; b=cVYUy/tSyiTBDLozsFO7JI/TJCEQhmsqFq7qLqhJ/INJk2J5jgWYi8KUtI2fWPgWIMeFZ/inmwCD8vWg89DFK830n1gTREsKPVBqqdRaQjMY1oBKYymASUP1ThY/yP/KvRvbwHFtXp1VEnz9B9DFLpDgNyESXybh3hCQiUF6Sbo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1598022967475233.92897169339813; Fri, 21 Aug 2020 08:16:07 -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-177-D7n3nmfqPxuITBnIJ7gXDw-1; Fri, 21 Aug 2020 11:15:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B703A805EE8; Fri, 21 Aug 2020 15:15:05 +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 97455600DD; Fri, 21 Aug 2020 15:15:05 +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 7E410662B7; Fri, 21 Aug 2020 15:15:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07LFCEaI011879 for ; Fri, 21 Aug 2020 11:12:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F40A5DA74; Fri, 21 Aug 2020 15:12:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1E8A5D9CC for ; Fri, 21 Aug 2020 15:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598022966; 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=T+bBNu2qin9Pn0bZ8c2xBOKhApurAu+0ILblswXDVY4=; b=iOFrBSGteUQ3zbMoXz3vv+tzZZyy7XuT/gWdWuGDMPNsmgY/mZxDd4XtaJIJfsKlAZQqU4 HXNRE++7i2I8p1X1BOd0QK1z12wbr7SmO8G6DC1hr+2/R8WupLFk3CVf3PHfY3yuQbZkTL T+zwbZyVgQbnjd0E0PAmkWGoH14j+qY= X-MC-Unique: D7n3nmfqPxuITBnIJ7gXDw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virnuma: Don't work around numa_node_to_cpus() for non-existent nodes Date: Fri, 21 Aug 2020 17:12:08 +0200 Message-Id: <7b5d774cdf5d0b047bb08813c70415e05d5d533d.1598022728.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In a very distant past, we came around machines that has not continuous node IDs. This made us error out when constructing capabilities XML. We resolved it by utilizing strange behaviour of numa_node_to_cpus() in which it returned a mask with all bits set for a non-existent node. However, this is not the only case when it returns all ones mask - if the node exists and has enough CPUs to fill the mask up (e.g. 128 CPUs). The fix consists of using nodemask_isset(&numa_all_nodes, ..) prior to calling numa_node_to_cpus() to determine if the node exists. Fixes: 628c93574758abb59e71160042524d321a33543f Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1860231 Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virnuma.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/util/virnuma.c b/src/util/virnuma.c index eeca438f25..75d5628cff 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -256,31 +256,23 @@ virNumaGetNodeCPUs(int node, int mask_n_bytes =3D max_n_cpus / 8; size_t i; g_autofree unsigned long *mask =3D NULL; - g_autofree unsigned long *allonesmask =3D NULL; g_autoptr(virBitmap) cpumap =3D NULL; =20 *cpus =3D NULL; =20 + if (!nodemask_isset(&numa_all_nodes, node)) { + VIR_DEBUG("NUMA topology for cell %d is not available, ignoring", = node); + return -2; + } + if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0) return -1; =20 - if (VIR_ALLOC_N(allonesmask, mask_n_bytes / sizeof(*mask)) < 0) - return -1; - - memset(allonesmask, 0xff, mask_n_bytes); - - /* The first time this returns -1, ENOENT if node doesn't exist... */ if (numa_node_to_cpus(node, mask, mask_n_bytes) < 0) { VIR_WARN("NUMA topology for cell %d is not available, ignoring", n= ode); return -2; } =20 - /* second, third... times it returns an all-1's mask */ - if (memcmp(mask, allonesmask, mask_n_bytes) =3D=3D 0) { - VIR_DEBUG("NUMA topology for cell %d is invalid, ignoring", node); - return -2; - } - if (!(cpumap =3D virBitmapNew(max_n_cpus))) return -1; =20 --=20 2.26.2