From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: David Marchand <david.marchand@redhat.com>
Cc: dev@dpdk.org, thomas@monjalon.net,
Bruce Richardson <bruce.richardson@intel.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
Dmitry Malloy <dmitrym@microsoft.com>,
Pallavi Kadam <pallavi.kadam@intel.com>
Subject: Re: [PATCH] eal: factorize lcore main loop
Date: Thu, 24 Mar 2022 01:31:07 -0700 [thread overview]
Message-ID: <20220324083107.GA28494@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <20220323093001.20618-1-david.marchand@redhat.com>
On Wed, Mar 23, 2022 at 10:30:01AM +0100, David Marchand wrote:
> All OS implementations provide the same main loop.
> Introduce helpers (shared for Linux and FreeBSD) to handle synchronisation
> between main and threads and factorize the rest as common code.
> Thread id are now logged as string in a common format across OS.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> I had this patch in store for a long time.
> I don't particularly care about it, it's not fixing anything.
> But it seems a good cleanup/consolidation, so I rebased it and I am
> sending it to get feedback.
>
... snip ...
> diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
> index 684bea166c..256de91abc 100644
> --- a/lib/eal/common/eal_common_thread.c
> +++ b/lib/eal/common/eal_common_thread.c
> @@ -9,6 +9,7 @@
> #include <assert.h>
> #include <string.h>
>
> +#include <rte_eal_trace.h>
> #include <rte_errno.h>
> #include <rte_lcore.h>
> #include <rte_log.h>
> @@ -163,6 +164,77 @@ __rte_thread_uninit(void)
> RTE_PER_LCORE(_lcore_id) = LCORE_ID_ANY;
> }
>
> +/* main loop of threads */
> +__rte_noreturn void *
> +eal_thread_loop(__rte_unused void *arg)
> +{
> + char cpuset[RTE_CPU_AFFINITY_STR_LEN];
> + pthread_t thread_id = pthread_self();
> + unsigned int lcore_id;
> + int ret;
> +
> + /* retrieve our lcore_id from the configuration structure */
> + RTE_LCORE_FOREACH_WORKER(lcore_id) {
> + if (thread_id == lcore_config[lcore_id].thread_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
i can see that in practice this isn't a problem since the linux
implementation of pthread_create(3) stores to pthread_t *thread before
executing start_routine.
but strictly speaking i don't think the pthread_create api contractually
guarantees that the thread id is stored before start_routine runs. so this
is relying on an internal implementation detail.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_create.html
"Upon successful completion, pthread_create() shall store the ID of the
created thread in the location referenced by thread."
https://man7.org/linux/man-pages/man3/pthread_create.3.html
"Before returning, a successful call to pthread_create() stores
the ID of the new thread in the buffer pointed to by thread; this
identifier is used to refer to the thread in subsequent calls to
other pthreads functions."
it doesn't really say when it does this in relation to start_routine running.
depends how hair splitty you want to be about it. but since you're revamping
the code you might be interested in addressing it.
ty
next prev parent reply other threads:[~2022-03-24 8:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-23 9:30 David Marchand
2022-03-23 12:01 ` Morten Brørup
2022-03-24 8:31 ` Tyler Retzlaff [this message]
2022-03-24 14:44 ` David Marchand
2022-03-25 12:11 ` Tyler Retzlaff
2022-03-25 14:58 ` Thomas Monjalon
2022-03-25 15:09 ` David Marchand
2022-03-25 16:38 ` Tyler Retzlaff
2022-03-25 12:23 ` Tyler Retzlaff
2022-04-01 8:44 ` [PATCH v2 1/2] eal: cleanup lcore ID hand-over David Marchand
2022-04-01 8:44 ` [PATCH v2 2/2] eal: factorize lcore main loop David Marchand
2022-04-05 7:05 ` David Marchand
2022-04-05 16:34 ` [PATCH v3 1/2] eal: cleanup lcore ID hand-over David Marchand
2022-04-05 16:34 ` [PATCH v3 2/2] eal: factorize lcore main loop David Marchand
2022-04-14 11:48 ` David Marchand
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=20220324083107.GA28494@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
--to=roretzla@linux.microsoft.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=navasile@linux.microsoft.com \
--cc=pallavi.kadam@intel.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).