From nobody Sat Feb 7 09:58:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1591034022; cv=none; d=zohomail.com; s=zohoarc; b=Fzh4818WN60+VQMlnucm2jDItOhHafFcHgdaRPsYXLVB0+2GVW54mOEPOLQrUPd9D4UUV+fCMzYEkpxKxn+0PCJoaXIgwtf0fegr1YsRklqPVVdsd731Mrztb8UDqHQDm/7wVaaUxfQ17XrOoW4o7HFZG31mz4DBmTIti68ah3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591034022; 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=n6JD0ayJnyPAxchQ040iyseMmBUNa6IblKupc6M8+Ag=; b=gt4hNQqNuW6hKaOMkDTM7/cijPKvuThxKkbPWBbja78NXtDVzbyeabLCz+Acm3yDCvbDs/n0G8XHXd65SZH7t5G+vyRFzoFrm993a0uRkT+0mF9sFuaPupovoE+9XkGY+kmvXAteRvaJsEL9qR9R9Sy73SU8k69XEzz1lRdxn0Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1591034022075307.5762004644632; Mon, 1 Jun 2020 10:53:42 -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-19-H0Hg7iIRP6u8ZSyEeRanAw-1; Mon, 01 Jun 2020 13:53:37 -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 9F7868018A5; Mon, 1 Jun 2020 17:53:32 +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 801365D9DD; Mon, 1 Jun 2020 17:53:32 +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 2B7A61809543; Mon, 1 Jun 2020 17:53:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 051Hp1kV009394 for ; Mon, 1 Jun 2020 13:51:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 950732156A49; Mon, 1 Jun 2020 17:51:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86A092156A3A for ; Mon, 1 Jun 2020 17:51:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC23F1859164 for ; Mon, 1 Jun 2020 17:51:00 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-5nqT0GG6NLqjXksZ_qKSbw-1; Mon, 01 Jun 2020 13:50:53 -0400 Received: by mail-qt1-f195.google.com with SMTP id y1so8362601qtv.12; Mon, 01 Jun 2020 10:50:53 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9da7:da03:b92e:aafb:831c]) by smtp.gmail.com with ESMTPSA id h22sm9519021qtk.63.2020.06.01.10.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591034020; 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=n6JD0ayJnyPAxchQ040iyseMmBUNa6IblKupc6M8+Ag=; b=U2NJUrLV15q6gMpx32G++6KlL9AWJeAH1BAoomwgpE/Q4IlFuz2hbrKw8dcVOZ0siDuB2P zQS6AlmPzMCxmEoHY8HrBzUgLUIdxPpzCrSSygVDqYVcGEsy4q6PkyYAUmOkvF1G4qNe8Z pLfMPGWCufvesPb7MWqB7mm2vDDShEw= X-MC-Unique: H0Hg7iIRP6u8ZSyEeRanAw-1 X-MC-Unique: 5nqT0GG6NLqjXksZ_qKSbw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n6JD0ayJnyPAxchQ040iyseMmBUNa6IblKupc6M8+Ag=; b=OmoimclwP6BjfCnlpC+jGMO8yH0jmFlbFLvoagbEenY9ytzrwU+ld7zx4LW0dPkhcm OBlyRkww70KvqK3Aqetx41uoJuKxhqZK7gU2i/Z15zoqTUA3o/dVogKqNtr6ql5CC3Ze x4UO8RZ0bRXRVPZuIA/9ynrVys2NR1RjtuQpms6zdCdUyeOfMsjxxTF1jqp0HpVQOJGq 0xdQJo0wbiHP98cfSANxeWBgw0vO09/73RRm0rCE66DRfNab3HxN67bmceCP0u145ntI aocgk4n4I8vVgE0kD7WSxTx1iqlhB/bngiJOn26nB/QcU790l1OYmWg7gcNGYI7Dk9KZ tClw== X-Gm-Message-State: AOAM533p123M7D14/HJNyInlzrWVhPiSgwKLgxERgSufMiZYJFY8qGn3 xR8orLzrZSmwx0FOYAJYNTmGQUzlKA0= X-Google-Smtp-Source: ABdhPJxP26ohHo1F82C1UNWZ+YvyMxxHT2yJdysuGHwiqkByq4uBkOCd7F9C/L4CXpUnzgqYQ9w57Q== X-Received: by 2002:ac8:4b58:: with SMTP id e24mr23346942qts.278.1591033852430; Mon, 01 Jun 2020 10:50:52 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 1/5] numa_conf.c: add helper functions for cpumap operations Date: Mon, 1 Jun 2020 14:50:37 -0300 Message-Id: <20200601175041.1607723-2-danielhb413@gmail.com> In-Reply-To: <20200601175041.1607723-1-danielhb413@gmail.com> References: <20200601175041.1607723-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , pkrempa@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 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" These helpers will be used in an auto-fill feature for incomplete NUMA topologies in the next patch. Signed-off-by: Daniel Henrique Barboza --- src/conf/numa_conf.c | 46 ++++++++++++++++++++++++++++++++++++++++ src/conf/numa_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 50 insertions(+) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 6f1257fd8e..3d766189ba 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1373,3 +1373,49 @@ virDomainNumaGetMemorySize(virDomainNumaPtr numa) =20 return ret; } + + +static int +virDomainNumaRemoveCPUsFromMap(virBitmapPtr result, virBitmapPtr exclude) +{ + size_t i; + + for (i =3D 0; i < virBitmapSize(exclude); i++) { + if (!virBitmapIsBitSet(exclude, i)) + continue; + + if (virBitmapClearBitExpand(result, i) < 0) + return -1; + } + + return 0; +} + + +int +virDomainNumaFillCPUsInNode(virDomainNumaPtr numa, size_t node, + unsigned int maxCpus) +{ + g_autoptr(virBitmap) maxCPUsBitmap =3D virBitmapNew(maxCpus); + size_t i; + + if (node >=3D virDomainNumaGetNodeCount(numa)) + return -1; + + virBitmapSetAll(maxCPUsBitmap); + + for (i =3D 0; i < numa->nmem_nodes; i++) { + virBitmapPtr nodeCpus =3D virDomainNumaGetNodeCpumask(numa, i); + + if (i =3D=3D node) + continue; + + if (virDomainNumaRemoveCPUsFromMap(maxCPUsBitmap, nodeCpus) < 0) + return -1; + } + + virBitmapFree(numa->mem_nodes[node].cpumask); + numa->mem_nodes[node].cpumask =3D g_steal_pointer(&maxCPUsBitmap); + + return 0; +} diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index ae3599bb8b..cdf87a87e8 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -185,3 +185,6 @@ int virDomainNumaDefCPUParseXML(virDomainNumaPtr def, x= mlXPathContextPtr ctxt); int virDomainNumaDefCPUFormatXML(virBufferPtr buf, virDomainNumaPtr def); =20 unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa); + +int virDomainNumaFillCPUsInNode(virDomainNumaPtr numa, size_t node, + unsigned int maxCpus); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a6af44fe1c..788e08045a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -834,6 +834,7 @@ virDomainMemoryAccessTypeFromString; virDomainMemoryAccessTypeToString; virDomainNumaCheckABIStability; virDomainNumaEquals; +virDomainNumaFillCPUsInNode; virDomainNumaFree; virDomainNumaGetCPUCountTotal; virDomainNumaGetMaxCPUID; --=20 2.26.2