All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Tal Shnaiderman <talshn@nvidia.com>
Cc: dev@dpdk.org, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com,
	navasile@linux.microsoft.com, dmitrym@microsoft.com,
	david.marchand@redhat.com
Subject: Re: [dpdk-dev] [PATCH v6] eal: add generic thread-local-storage functions
Date: Tue, 05 Jan 2021 12:53:43 +0100	[thread overview]
Message-ID: <2119244.Rpp8axq6Fq@thomas> (raw)
In-Reply-To: <20201230111244.13832-1-talshn@nvidia.com>

30/12/2020 12:12, Tal Shnaiderman:
> Add support for tls functionality in EAL.

You should write TLS uppercase here and below.

There is already a TLS capability in rte_per_lcore.h,
using __thread keyword.
Note: I think the historical wording "lcore" is confusing.
We talk about lcore, assuming the thread is bound to its lcore.

Please explain in the patch why the more complex TLS functions
are required, i.e. can __thread variable be used in Windows?
limitation, etc.

> The following functions are added:
> rte_thread_tls_create_key - function to create a tls data key.
> rte_thread_tls_delete_key - function to delete a tls data key.
> rte_thread_tls_set_value - function to set value bound to the tls key
> rte_thread_tls_get_value - function to get value bound to the tls key

We can assume the TLS key logic is known,
but this patch is the right place to explain it.

> tls key will be defined by the new type rte_tls_key
> 
> Windows implementation is under librte_eal/windows and
> implemented using WIN32 API for Windows only.
> 
> common implementation is under librte_eal/common and
> implemented using pthread for UNIX and Windows compilation
> using extenral pthread libraries, when supported.

typo: external

[...]
> v3: switch from pthread shim to generic eal implementation [DmitryK]
> v4: modify file names, function names, move unix code to common
> for future external pthreads support [DmitryK]

For now, there is no external pthread library.
It did not have been discussed generally in the techboard.
As it is using the Unix pthread API, it sounds more logical
to have this implementation in the Unix sub-directory I think.

> --- a/lib/librte_eal/common/meson.build
> +++ b/lib/librte_eal/common/meson.build
> +	'rte_thread.c',
[...]
> --- a/lib/librte_eal/include/meson.build
> +++ b/lib/librte_eal/include/meson.build
> +	'rte_thread.h',

There are existing functions in rte_lcore.h and rte_per_lcore.h
which are managing threads.
I think a prior patch should move such functions in rte_thread files.
At least we can start moving the affinity functions,
which are not using pthread types as parameters.

> --- /dev/null
> +++ b/lib/librte_eal/include/rte_thread.h
> @@ -0,0 +1,88 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2020 Mellanox Technologies, Ltd
> + */
> +
> +#include <rte_compat.h>

Why do you need rte_compat?

> +/**
> + * Function to create a TLS data key visible to all threads in the process
> + * function need to be called once to create a key usable by all threads.
> + * rte_tls_key is an opaque pointer used to store the allocated key.
> + * and optional destructor can be set to be called when a thread expires.

You may explain that the key is later used to get/set a value.

> + *
> + * @param key
> + *   Pointer to store the allocated rte_tls_key
> + * @param destructor
> + *   The function to be called when the thread expires.
> + *   Not supported on Windows OS.

What happens when specifying a destructor on Windows?

> + *
> + * @return
> + *   On success, zero.
> + *   On failure, a negative number.
> + */
> +__rte_experimental
> +int
> +rte_thread_tls_create_key(rte_tls_key *key, void (*destructor)(void *));

For .h files, we have the return type on the same line (I know it is stupid).

I would suggest moving the verb "create" at the end of the function names.

[...]
> +rte_thread_tls_delete_key(rte_tls_key key);

Could be rte_thread_tls_key_delete?

[...]
> +rte_thread_tls_set_value(rte_tls_key key, const void *value);

