DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: David Marchand <david.marchand@redhat.com>, dev@dpdk.org
Cc: Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: Re: [PATCH] ethdev: recommend against using locks in event callbacks
Date: Thu, 1 Feb 2024 10:08:35 +0000	[thread overview]
Message-ID: <8a1a6acf-0e41-40ac-9c27-9265bc5b706f@redhat.com> (raw)
In-Reply-To: <20240201084319.2687896-1-david.marchand@redhat.com>

On 01/02/2024 08:43, David Marchand wrote:
> As described in a recent bugzilla opened against the net/iavf driver,
> a driver may call a event callback from other calls of the ethdev API.
> 
> Nothing guarantees in the ethdev API against such behavior.
> 
> Add a notice against using locks in those callbacks.
> 
> Bugzilla ID: 1337
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  lib/ethdev/rte_ethdev.h | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index 21e3a21903..5c6b104fb4 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -4090,7 +4090,19 @@ enum rte_eth_event_type {
>  	RTE_ETH_EVENT_MAX       /**< max value of this enum */
>  };
>  
> -/** User application callback to be registered for interrupts. */
> +/**
> + * User application callback to be registered for interrupts.
> + *
> + * Note: there is no guarantee in the DPDK drivers that a callback won't be
> + *       called in the middle of other parts of the ethdev API. For example,
> + *       imagine that thread A calls rte_eth_dev_start() and as part of this
> + *       call, a RTE_ETH_EVENT_INTR_RESET event gets generated and the
> + *       associated callback is ran on thread A. In that example, if the
> + *       application protects its internal data using locks before calling
> + *       rte_eth_dev_start(), and the callback takes a same lock, a deadlock
> + *       occurs. Because of this, it is highly recommended NOT to take locks in
> + *       those callbacks.
> + */

That is a good practical recommendation for an application developer.

I wonder if it should taken further so that the API formally states the
callback MUST be non-blocking?

>  typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
>  		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
>  


  reply	other threads:[~2024-02-01 10:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01  8:43 David Marchand
2024-02-01 10:08 ` Kevin Traynor [this message]
2024-02-06 20:33   ` Ferruh Yigit
2024-02-07 14:31     ` Kevin Traynor
2024-02-06 20:27 ` Ferruh Yigit
2024-02-07 15:29 ` Kevin Traynor
2024-02-09 16:07 ` Dariusz Sosnowski
2024-02-09 21:13   ` Ferruh Yigit

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=8a1a6acf-0e41-40ac-9c27-9265bc5b706f@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.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).