[PATCH 1/2] eal: fix failure race and behavior of thread create

Thomas Monjalon thomas at monjalon.net
Thu Mar 9 10:58:06 CET 2023


09/03/2023 10:17, David Marchand:
> On Tue, Mar 7, 2023 at 3:33 PM David Marchand <david.marchand at redhat.com> wrote:
> > On Thu, Mar 2, 2023 at 7:44 PM Tyler Retzlaff
> > <roretzla at linux.microsoft.com> wrote:
> > >
> > > In rte_thread_create setting affinity after pthread_create may fail.
> > > Such a failure should result in the entire rte_thread_create failing
> > > but doesn't.
> > >
> > > Additionally if there is a failure to set affinity a race exists where
> > > the creating thread will free ctx and depending on scheduling of the new
> > > thread it may also free ctx (double free).
> > >
> > > Resolve both of the above issues by using the pthread_setaffinity_np
> > > prior to thread creation to set the affinity of the created thread. By
> > > doing this no failure paths exist after pthread_create returns
> > > successfully.
> > >
> > > Fixes: ce6e911d20f6 ("eal: add thread lifetime API")
> > > Cc: stable at dpdk.org
> > > Cc: roretzla at linux.microsoft.com
> > >
> > > Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> > Reviewed-by: David Marchand <david.marchand at redhat.com>
> 
> Series applied, thanks.

Unfortunately we cannot merge this patch
because it does not compile on Alpine Linux (musl libc):

lib/eal/unix/rte_thread.c:160:31: error:
implicit declaration of function 'pthread_attr_setaffinity_np'

Is it possible to fix the race without using pthread_attr_setaffinity_np?




More information about the stable mailing list