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 AB79243A34; Thu, 1 Feb 2024 09:43:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 79E8040299; Thu, 1 Feb 2024 09:43:52 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 97DE340275 for ; Thu, 1 Feb 2024 09:43:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706777030; 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; bh=nhWHxri6cbDSXnSUOyadaxNbtplbzFLU5ra57JyIW4A=; b=UJvbWM3X2EEtB+eD1HdIcnBR6e4OalvK5fM/h3QWTYGWKepeQFTm85cwuQwz8AGMr8Y+8x Taud94DDtcyqRUCpACn8gG4+rVdeWcXyPXKDcneCAilA59pyHG1yQM+qQnBM20iu873KXL 5Z/DeXq24SwLejv9kYnRaG4MEg4X5/U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-94-VYWKaEHgM92u2Wpt9HgEpQ-1; Thu, 01 Feb 2024 03:43:47 -0500 X-MC-Unique: VYWKaEHgM92u2Wpt9HgEpQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99FEA185A780; Thu, 1 Feb 2024 08:43:46 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53C7D1121306; Thu, 1 Feb 2024 08:43:45 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: ktraynor@redhat.com, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH] ethdev: recommend against using locks in event callbacks Date: Thu, 1 Feb 2024 09:43:18 +0100 Message-ID: <20240201084319.2687896-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 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 --- 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. + */ typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id, enum rte_eth_event_type event, void *cb_arg, void *ret_param); -- 2.43.0