From patchwork Wed Jun 30 01:56:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Narcisa Ana Maria Vasile X-Patchwork-Id: 95019 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36880A0A0F; Wed, 30 Jun 2021 03:56:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F56140E01; Wed, 30 Jun 2021 03:56:18 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 314E040DF6; Wed, 30 Jun 2021 03:56:17 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1059) id 8256F20B7178; Tue, 29 Jun 2021 18:56:16 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8256F20B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1625018176; bh=yLqKPAcrON1gKEbUiaK9qVOzvVaNV2BdOfxFz8NzLQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOgDVhUdP7V4YwLlSUXn2q7l1eNXrEY9T0YIbhOqczEBgHJ6EiOOIp8aBZT6YOgBv mee7YeDvAvOPZ/JbFAHbG4GpTLXDPcKXzcoHWqcJKCjwYOen+zikS82IPA4hM0BT8P t3ZgKMf5RTk3Fh64cdVfeTmZC39YAGZIVZs3BLig= From: Narcisa Ana Maria Vasile To: dev@dpdk.org, thomas@monjalon.net, dmitry.kozliuk@gmail.com, ocardona@microsoft.com, pallavi.kadam@intel.com, talshn@nvidia.com, dmitrym@microsoft.com Cc: Narcisa Vasile , stable@dpdk.org Date: Tue, 29 Jun 2021 18:56:05 -0700 Message-Id: <1625018165-27103-1-git-send-email-navasile@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1624580843-4521-1-git-send-email-navasile@linux.microsoft.com> References: <1624580843-4521-1-git-send-email-navasile@linux.microsoft.com> Subject: [dpdk-dev] [PATCH v2] eal/windows: ensure all enabled CPUs are counted X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Narcisa Vasile rte_cpuset_t describes a set of CPUs by using an array of masks named '_bits'. Each element in the '_bits' array represents a bit mask, with each bit corresponding to a CPU. The maximum number of CPUs is given by 'CPU_SETSIZE'. The number of bit masks is computed using '_NUM_SETS(CPU_SETSIZE)'. count_cpu() should count the number of CPUs enabled in the set 's'. Currently, it iterates through the number of masks in the set 's', instead of iterating through all the bits in all the masks. For example, if '_NUM_SETS(CPU_SETSIZE)' returns 2, which means there are 2 bit masks: _bits[0] and _bits[1], count_cpu() would only check if CPUs '0' and '1' are enabled. The correct behavior is to iterate through all the CPUs in the set and count the ones that are enabled. This patch fixes count_cpu() to ensure all the bits in all the masks are checked to compute the correct number of CPUs enabled in 's'. Fixes: e8428a9d89f1 ("eal/windows: add some basic functions and macros") Cc: pallavi.kadam@intel.com Cc: stable@dpdk.org Signed-off-by: Narcisa Vasile Acked-by: Dmitry Kozlyuk Acked-by: Pallavi Kadam --- v2: * Fix commit message. lib/eal/windows/include/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/eal/windows/include/sched.h b/lib/eal/windows/include/sched.h index ff572b5dcb..bc31cc8465 100644 --- a/lib/eal/windows/include/sched.h +++ b/lib/eal/windows/include/sched.h @@ -49,7 +49,7 @@ count_cpu(rte_cpuset_t *s) unsigned int _i; int count = 0; - for (_i = 0; _i < _NUM_SETS(CPU_SETSIZE); _i++) + for (_i = 0; _i < CPU_SETSIZE; _i++) if (CPU_ISSET(_i, s) != 0LL) count++; return count;