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 D9F9B45A9A for ; Thu, 3 Oct 2024 11:58:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9AED400D7; Thu, 3 Oct 2024 11:58:46 +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 30305400D7 for ; Thu, 3 Oct 2024 11:58:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727949524; 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=c8Y94JVryT0oY9tYRHnnqoQQ1Jw6xbX5Q9Z4nBdXohY=; b=LF3c6bkyNJtJ1cGgKKivD82TPNdD+YtHibK3Cptfa84nUt+IN2VAMYlnyjpvxxpBeqHr+J REGAXQPAvn8RDGQY3akiDtG/6y/bnoz4BbUsdhhUPEHk0fEQ8Q2NuiRFuJm4s3KYtiP6Bq KnaGStPM7Ou7SAZwf3yEnaHXWu/6vZc= 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-411-KvAC-jeGMz2v0qzoA3JMBA-1; Thu, 03 Oct 2024 05:58:42 -0400 X-MC-Unique: KvAC-jeGMz2v0qzoA3JMBA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5399206172aso517485e87.1 for ; Thu, 03 Oct 2024 02:58:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727949521; x=1728554321; 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=c8Y94JVryT0oY9tYRHnnqoQQ1Jw6xbX5Q9Z4nBdXohY=; b=qJTZ1sz/kCyejIffkJYrqh9rMkSmgjmOYdpyKGluoJeI/VFHKvdneVQpMlspsFwEUj flfYfQG1d5IlxF6W5fbQ0oFUk7DAdo3nPddl8dB4uZIHUdeB3nyOZz7uN/v1jCd7Mvcn CPcPoFxl0kx+x7Zd8E5vZm6DzIep+xQsgjjEiMEXmGcwr2oHuSMaRUc9JxDwMyWL3a9H sEgFOf+p5+/n+q6NsMRjt9eiPjx0fwi+ThwDjEnmhKJFNcN2eqQvmX8XL6SMXInZ8/v+ 4EjjWcvyOQgHFtaxnWpaMnMnjoc7assK4GOElo8KTghaAs/AlAy9EZAkapVD6nH1rfmA hHFQ== X-Forwarded-Encrypted: i=1; AJvYcCXmQ3qosm116uUQFFeQhUB0zuflEaEuODADFRXENuOnEqu0zL5p5YaD0Nbultm590uFU0pzhlk=@dpdk.org X-Gm-Message-State: AOJu0YwEa/3GU6qsbDN2gOLiVFF3DLrb+Esw2vZ7G60MM6rWRGicCusO 5iNLK6V/1xnURlsY2uT8gGwZME6GxXRhZuGWyuoM8N4x00DGeYwCLlLdcyA6mGlAN6Mlk7EIxzo 2qA0VCoiMGeoCtEuEJdUwtUYS/mNUJm+gEA6FlOeJT9GdojTUS5CAqZqO3gP+zWENPB962EFEwy ZraLcVdanAu/ebgPv3eNs= X-Received: by 2002:a05:6512:224b:b0:536:54d6:e6d6 with SMTP id 2adb3069b0e04-539a0663876mr3426905e87.17.1727949521253; Thu, 03 Oct 2024 02:58:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IES3YbfFSQQ2awD03mS6Z+icDSt7Dadl/DPAktL5uU/MFmIvdpeA3XvOvItoyPh2zkjh77u+00+tlZv1MPC7+M= X-Received: by 2002:a05:6512:224b:b0:536:54d6:e6d6 with SMTP id 2adb3069b0e04-539a0663876mr3426893e87.17.1727949520873; Thu, 03 Oct 2024 02:58:40 -0700 (PDT) MIME-Version: 1.0 References: <20241002155709.2522273-1-david.marchand@redhat.com> <20241002155709.2522273-3-david.marchand@redhat.com> In-Reply-To: From: David Marchand Date: Thu, 3 Oct 2024 11:58:28 +0200 Message-ID: Subject: Re: [PATCH 2/2] ethdev: fix race on ports for telemetry commands To: Bruce Richardson Cc: Robin Jarry , dev@dpdk.org, 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 Thu, Oct 3, 2024 at 11:46=E2=80=AFAM Bruce Richardson wrote: > > On Wed, Oct 02, 2024 at 09:26:10PM +0200, Robin Jarry wrote: > > David Marchand, Oct 02, 2024 at 21:18: > > > On Wed, Oct 2, 2024 at 9:09=E2=80=AFPM Robin Jarry wrote: > > > > I was going to suggest adding a rte_spinlock_t* parameter to a new > > > > telemetry register function that would need to be held while the > > > > callback is invoked. Or if we want to keep doors open to other kind= s of > > > > lock, a wrapper callback. > > > > > > Well, as you had experimented this approach, we know this does not > > > work: the ethdev lock is in dpdk shared memory which is not available > > > yet at the time RTE_INIT() is called. > > > > > > A single callback is strange, I guess you mean pre/post callbacks the= n. > > > > It could be a single function that will wrap the callbacks. E.g.: > > > > static int > > eth_dev_telemetry_with_lock( > > telemetry_cb fn, const char *cmd, const char *params, struct rte_tel= _data *d) > > { > > int ret; > > rte_spinlock_lock(rte_mcfg_ethdev_get_lock()); > > ret =3D fn(cmd, params, d); > > rte_spinlock_unlock(rte_mcfg_ethdev_get_lock()); > > return ret; > > } > > > > RTE_INIT(ethdev_init_telemetry) > > { > > .... > > rte_telemetry_register_cmd("/ethdev/stats", eth_dev_handle_port_stat= s, > > "Returns the common stats for a port. Parameters: int port_i= d", > > eth_dev_telemetry_with_lock); > > .... > > } > > > > I'm not sure which solution is the uglier :D > > > > I don't actually mind this latter solution, except that the order of the > parameters should be reversed (and it breaks the ABI, unless we add a > special new function for it) For me, the wrapper function should be the > main callback, and the real (unwrapped) function the extra parameter to b= e > called. That extra parameter to callbacks should just be a generic pointe= r, > so it can be data or function that is passed around. > > rte_telemetry_register_param_cmd(const char *cmd, telemetry_cb fn= , > void *param, const char *help) > > Or more specifically: > > > rte_telemetry_register_param_cmd("/ethdev/stats", > eth_dev_telemetry_with_lock, /* callback */ > eth_dev_handle_port_stats, /* parameter */ > "Returns the common stats for a port. Parameters: int port_id= "); Ok, this way seems nicer. I'll let Robin submit a v2. --=20 David Marchand