All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Robin Jarry <rjarry@redhat.com>
Cc: dev@dpdk.org, Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Ciara Power <ciara.power@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Keith Wiles <keith.wiles@intel.com>,
	stable@dpdk.org
Subject: Re: [PATCH dpdk v3 2/2] ethdev: fix potential race in telemetry endpoints
Date: Mon, 14 Oct 2024 13:01:24 -0700	[thread overview]
Message-ID: <20241014130124.32c7b4bf@hermes.local> (raw)
In-Reply-To: <20241014193237.1992382-3-rjarry@redhat.com>

On Mon, 14 Oct 2024 21:32:37 +0200
Robin Jarry <rjarry@redhat.com> wrote:

> While invoking telemetry commands (which may happen at any time, out of
> control of the application), an application thread may concurrently
> add/remove ports. The telemetry callbacks may then access partially
> initialized/uninitialised ethdev data.
> 
> Reuse the ethdev lock that protects port allocation/destruction and the
> new telemetry callback register api that takes an additional private
> argument. Pass eth_dev_telemetry_do as the main callback and the actual
> endpoint callbacks as private argument.
> 
> Fixes: c190daedb9b1 ("ethdev: add telemetry callbacks")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  lib/ethdev/rte_ethdev_telemetry.c | 66 ++++++++++++++++++++++---------
>  1 file changed, 47 insertions(+), 19 deletions(-)
> 
> diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
> index 6b873e7abe68..7599fa2852b6 100644
> --- a/lib/ethdev/rte_ethdev_telemetry.c
> +++ b/lib/ethdev/rte_ethdev_telemetry.c
> @@ -1395,45 +1395,73 @@ eth_dev_handle_port_tm_node_caps(const char *cmd __rte_unused,
>  	return ret;
>  }
>  
> +static int eth_dev_telemetry_do(const char *cmd, const char *params,
> +				void *arg, struct rte_tel_data *d)
> +{
> +	int ret;
> +	telemetry_cb fn = arg;
> +	rte_spinlock_lock(rte_mcfg_ethdev_get_lock());
> +	ret = fn(cmd, params, d);
> +	rte_spinlock_unlock(rte_mcfg_ethdev_get_lock());
> +	return ret;
> +}

If this happens often, and the function takes a long time (like doing i/o)
it might be worth changing this to reader/writer in future.

Also, would be best to add a comment here as to what is being protected
if you do another version.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

  reply	other threads:[~2024-10-14 20:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 15:57 [PATCH 0/2] Fix race in ethdev telemetry David Marchand
2024-10-02 15:57 ` [PATCH 1/2] ethdev: expose telemetry dump command for Windows David Marchand
2024-10-02 15:57 ` [PATCH 2/2] ethdev: fix race on ports for telemetry commands David Marchand
2024-10-02 16:27   ` Bruce Richardson
2024-10-02 19:06     ` David Marchand
2024-10-02 19:09       ` Robin Jarry
2024-10-02 19:18         ` David Marchand
2024-10-02 19:26           ` Robin Jarry
2024-10-03  9:46             ` Bruce Richardson
2024-10-03  9:58               ` David Marchand
2024-10-08  2:07   ` lihuisong (C)
2024-10-08  6:48     ` David Marchand
2024-10-03 11:24 ` [PATCH dpdk v2 0/2] Fix race in ethdev telemetry Robin Jarry
2024-10-03 11:24 ` [PATCH dpdk v2 1/2] telemetry: add api to register command with private argument Robin Jarry
2024-10-03 11:39   ` Bruce Richardson
2024-10-03 12:36     ` Robin Jarry
2024-10-03 12:43       ` Robin Jarry
2024-10-03 11:24 ` [PATCH dpdk v2 2/2] ethdev: fix potential race in telemetry endpoints Robin Jarry
2024-10-03 11:39   ` Bruce Richardson
2024-10-14 19:32 ` [PATCH dpdk v3 0/2] Fix race in ethdev telemetry Robin Jarry
2024-10-14 19:32   ` [PATCH dpdk v3 1/2] telemetry: add api to register command with private argument Robin Jarry
2024-10-14 19:32   ` [PATCH dpdk v3 2/2] ethdev: fix potential race in telemetry endpoints Robin Jarry
2024-10-14 20:01     ` Stephen Hemminger [this message]
2024-10-15  8:02       ` David Marchand
2024-10-15  8:04         ` Robin Jarry
2024-10-15  8:38     ` 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=20241014130124.32c7b4bf@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=ciara.power@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=keith.wiles@intel.com \
    --cc=rjarry@redhat.com \
    --cc=stable@dpdk.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.