DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Pravin Pathak <pravinpathakdev@gmail.com>
Cc: <dev@dpdk.org>, <jerinj@marvell.com>,
	<tirthendu.sarkar@intel.com>, <pravin.pathak.dev@gmail.com>
Subject: Re: [PATCH v1] event/dlb2: race condition during dynamic linking
Date: Thu, 22 Oct 2026 17:51:33 +0100	[thread overview]
Message-ID: <ato_FWxmvDFdKfzY@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20261021172041.433881-1-pravin.pathak.dev@gmail.com>

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 <pravin.pathak.dev@gmail.com>
> ---
>  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 <bruce.richardson@intel.com>


> 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
> 

  parent reply	other threads:[~2026-10-22 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 17:20 [PATCH v1] event/dlb2: race condition during dynamic linking Pravin Pathak
2026-10-22 16:46 ` Sarkar, Tirthendu
2026-10-23 12:49   ` Jerin Jacob
2026-10-22 16:51 ` Bruce Richardson [this message]
2026-10-27 21:00 ` Stephen Hemminger

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=ato_FWxmvDFdKfzY@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=pravin.pathak.dev@gmail.com \
    --cc=pravinpathakdev@gmail.com \
    --cc=tirthendu.sarkar@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox