DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Tasnim Bashar <tbashar@mellanox.com>
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
Subject: Re: [dpdk-dev] [PATCH v3] eal/windows: fix invalid thread handle
Date: Mon, 15 Jun 2020 10:16:14 +0200	[thread overview]
Message-ID: <1716943.Gv3JEJsLzV@thomas> (raw)
In-Reply-To: <20200602020052.4540-1-tbashar@mellanox.com>

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 <tbashar@mellanox.com>
> ---
> 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;
>  }




  parent reply	other threads:[~2020-06-15  8:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  0:11 [dpdk-dev] [PATCH] " Tasnim Bashar
2020-05-22  0:55 ` Dmitry Kozlyuk
2020-06-02  2:00 ` [dpdk-dev] [PATCH v3] " Tasnim Bashar
2020-06-11 14:35   ` Thomas Monjalon
2020-06-12 16:22     ` Tasnim Bashar
2020-06-12 21:33       ` Thomas Monjalon
2020-06-15  8:16   ` Thomas Monjalon [this message]
2020-06-16 18:53     ` Tasnim Bashar
2020-06-16 19:17       ` Thomas Monjalon
2020-06-16 19:59         ` Tasnim Bashar
2020-06-15  9:42   ` Thomas Monjalon
2020-06-16 19:00     ` Tasnim Bashar
2020-06-24 23:10   ` [dpdk-dev] [PATCH v4] eal/windows: fix " Tasnim Bashar
2020-06-25  0:38     ` Ranjit Menon
2020-06-25 19:11       ` Tasnim Bashar
2020-06-25 19:25     ` [dpdk-dev] [PATCH v5] " Tasnim Bashar
2020-06-29 23:09       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1716943.Gv3JEJsLzV@thomas \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=fady@mellanox.com \
    --cc=harini.ramakrishnan@microsoft.com \
    --cc=navasile@linux.microsoft.com \
    --cc=ocardona@microsoft.com \
    --cc=ophirmu@mellanox.com \
    --cc=pallavi.kadam@intel.com \
    --cc=ranjit.menon@intel.com \
    --cc=talshn@mellanox.com \
    --cc=tbashar@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).