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 4B31C45A9E; Wed, 2 Oct 2024 18:27:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12FBA40268; Wed, 2 Oct 2024 18:27:45 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by mails.dpdk.org (Postfix) with ESMTP id 7A3874025C; Wed, 2 Oct 2024 18:27:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727886464; x=1759422464; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=csNfPdYJz/8tXdeLy8h8yuzgZWuFwJ4xfvJOpL1B9gg=; b=XZKymd4zrs0OVv7ZcHR8G3wiAA+OVYZVdmUJcUdRjm+lWheEeR8PRJgB hqqgCL6WVF5mzzMv+H9SY68YnMUBIXtME8jTmhMccPINHs17OMirbX4ke 2SHcJygeAl5fA0T3fJo77iN+G3q4Xvpsie1RGz4CuoRg/PLW3gTVNdntJ eIUTKkDia2HmO8N8CXx9tdxMop0oLkblIlhT+gUXQzicDHXGaqWmoESax dVjt/WYM2IHigkT+e0qKIWoYTMm11sPflKa0FrgfAls53H4DRMc3oV2y0 ybZZZ6NhnBCKCtO/GgPi/a9ix4Z4mugOWNNZ3e6iAxZ0RtYo7X1WM1sX1 Q==; X-CSE-ConnectionGUID: 3YaSKD6vQPmHNc/7ddbP3g== X-CSE-MsgGUID: MZ2a5sZOSOy1VsguqdcRKg== X-IronPort-AV: E=McAfee;i="6700,10204,11213"; a="37647289" X-IronPort-AV: E=Sophos;i="6.11,172,1725346800"; d="scan'208";a="37647289" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2024 09:27:42 -0700 X-CSE-ConnectionGUID: rP89a6GLTJejUDzoKJ+yqQ== X-CSE-MsgGUID: IYJtPTe/RjyIJu0UQM2Ddw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,172,1725346800"; d="scan'208";a="104839238" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 02 Oct 2024 09:27:43 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 2 Oct 2024 09:27:42 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 2 Oct 2024 09:27:42 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Wed, 2 Oct 2024 09:27:42 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.49) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 2 Oct 2024 09:27:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j8DoCbMRQPhl4SGiNHksa2JaS/m6KFgdaccoFkD8BxUq3L/xLVqN+8CYOXy0xpB/c6q2aabzUrsHmC5AAfKNi+3zNO7SyS3xtbstJIVi4uYTXY9r+D2yjV0p0GjwkCfVnkkxGy8E+fQUCxOmxyu+8mLPZtXBBkmVlmBWPURd1V+HhgslzVAWkZLv5vXl3jatb6uWeFthTRBidhIUQL8o4JJrLdUY2Be6atdnehDX1HhIQ0ut8J6r6bbxFNHqkbFe0hCaMF4cO5icbaDDgCR4bQ94XDA+4Cc9GpyTIszTXxBHM+JttKqu//zsHm/XAwMWtLuy2O/I+WYqU6nkJ1FjnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5k93VVuIfONKftzlXtgQ2fBiwA5IR/FUqxz4jqs43M4=; b=q5vV2AqyPd4eodSWlAeTE5gHExqty3KDny/Dx11b3E18mA9c4Eb0VinmiU7FuRH11J0hUlmxG1+bzTh1zHX2hpyjDEOj6qA44lmFLyp0J4kJYY+4yx3mEec0tt6rPIAY4rEbIWaTn9fHawhWqotjTqNKv/KzzxxPlZrSFrOcBDTExff/Js/PIp1oXV2SGZo43JHbROpRrqM3j0Sn7e/uzN3v4AyBjJzAdSudez9KP08jVFaqEbnfvIr0b+VyU7Lq6y9uHyrOJBY9t67z2vkG3yP2NXXL5So7ds9FCbuLTPVrAFh6Q6wRisbjeRTuHszNF6gSgkMv4UTOpLXStRuvxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by MN2PR11MB4695.namprd11.prod.outlook.com (2603:10b6:208:260::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Wed, 2 Oct 2024 16:27:37 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%4]) with mapi id 15.20.8026.014; Wed, 2 Oct 2024 16:27:37 +0000 Date: Wed, 2 Oct 2024 17:27:31 +0100 From: Bruce Richardson To: David Marchand CC: , , , , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Keith Wiles , Ciara Power Subject: Re: [PATCH 2/2] ethdev: fix race on ports for telemetry commands Message-ID: References: <20241002155709.2522273-1-david.marchand@redhat.com> <20241002155709.2522273-3-david.marchand@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20241002155709.2522273-3-david.marchand@redhat.com> X-ClientProxiedBy: DUZP191CA0056.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4fa::14) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|MN2PR11MB4695:EE_ X-MS-Office365-Filtering-Correlation-Id: d13edd18-ad4e-4e57-de24-08dce2ff2071 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nAEtTu7Mzmzys+Bm4qvTLAVgtBsSfVhYMTiD6WIE3E9qsRMSe8rVnpwVy6mn?= =?us-ascii?Q?acMY5AhWrnaMdNAN8bXtRTmnSM+pUusxE68wJ0Ah8LUC3YZNXARYNhwp/+w6?= =?us-ascii?Q?Zi79PfVOZ4vBA5wHF4yVOse9oFhz+RYo2hqmCSC2KhV1YS6oIPe6hv1Qn0O2?= =?us-ascii?Q?z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tg8GXSKGznR3USrhZ0f0nMzIE?= =?us-ascii?Q?/Q/d7imAcxnzeJMUrbacYF79qmFfWcZzkaEZgZN8peuQjLi+ZcuLp54ThhLC?= =?us-ascii?Q?1E2DfsevZ3M0IPfSAQZuE9Z1Uj2E/rggnj4PTcv7odYDNLt45UlUd8j4haN0?= =?us-ascii?Q?zPNEjtypqFMOmWEOVfri7qnWXb5isWp4vae4amKZrmsicqxDIpZfpL57mAA9?= =?us-ascii?Q?s8vH9pxSk9mMNxEtrU9bIZJd7PFxFnplTaitLRbCRw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lfZCethH2LKxF/Uv4wpRnUts7VgteezkwjhuOPYSeRceMqy6zMHVlDMbIb5w?= =?us-ascii?Q?XvzAjr18aHWy6NmapV7p8CZ6wRCFscwos/AthfG6+7/7V40tBtxNm7FESAb/?= =?us-ascii?Q?YF5xYEMCM6GnbDZn6QIFjouXwD6sYz/ekls8RoRWFH0k8BWr/q834MgbmYS/?= =?us-ascii?Q?nJYKIRDs7WKLncegrXVHnqhBjEYVoSmaMlm4IylrEzFZ/nI9MuOyZFe6owSm?= =?us-ascii?Q?ynmKlQ16byYtKPNaHO++RW4orkQHjH7WjFqJwcXU4eCEoU9WWKlA1iUcrEfk?= =?us-ascii?Q?evVjGgmSHFov2/Ara9yp1NRsQxh4CmRgaNJ9YnXv68fjoiwDF43ospb58kBk?= =?us-ascii?Q?wQ2GTGCE7iYD3IQE6Lp8+J0cN8krhXXAaOmulPF57DC5RSXvZ5xlWJ+qXKJv?= =?us-ascii?Q?43gKsW7hcArIOx17XI/yuwoFUZAPdXH4oLLCT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pcJP75uXsmvwBqjgq7aGYIZgZcPRTrdTpz0cNtuEyuC+K0F5DwxLORb7cn?= =?us-ascii?Q?tmHY//2lWGGMxEhxVIkkCNvJiYb11yZ4QOhxSTxrmuLHySqAnxyzQ+Ink7T6?= =?us-ascii?Q?nOx8wpOxciefhti1Qj3+rE55Rw5nL5gpIXfmRYpj2dxeNL15KrV6XxDXvYFI?= =?us-ascii?Q?qOyefS2wt6IJr7ATQpgVSA1fg2MAZPPg2+tOGiVU/Ey8gZFaECZrZULYAbmh?= =?us-ascii?Q?sPE+QH+IZc1Q0/QGxqceimMGmk/6whUd4qxQFkErTLge/6gSIfJqpW432tcJ?= =?us-ascii?Q?zA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: d13edd18-ad4e-4e57-de24-08dce2ff2071 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 16:27:37.1026 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wXsI6aCgll9tHhpsbECeYnbXDW7Tq88/XuwzaVIRQSuIy12Ka2LQp6AQTh8CAT6AivDXMcwaEy4nzcM4uJrJ2oeZPm7jZ9EamSzi51+m46s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4695 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Oct 02, 2024 at 05:57:08PM +0200, David Marchand 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 > initialised/uninitialised ethdev data. > > Reuse the ethdev lock that protects port allocation/destruction. > > 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 *cmd __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 parameters") \ > + ETHDEV_TELEMETRY_HANDLER("/ethdev/stats", eth_dev_handle_port_stats, \ > + "Returns the common stats for a port. Parameters: int port_id") \ > + ETHDEV_TELEMETRY_HANDLER("/ethdev/xstats", eth_dev_handle_port_xstats, \ > + "Returns the extended stats for a port. Parameters: int port_id,hide_zero=true|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_port_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: int port_id") \ > + ETHDEV_TELEMETRY_HANDLER("/ethdev/macs", eth_dev_handle_port_macs, \ > + "Returns the MAC addresses for a port. Parameters: int port_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_id, 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_id, 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_handle_port_tm_level_caps, \ > + "Returns TM Level Capabilities info for a port. Parameters: int port_id, int level_id (see tm_capability for the max)") \ > + ETHDEV_TELEMETRY_HANDLER("/ethdev/tm_node_capability", eth_dev_handle_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) \ > +static int func ## _locked(const char *cmd __rte_unused, const char *params, \ > + struct rte_tel_data *d) \ > +{ \ > + int ret; \ > + rte_spinlock_lock(rte_mcfg_ethdev_get_lock()); \ > + ret = func(cmd, params, d); \ > + rte_spinlock_unlock(rte_mcfg_ethdev_get_lock()); \ > + return ret; \ > +} > +ETHDEV_TELEMETRY_HANDLERS > +#undef ETHDEV_TELEMETRY_HANDLER > + Not really a massive fan of such use of macros in the code, since I think it makes things obscure for the casual reader. However, I see why this approach has been taken. I think the macro code needs some documentation explaining why this was done this way. > RTE_INIT(ethdev_init_telemetry) > { > - rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list, > - "Returns list of available ethdev ports. Takes no parameters"); > - rte_telemetry_register_cmd("/ethdev/stats", eth_dev_handle_port_stats, > - "Returns the common stats for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/xstats", eth_dev_handle_port_xstats, > - "Returns the extended stats for a port. Parameters: int port_id,hide_zero=true|false(Optional for indicates hide zero xstats)"); > - rte_telemetry_register_cmd("/ethdev/dump_priv", eth_dev_handle_port_dump_priv, > - "Returns dump private information for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/link_status", > - eth_dev_handle_port_link_status, > - "Returns the link status for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info, > - "Returns the device info for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/module_eeprom", eth_dev_handle_port_module_eeprom, > - "Returns module EEPROM info with SFF specs. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/macs", eth_dev_handle_port_macs, > - "Returns the MAC addresses for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/flow_ctrl", eth_dev_handle_port_flow_ctrl, > - "Returns flow ctrl info for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq, > - "Returns Rx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)"); > - rte_telemetry_register_cmd("/ethdev/tx_queue", eth_dev_handle_port_txq, > - "Returns Tx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)"); > - rte_telemetry_register_cmd("/ethdev/dcb", eth_dev_handle_port_dcb, > - "Returns DCB info for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info, > - "Returns RSS info for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/fec", eth_dev_handle_port_fec, > - "Returns FEC info for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/vlan", eth_dev_handle_port_vlan, > - "Returns VLAN info for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/tm_capability", eth_dev_handle_port_tm_caps, > - "Returns TM Capabilities info for a port. Parameters: int port_id"); > - rte_telemetry_register_cmd("/ethdev/tm_level_capability", eth_dev_handle_port_tm_level_caps, > - "Returns TM Level Capabilities info for a port. Parameters: int port_id, int level_id (see tm_capability for the max)"); > - rte_telemetry_register_cmd("/ethdev/tm_node_capability", eth_dev_handle_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) \ > + rte_telemetry_register_cmd(command, func ## _locked, usage); > + ETHDEV_TELEMETRY_HANDLERS > +#undef ETHDEV_TELEMETRY_HANDLER > } An alternative to this macro-fu, is to just define a single ethdev telemetry function, and within that, take the lock and then dispatch to the appropriate subfunction based upon the actual command coming in. The dispatch may be slightly slower due to the additional text matching (only from byte 8 onwards, so very short strings), but I think the code could be a simpler in C rather than in macros, and the perf impact for telemetry is likely to be negligible, compared to the overhead of the socket I/O etc. /Bruce