From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 76BBD45ADF for ; Tue, 8 Oct 2024 08:49:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C4154025D; Tue, 8 Oct 2024 08:49:14 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 2709F4025D for ; Tue, 8 Oct 2024 08:49:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728370152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=64085DL+Gh/stKALGFg1oS+z0O3dskcXCOS1uiNuqo0=; b=SzsdDsNOM1sHip2/nkNnpCQs+lB+BnyaZnL2guFIM3LvkpEvS2ThMI9VxtTwo2Fm+kLsbC MICh7T2k7vHAzCHGr2onXfprhlDCfZs/vFk++bCYqUA5V5G3LGgSbTlaq7wnpqZ3JyG9ty Zupiu0gc6PE3Ac8uHOKuYzU+XpUrPfs= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-004zSAfpO96ccgaB1UcoFA-1; Tue, 08 Oct 2024 02:49:11 -0400 X-MC-Unique: 004zSAfpO96ccgaB1UcoFA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-53691cd5a20so4210359e87.3 for ; Mon, 07 Oct 2024 23:49:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728370150; x=1728974950; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=64085DL+Gh/stKALGFg1oS+z0O3dskcXCOS1uiNuqo0=; b=rPhlHlmxERcT90dUzvA+svL2qeELt/cFNOleFMM1Q0cd8KyaGAWCYZO42rXvQhYjkq Rb3AwM3I8s0hywIOcOM7EvSNPiysEAiGaifbYCD+5EoKF5xlAbgl9Nwcht9Sd58ra4KA EFW/wEGpckp2rMVlqtGQnSV44bhGQNLIJ3T8FZu+MB+yyFU4t65Wk6MuygaEMe8SBfmR OwGl2KSDCvezmybTXgPns9zMJIVfU5cQ36DAePO7EegYqBi1TeBvzvOtNAWLfTO8ndjt 03sVSDl117EU0yQ0g9kug2Hjt2LrFTYb+29zVb91U3w8XYBC2LSGXpVKFK9TPPkGkc7l zgYg== X-Forwarded-Encrypted: i=1; AJvYcCUl6LEaIS02/3qVThevPqAzMJXXWgp0TF7u7XGO7DOrXZQ8uTVombgLL3U+iK2VNkZFETgGJvY=@dpdk.org X-Gm-Message-State: AOJu0YxghcurnGNU9s7kU36Y0CbsQWxxTvFIMwWfWGhbbaxXcJte2+LH ut+/EAVoyNnLL4VNSpmng0oT3qd+7SeZ4vyoE7hSP3y4s+3HFAj71qGq0uykkYeGcDFFET8xig1 sC+Jfkes1ONQw+K/oSdKhoJVpjsMuI910TLSb1H2qAfOnSiegsKEtgW7cWS2qTFpWdALgyFzwBr 1kBt4hRsq9oIbLHRd+NG8= X-Received: by 2002:a05:6512:a90:b0:539:948a:aadb with SMTP id 2adb3069b0e04-539ab9de485mr7094360e87.42.1728370150080; Mon, 07 Oct 2024 23:49:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMxkHPPTKsG9BywfKacxnOXPWECv0BuLUF5DjpiB9/v/tblUglA6KaAWj76JhouOnCcBurNjXJMT+Ge/yFam8= X-Received: by 2002:a05:6512:a90:b0:539:948a:aadb with SMTP id 2adb3069b0e04-539ab9de485mr7094338e87.42.1728370149619; Mon, 07 Oct 2024 23:49:09 -0700 (PDT) MIME-Version: 1.0 References: <20241002155709.2522273-1-david.marchand@redhat.com> <20241002155709.2522273-3-david.marchand@redhat.com> <1f0865f8-a76a-caf1-2ec0-9a3d86525d9e@huawei.com> In-Reply-To: <1f0865f8-a76a-caf1-2ec0-9a3d86525d9e@huawei.com> From: David Marchand Date: Tue, 8 Oct 2024 08:48:58 +0200 Message-ID: Subject: Re: [PATCH 2/2] ethdev: fix race on ports for telemetry commands To: "lihuisong (C)" Cc: dev@dpdk.org, bruce.richardson@intel.com, rjarry@redhat.com, ktraynor@redhat.com, stable@dpdk.org, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Keith Wiles , Ciara Power X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Tue, Oct 8, 2024 at 4:09=E2=80=AFAM lihuisong (C) = wrote: > > > =E5=9C=A8 2024/10/2 23:57, David Marchand =E5=86=99=E9=81=93: > > 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 > > initialised/uninitialised ethdev data. > > > > Reuse the ethdev lock that protects port allocation/destruction. > Agree to lock for telemetry. > > > > Fixes: c190daedb9b1 ("ethdev: add telemetry callbacks") > > Cc: stable@dpdk.org > > > > Signed-off-by: David Marchand > > --- > > lib/ethdev/rte_ethdev_telemetry.c | 93 +++++++++++++++++++-----------= - > > 1 file changed, 56 insertions(+), 37 deletions(-) > > > > diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_= telemetry.c > > index 8031a58595..7f9c924209 100644 > > --- a/lib/ethdev/rte_ethdev_telemetry.c > > +++ b/lib/ethdev/rte_ethdev_telemetry.c > > @@ -6,6 +6,7 @@ > > #include > > > > #include > > +#include > > #include > > > > #include "rte_ethdev.h" > > @@ -1403,43 +1404,61 @@ eth_dev_handle_port_tm_node_caps(const char *cm= d __rte_unused, > > return ret; > > } > > > > +#define ETHDEV_TELEMETRY_HANDLERS \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/list", eth_dev_handle_port_list= , \ > > + "Returns list of available ethdev ports. Takes no paramet= ers") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/stats", eth_dev_handle_port_sta= ts, \ > > + "Returns the common stats for a port. Parameters: int por= t_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/xstats", eth_dev_handle_port_xs= tats, \ > > + "Returns the extended stats for a port. Parameters: int p= ort_id,hide_zero=3Dtrue|false(Optional for indicates hide zero xstats)") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/dump_priv", eth_dev_handle_port= _dump_priv, \ > > + "Returns dump private information for a port. Parameters:= int port_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/link_status", eth_dev_handle_po= rt_link_status, \ > > + "Returns the link status for a port. Parameters: int port= _id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/info", eth_dev_handle_port_info= , \ > > + "Returns the device info for a port. Parameters: int port= _id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/module_eeprom", eth_dev_handle_= port_module_eeprom, \ > > + "Returns module EEPROM info with SFF specs. Parameters: i= nt port_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/macs", eth_dev_handle_port_macs= , \ > > + "Returns the MAC addresses for a port. Parameters: int po= rt_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/flow_ctrl", eth_dev_handle_port= _flow_ctrl, \ > > + "Returns flow ctrl info for a port. Parameters: int port_= id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/rx_queue", eth_dev_handle_port_= rxq, \ > > + "Returns Rx queue info for a port. Parameters: int port_i= d, int queue_id (Optional if only one queue)") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/tx_queue", eth_dev_handle_port_= txq, \ > > + "Returns Tx queue info for a port. Parameters: int port_i= d, int queue_id (Optional if only one queue)") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/dcb", eth_dev_handle_port_dcb, = \ > > + "Returns DCB info for a port. Parameters: int port_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/rss_info", eth_dev_handle_port_= rss_info, \ > > + "Returns RSS info for a port. Parameters: int port_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/fec", eth_dev_handle_port_fec, = \ > > + "Returns FEC info for a port. Parameters: int port_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/vlan", eth_dev_handle_port_vlan= , \ > > + "Returns VLAN info for a port. Parameters: int port_id") = \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/tm_capability", eth_dev_handle_= port_tm_caps, \ > > + "Returns TM Capabilities info for a port. Parameters: int= port_id") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/tm_level_capability", eth_dev_h= andle_port_tm_level_caps, \ > > + "Returns TM Level Capabilities info for a port. Parameter= s: int port_id, int level_id (see tm_capability for the max)") \ > > + ETHDEV_TELEMETRY_HANDLER("/ethdev/tm_node_capability", eth_dev_ha= ndle_port_tm_node_caps, \ > > + "Returns TM Node Capabilities info for a port. Parameters= : int port_id, int node_id (see tm_capability for the max)") > > + > > +#define ETHDEV_TELEMETRY_HANDLER(command, func, usage) \ > In addition, the "command" and "usage" are unuseful in this definition. > This is confused to me. > Can the first macro definition just use 'func' as input parameter? > The name of this macro define is the same as the below one. > I prefer to use two different macros to do this. This patch has been withdrawn. Robin is working on another approach, see: https://patchwork.dpdk.org/project/dpdk/patch/20241003112438.902397-6-rjarr= y@redhat.com/ https://patchwork.dpdk.org/project/dpdk/patch/20241003112438.902397-7-rjarr= y@redhat.com/ --=20 David Marchand