From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D8FFA0093; Mon, 15 Jun 2020 10:16:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ED2542B87; Mon, 15 Jun 2020 10:16:19 +0200 (CEST) Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by dpdk.org (Postfix) with ESMTP id 773451150 for ; Mon, 15 Jun 2020 10:16:18 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id E7F8B580159; Mon, 15 Jun 2020 04:16:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 15 Jun 2020 04:16:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm1; bh= RBToYdPR9IxPehqqbHqow1AyamdhV80u8bblSPrsKak=; b=PlpFa8Usc++qbcnv shIJetCUo0ZZuiD6QHixb6iR0dusPQGNZe1Uwu6I85v8ZgoLLXh/s6dfG474Geea 3kkvT+K912Svu0nMnvLCfGbx9ViQYcKj1pWCQ34dTnVjN/2o7jJeqejjQEFCH1ca /8Yva0SfZPXd0Y+1abbKQnqHQrin61vRCR6witBAONANzTgAXwhzOmtAgeTGaT2r Xk1TmSGn7ykYxv62xLCTjQ2KZA9Ul35rv/BMGx7OOOJOr0D23IfhurICP1CRBM6X WQqVRlwSn0cP6UZNrqBIkT14Y6waEwa/kkBin0NJIO7yIgZh/4x4MjT6lS8o2bV9 rBa+Kg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=RBToYdPR9IxPehqqbHqow1AyamdhV80u8bblSPrsK ak=; b=eLF9V3Y/OFTrg61EgIo1f5iqmNqfNfsy9LWWC9mGzdLQsFwvQRToHWM5v t6vcGCrrxEsEjhX2X6fSLcrtHW2y030rubtFKu2FtmrX45zrEEsZAyKNpLhi0imx xU18LG3YMQ9z/ATFuLtWfW8IrF+bE66Cdau5+vRdlyCphc6ytba0K4NeLF+oynVP 3flTxiKPyTE+chSoG5y0Ip9n8i1KBjcZMWEOYDpOG0Kw7/J/dv6JXUIbGJgojDie KsoU3fF4gmW1+wK1wiEDLElP0BRGN5n4VY2gjmSX/WIlrbmybLXQBRIcDfpKz+2Z 4kbAH7srhpGoQU0cMf47zYvCjWIPg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeikedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 0733E3061856; Mon, 15 Jun 2020 04:16:15 -0400 (EDT) From: Thomas Monjalon To: Tasnim Bashar Cc: dev@dpdk.org, harini.ramakrishnan@microsoft.com, pallavi.kadam@intel.com, ranjit.menon@intel.com, ocardona@microsoft.com, navasile@linux.microsoft.com, dmitry.kozliuk@gmail.com, talshn@mellanox.com, fady@mellanox.com, ophirmu@mellanox.com Date: Mon, 15 Jun 2020 10:16:14 +0200 Message-ID: <1716943.Gv3JEJsLzV@thomas> In-Reply-To: <20200602020052.4540-1-tbashar@mellanox.com> References: <20200522001112.48932-1-tbashar@mellanox.com> <20200602020052.4540-1-tbashar@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v3] eal/windows: fix invalid thread handle 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 02/06/2020 04:00, Tasnim Bashar: > Casting thread ID to handle is not accurate way to get thread handle. > Need to use OpenThread function to get thread handle from thread ID. > > pthread_setaffinity_np and pthread_getaffinity_np functions > for Windows are affected because of it. > > Signed-off-by: Tasnim Bashar > --- > v3: WA to remove warning(-Wmaybe-uninitialized) The -Wmaybe-uninitialized warning was there before this patch. Shouldn't it be a separate patch before this one? > static inline int > -eal_get_thread_affinity_mask(pthread_t threadid, unsigned long *cpuset) > +eal_get_thread_affinity_mask(pthread_t threadid, rte_cpuset_t *cpuset) > { > /* Workaround for the lack of a GetThreadAffinityMask() > *API in Windows > */ > - /* obtain previous mask by setting dummy mask */ > - DWORD dwprevaffinitymask = > - SetThreadAffinityMask((HANDLE) threadid, 0x1); > + DWORD_PTR dwprevaffinitymask; Please use underscores to separate parts in names. > + HANDLE thread_handle; > + DWORD_PTR ret; > + > + thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid); > + if (thread_handle == NULL) { > + RTE_LOG_WIN32_ERR("OpenThread()"); > + return -1; > + } > + > + /* obtain previous mask by setting dummy mask */ > + dwprevaffinitymask = SetThreadAffinityMask(thread_handle, 0x1); > + if (dwprevaffinitymask == 0) { > + RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); > + CloseHandle(thread_handle); > + return -1; > + } > + > /* set it back! */ > - SetThreadAffinityMask((HANDLE) threadid, dwprevaffinitymask); > - *cpuset = dwprevaffinitymask; > + ret = SetThreadAffinityMask(thread_handle, dwprevaffinitymask); > + if (ret == 0) { > + RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); > + CloseHandle(thread_handle); > + return -1; > + } > + memset(cpuset, 0, sizeof(rte_cpuset_t)); Shouldn't we use RTE_CPU_ZERO instead of memset? > + *cpuset->_bits = dwprevaffinitymask; > + CloseHandle(thread_handle); > return 0; > }