rte_thread_tls_value_set?

> +rte_thread_tls_get_value(rte_tls_key key);

rte_thread_tls_value_get?




  parent reply	other threads:[~2021-01-05 11:53 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-13 20:24 [dpdk-dev] [PATCH v2] eal/windows: add pthread TLS function support Tal Shnaiderman
2020-12-15 22:36 ` Dmitry Kozlyuk
2020-12-17 17:49 ` [dpdk-dev] [PATCH v3] eal: add generic thread-local-storage functions Tal Shnaiderman
2020-12-17 20:56   ` Dmitry Kozlyuk
2020-12-18 19:37     ` Tal Shnaiderman
2020-12-22  7:30   ` [dpdk-dev] [PATCH v4] " Tal Shnaiderman
2020-12-23  1:18     ` Dmitry Kozlyuk
2020-12-23 11:44       ` Tal Shnaiderman
2020-12-23 11:58         ` Dmitry Kozlyuk
2020-12-23 18:16           ` [dpdk-dev] [EXTERNAL] " Dmitry Malloy (MESHCHANINOV)
2020-12-26 16:08     ` [dpdk-dev] [PATCH v5] " Tal Shnaiderman
2020-12-29 23:13       ` Dmitry Kozlyuk
2020-12-30 10:04         ` Tal Shnaiderman
2020-12-30 11:12       ` [dpdk-dev] [PATCH v6] " Tal Shnaiderman
2021-01-01 22:16         ` Dmitry Kozlyuk
2021-01-05 11:53         ` Thomas Monjalon [this message]
2021-01-05 17:06       ` [dpdk-dev] [PATCH v7 0/2] support generic threading functions Tal Shnaiderman
2021-01-05 17:06         ` [dpdk-dev] [PATCH v7 1/2] eal: move thread affinity functions to new file Tal Shnaiderman
2021-01-06 14:40           ` Dmitry Kozlyuk
2021-01-06 19:45           ` [dpdk-dev] [PATCH v8 0/2] support generic threading functions Tal Shnaiderman
2021-01-06 19:45             ` [dpdk-dev] [PATCH v8 1/2] eal: move thread affinity functions to new file Tal Shnaiderman
2021-01-06 19:45             ` [dpdk-dev] [PATCH v8 2/2] eal: add generic thread-local-storage functions Tal Shnaiderman
2021-01-06 20:10               ` Dmitry Kozlyuk
2021-01-06 20:33                 ` Tal Shnaiderman
2021-01-06 20:35             ` [dpdk-dev] [PATCH v9 0/2] support generic threading functions Tal Shnaiderman
2021-01-06 20:35               ` [dpdk-dev] [PATCH v9 1/2] eal: move thread affinity functions to new file Tal Shnaiderman
2021-01-06 20:35               ` [dpdk-dev] [PATCH v9 2/2] eal: add generic thread-local-storage functions Tal Shnaiderman
2021-01-07 14:46                 ` Dmitry Kozlyuk
2021-02-10 13:33                 ` Burakov, Anatoly
2021-02-10 14:26                   ` Medvedkin, Vladimir
2021-02-11  7:34                     ` Tal Shnaiderman
2021-02-11  7:26                   ` Tal Shnaiderman
2021-01-11 22:33               ` [dpdk-dev] [PATCH v9 0/2] support generic threading functions Thomas Monjalon
2021-01-05 17:06         ` [dpdk-dev] [PATCH v7 2/2] eal: add generic thread-local-storage functions Tal Shnaiderman
2021-01-06 15:05           ` Dmitry Kozlyuk
2021-01-06 16:04             ` Tal Shnaiderman

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=2119244.Rpp8axq6Fq@thomas \
    --to=thomas@monjalon.net \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dmitrym@microsoft.com \
    --cc=navasile@linux.microsoft.com \
    --cc=pallavi.kadam@intel.com \
    --cc=talshn@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.