From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 70018532C; Tue, 19 Feb 2019 21:38:43 +0100 (CET) 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 mx1.redhat.com (Postfix) with ESMTPS id A1E763DFCD; Tue, 19 Feb 2019 20:38:42 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-16.brq.redhat.com [10.40.204.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6062217D5A; Tue, 19 Feb 2019 20:38:41 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: anatoly.burakov@intel.com, stable@dpdk.org Date: Tue, 19 Feb 2019 21:38:13 +0100 Message-Id: <1550608693-12882-1-git-send-email-david.marchand@redhat.com> In-Reply-To: <1550150874-9535-1-git-send-email-david.marchand@redhat.com> References: <1550150874-9535-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 19 Feb 2019 20:38:42 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2] eal: fix check when retrieving current cpu affinity X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2019 20:38:43 -0000 pthread_getaffinity_np returns a >0 value when failing. This is mainly for the sake of correctness. The only case where it could fail is when passing an incorrect cpuset size wrt to the kernel. Fixes: 2eba8d21f3c9 ("eal: restrict cores auto detection") Cc: stable@dpdk.org Signed-off-by: David Marchand --- Changelog since v1: - added missing Cc: stable@dpdk.org --- lib/librte_eal/common/eal_common_options.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 6c96f45..1f45f82 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1343,10 +1343,9 @@ static int xdigit2val(unsigned char c) unsigned int lcore_id; unsigned int removed = 0; rte_cpuset_t affinity_set; - pthread_t tid = pthread_self(); - if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t), - &affinity_set) < 0) + if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t), + &affinity_set)) CPU_ZERO(&affinity_set); for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { -- 1.8.3.1