On Wed, Oct 21, 2026 at 01:20:41PM -0400, Pravin Pathak wrote:
> dlb2 handles dynamic linking and linking asynchronously if queues
> being linked/unlinked have traffic. It starts a thread if not already
> started to handle the process. This change avoids the race condition
> in thread creation where sometimes the thread starts immediately,
> descheduling the calling thread and finishes the job and exits, and then
> caller sets worker launched true when the thread is not running.
> 
> Signed-off-by: Pravin Pathak <[email protected]>
> ---
>  drivers/event/dlb2/pf/base/dlb2_osdep.h | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 

Fix makes sense to me. Note some comment inline below.

Acked-by: Bruce Richardson <[email protected]>


> diff --git a/drivers/event/dlb2/pf/base/dlb2_osdep.h 
> b/drivers/event/dlb2/pf/base/dlb2_osdep.h
> index 382a49090a..1505563f83 100644
> --- a/drivers/event/dlb2/pf/base/dlb2_osdep.h
> +++ b/drivers/event/dlb2/pf/base/dlb2_osdep.h
> @@ -208,14 +208,16 @@ static inline void os_schedule_work(struct dlb2_hw *hw)
>  
>       dlb2_dev = container_of(hw, struct dlb2_dev, hw);
>  
> +     dlb2_dev->worker_launched = true;
> +
>       ret = 
> rte_thread_create_internal_control(&complete_queue_map_unmap_thread,
>                       "dlb-qunmap", dlb2_complete_queue_map_unmap, dlb2_dev);
> -     if (ret)
> +     if (ret) {

DPDK coding style recommends using explicit comparisons for clarity, so
this should really be "if (ret != 0)" or "if (ret < 0)".

>               DLB2_ERR(dlb2_dev,
>                        "Could not create queue complete map/unmap thread, 
> err=%d\n",
>                        ret);
> -     else
> -             dlb2_dev->worker_launched = true;
> +             dlb2_dev->worker_launched = false;
> +     }

I notice that worker_launched is neither volatile nor atomic, so is
technically not suitable for communicating between threads - though in
practice it's presumably working fine here. Maybe look to make it atomic in
a future patch.

>  }
>  
>  /**
> -- 
> 2.53.0
> 

Reply via email to