From: Tal Shnaiderman <talshn@nvidia.com>
To: Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
"dev@dpdk.org" <dev@dpdk.org>,
NBU-Contact-Thomas Monjalon <thomas@monjalon.net>,
"dmitry.kozliuk@gmail.com" <dmitry.kozliuk@gmail.com>,
Khoa To <khot@microsoft.com>,
"navasile@microsoft.com" <navasile@microsoft.com>,
"dmitrym@microsoft.com" <dmitrym@microsoft.com>,
"roretzla@microsoft.com" <roretzla@microsoft.com>,
"ocardona@microsoft.com" <ocardona@microsoft.com>
Cc: "bruce.richardson@intel.com" <bruce.richardson@intel.com>,
"david.marchand@redhat.com" <david.marchand@redhat.com>,
"pallavi.kadam@intel.com" <pallavi.kadam@intel.com>
Subject: Re: [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name
Date: Wed, 18 Aug 2021 19:42:48 +0000 [thread overview]
Message-ID: <DM4PR12MB538904EF1E373F60934707DEA4FF9@DM4PR12MB5389.namprd12.prod.outlook.com> (raw)
In-Reply-To: <1629294247-5207-2-git-send-email-navasile@linux.microsoft.com>
> Subject: [PATCH v3 1/6] eal: add function that sets thread name
>
> External email: Use caution opening links or attachments
>
>
> From: Narcisa Vasile <navasile@microsoft.com>
>
> Implement function that sets the name of a thread.
> On Windows, SetThreadDescription() is used. Use GetProcAddress() to obtain
> the address of the function for MinGW compatibility.
>
> Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
> ---
> lib/eal/common/rte_thread.c | 17 +++++++++ lib/eal/include/rte_thread.h |
> 16 +++++++++
> lib/eal/version.map | 1 +
> lib/eal/windows/rte_thread.c | 68
> ++++++++++++++++++++++++++++++++++++
> 4 files changed, 102 insertions(+)
<snip>
> +RTE_INIT(rte_thread_description_ptr_init)
> +{
> + HMODULE kernel_lib = NULL;
> + static const char library_name[] = "kernel32.dll";
> + static const char function[] = "SetThreadDescription";
> +
> + kernel_lib = LoadLibraryA(library_name);
> + if (kernel_lib == NULL) {
> + (void)thread_log_last_error("LoadLibraryA(\"kernel32.dll\")");
> + return;
> + }
> +
> + SetThreadDescription_ptr = (SetThreadDescription_type)(
> + (void *)GetProcAddress(kernel_lib, function));
> + if (SetThreadDescription_ptr == NULL) {
> + (void)thread_log_last_error("GetProcAddress(\"kernel32.dll\",
> \"SetThreadDescription\")");
> + return;
You need to remove the return above to also free kernel32.dll in error flow.
> + }
> +
> + FreeLibrary(kernel_lib);
> +}
> +
> +int
> +rte_thread_name_set(rte_thread_t thread_id, const char *name) {
> + int ret = 0;
> + size_t count;
> + HRESULT hr;
> + HANDLE thread_handle = NULL;
> + WCHAR w_name[16];
> +
> + thread_handle = OpenThread(THREAD_SET_LIMITED_INFORMATION,
> FALSE,
> + thread_id.opaque_id);
> + if (thread_handle == NULL) {
> + ret = thread_log_last_error("OpenThread()");
> + goto cleanup;
> + }
> +
> + count = mbstowcs(w_name, name, RTE_DIM(w_name));
> + if (count == (size_t) (-1)) {
> + RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
> + ret = EINVAL;
> + goto cleanup;
> + }
> +
> + if (SetThreadDescription_ptr == NULL) {
> + RTE_LOG(DEBUG, EAL, "Invalid function pointer to
> SetThreadDescription()!\n");
> + ret = EINVAL;
> + goto cleanup;
> + }
> +
> + hr = SetThreadDescription_ptr(thread_handle, w_name);
> + if (FAILED(hr)) {
> + ret = thread_log_last_error("SetThreadDescription()");
> + goto cleanup;
> + }
> +
> +cleanup:
> + if (thread_handle != NULL)
> + CloseHandle(thread_handle);
> + return ret;
> +}
> +
> int
> rte_thread_key_create(rte_thread_key *key,
> __rte_unused void (*destructor)(void *))
> --
> 2.31.0.vfs.0.1
next prev parent reply other threads:[~2021-08-18 19:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 21:54 [dpdk-dev] [PATCH 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-06-18 21:54 ` [dpdk-dev] [PATCH 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-06-20 23:53 ` Dmitry Kozlyuk
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-06-19 1:57 ` [dpdk-dev] [PATCH v2 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-08-18 19:42 ` Tal Shnaiderman [this message]
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-08-18 13:44 ` [dpdk-dev] [PATCH v3 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 0/6] Enable the internal EAL thread API Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 1/6] eal: add function that sets thread name Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 2/6] eal: add function for control thread creation Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 3/6] Enable the new EAL thread API in app, drivers and examples Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 4/6] lib: enable the new EAL thread API Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 5/6] eal: set affinity and priority attributes Narcisa Ana Maria Vasile
2021-08-18 21:19 ` [dpdk-dev] [PATCH v4 6/6] Allow choice between internal EAL thread API and external lib Narcisa Ana Maria Vasile
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=DM4PR12MB538904EF1E373F60934707DEA4FF9@DM4PR12MB5389.namprd12.prod.outlook.com \
--to=talshn@nvidia.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=dmitrym@microsoft.com \
--cc=khot@microsoft.com \
--cc=navasile@linux.microsoft.com \
--cc=navasile@microsoft.com \
--cc=ocardona@microsoft.com \
--cc=pallavi.kadam@intel.com \
--cc=roretzla@microsoft.com \
--cc=thomas@monjalon.net \
/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).