Article View: linux.kernel.netdev
Article #8967[PATCH RFC 1/2] net/mlx5: Submit blocking commands from the caller's context
From: Breno Leitao
Date: Fri, 30 Oct 2026 16:31
Date: Fri, 30 Oct 2026 16:31
49 lines
11922 bytes
11922 bytes
mlx5_cmd_invoke() queues every command that is not a page-queue command
on the ordered cmd->wq, and a blocking caller then sleeps in wait_func()
until the command completes. The work item only takes a command slot,
writes the descriptor and rings the doorbell, so each blocking command
pays for a queue_work(), a worker wakeup and a context switch while its
caller sits idle.
All ordered workqueues share one unbound worker pool, so the command
work items of every mlx5 function also contend on a single pool->lock.
On an arm64 host with a dozen mlx5 functions in switchdev mode, where
monitoring daemons read /proc/net/dev, lock contention profiling put
36% of the pool->lock wait in queue_work() called from cmd_exec(), and
the rest in the workers running the command and stats work items.
Page-queue commands already call cmd_work_handler() directly. Do the
same for every command without a callback. Callback commands keep using
the workqueue, since mlx5_cmd_exec_cb() must not block.
Firmware runs up to max_reg_cmds commands concurrently, so callers could
not rely on the submission order, and the slot semaphore still serves
its waiters in FIFO order.
With 32 parallel ethtool -S loops on a ConnectX-4 Lx, this removes all
46.7k mlx5_cmd work items of the run and cuts kworker context switches
from 50.7k to 3.9k.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 84583dc5eb1c05..988518155582a4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1301,7 +1301,8 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
INIT_DELAYED_WORK(&ent->cb_timeout_work, cb_timeout_handler);
INIT_WORK(&ent->work, cmd_work_handler);
- if (page_queue) {
+ /* A blocking caller waits for the command anyway, submit it inline */
+ if (page_queue || !callback) {
cmd_work_handler(&ent->work);
} else if (!queue_work(cmd->wq, &ent->work)) {
mlx5_core_warn(dev, "failed to queue work\n");
--
2.53.0-Meta
Technical Details
Message-ID:
<20261030-mlx5-cmd-wq-v1-1-1458b2aed637@debian.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer04.iad!feed-me.highwinds-media.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353845-linux-kernel-netdev=dewy.ruReferences:
<20261030-mlx5-cmd-wq-v1-0-1458b2aed637@debian.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer04.iad!feed-me.highwinds-media.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353845-linux-kernel-netdev=dewy.ru From: leitao@debian.org (Breno Leitao) Newsgroups: linux.kernel.netdev Subject: [PATCH RFC 1/2] net/mlx5: Submit blocking commands from the caller's context Date: Fri, 30 Oct 2026 09:31:43 -0700 Organization: Usenet Network Message-ID: <20261030-mlx5-cmd-wq-v1-1-1458b2aed637@debian.org> References: <20261030-mlx5-cmd-wq-v1-0-1458b2aed637@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2275464"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:7Yi0DseSv0HBJqSzFL4UjlQL07s= sha256:yYINqLVy4t5bt3PNGMijcaLBUv+dHmId+5+i41SBdVE= sha1:jGFfxBD5ZKf7ApUaVB9xbFFePc0= sha256:c7NfIjXQrVjpcrwYQ747jZ5ZaZ1uOOQ5AqeVGNdBBGw= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 2A9CF125CA3; Fri, 30 Oct 2026 19:36:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=debian.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id viPuldug20Ii; Fri, 30 Oct 2026 19:36:02 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353845-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=debian.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 58762125CA0; Fri, 30 Oct 2026 19:35:54 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 886792DDB7; Fri, 30 Oct 2026 16:31:59 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793377919; b=TVcioIQQle2SATrwYEZgl5u5fHYbGAG6Kp7w3PlHaftX+sAU69+t5U6tUz2DmU/dXwHj Vh8HTicHMZUEYV3OFfmYuWheK++M/F7Xg/kbpagYaDqEoNYqHGZdAS0MxtlWydHM2GZXs 1lVRlZ9mmyc7LxpScpan8iEAItvDuksRsE9qay3wC98fvtraEKqrCwJAIAm1G8QXLj46/ 5jjrLOsoNOMJwi/H1gCIXvWSMHv1LwxCAKZwminb/73CW5/bkEhtmzg2jXxXK75n/kDOO Gw7mjN+g/3cYqjLfu0XnqUHgMUgB/yed0uqIFtAFU6SfcU0k4sxvrIqRSnRwqTPMpMg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793377919; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From: Date:Subject:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Debian-User; bh=Pq+i8rJi/9ZoV6LFHD0nn/AL1YjVYkhOQnH0yPWO1Xc=; b=HHk+FuOKaiNuk/9olMcnCPmLRjK90nd09LZ4e0VVJm8ObQa+u8iBt1r0znXo53PdRhPh rVq/I4ZVvaeBnyLwGQfp2VeSSjJR6jITsgXkDxUOJ49aKMwgxbhhnw76U2Qxtg1jrGUPF va7Es/FDdZsyPmHuM8Lk6EvsSkXFlsHiwkPr/etsjN6zspcG10fgtX9UWEfjYGLWUqDUg dAQszg9mVifcT9Cm8cuZrVtSdS02paOEjIfQyULAZJO3sdnSAT0dMtag4FltS7iHA6j9X IegoWVxEDmnGLkzmKgyd096pRUijMOCduFAB0Df9kgqi6Xn8soAzxZDKtC98reZF8ow== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=kmJA83O+; dmarc=pass header.from=debian.org; spf=pass smtp.mailfrom=debian.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AC94606A32C; Fri, 30 Oct 2026 16:31:59 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=kmJA83O+ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=82.195.75.108 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793377918; b=QUKLVuLqI8Tx1X3cwPZtyfr6sobdEjCokRiRpg5SZH0FhMLT0VwgeEIJTTko8O61oY0R QNPJmAm0fB2Q9rSRPCn2Q8nz86edwQrsNDtkD4TYDJf5E3dD5RRXw3ZVcQqHAgYNhUkq3 cgiaDnv4FH9X726wxegONNpB5o5nKKkA5J5f1j9QqvfWxYESx3VX80uynandmMMmxgh0H vH5vJTNWvEyj8Jczrp5LRmUnQXH5/KFSFQuoTAcPSvGuSvGTUY5sQIubgxb/XT+UjJpmb lhH2CJgXbRwv9xTOeJnewv+yAgoqlXUHk9VbDpujtTHL5ZWCO8Q5wyQQA2b7BYa3EoQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793377918; h=DMARC-Filter:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Debian-User; bh=Pq+i8rJi/9ZoV6LFHD0nn/AL1YjVYkhOQnH0yPWO1Xc=; b=EGJVHQbmDc7uAZZz/WFgfgzESn5d7UShSSy9r16UYG7znGbDJQUeIkaKT5gfhBbkAEcT prgmeD+Pg8QPgX4eCGTOLC7RU+fPgRCy4E5wZxCivcVe3mWMDuCsFDjNnXYcuPOB6KAX2 IHfeG/4ellMyeX6c2WRILoX+h6YJ7uGGQATKtZSsPHNrJxO1BeOB9nhL3YpS1EIv7UNQn s1+06jRUb/k+Kvof4IF/amknnKokbtubwZZLQJDYySZLMKfOQL6pSyeNjIFCyOPlEV1SS 4iX4Jdv0cmVl1sM1ZfO4qlhzkM61s5Leo1594aGomSHHBO7poW6CH9eDVk8PMbebqxQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=kmJA83O+; arc=none smtp.remote-ip=82.195.75.108 X-Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB568606A31F; Fri, 30 Oct 2026 16:31:57 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BB568606A31F X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=Pq+i8rJi/9ZoV6LFHD0nn/AL1YjVYkhOQnH0yPWO1Xc=; b=kmJA83O+MQfglZeCpSQOE4P75x ull6C2vVsipPfVK7BWmaTdd7EdxnKHQt8oDYQ8TCBPiJqs1MLx0fQniY1wScXct7QQbo5KpyCT3RY 7MV5myrJmIn/Uy+YrNClos9+yKJjrS95t8kBFcatMlO55ehbd6FdoCAQdy1pEtXUlMAjdxtoXIQMj 33raxOS/q9ehBseYiDaFuj6l7yrf9LjCBvJgX/0+Uw37xOvOAztuMPcJ3WxlZ52T+oUM00S3oQ/p6 cZjJ/gbx1uWUvZ6xPLt9ZSYJUfXII52A3Ubvn8cryTSJDYKKfaWMBmMXy8bRmUnOj89Ebf6HPgRG1 gAKUH1Bg==; X-Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from <leitao@debian.org>) id 1xMpWD-003x1v-29; Fri, 30 Oct 2026 16:31:53 +0000 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261030-mlx5-cmd-wq-v1-0-1458b2aed637@debian.org> X-Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Breno Leitao <leitao@debian.org>, kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=2270; i=leitao@debian.org; h=from:subject:message-id; bh=/85JIr0ETe8f+4pRr4MDFjchmH9gZ5ulHRVINwtreoc=; b=owEBbAKT/ZANAwAIATWjk5/8eHdtAcsmYgBq5MZyYdCWBWfs86LIQZNZeYvPd6p/gMZp20vuj gh2L5AaMM2JAjIEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCauTGcgAKCRA1o5Of/Hh3 bQEzD/isKA+azalzoS9OvSRRJzHF5gGcjOoH7b+Xc9CLDP1o16VxdvZ+euLjRzFyAyQmi6WMdS8 irl41IIE/jmr1n5e3PfeUEQ77BdH25QaAK3zQ8FpNW1zquaiQ4qjkVk6LBnRQP0HrxTKKDAOA89 eNssF9n3IkSMeSzg9hf0EbKM25NHbu5Tv4QZtKnM9/pgdLbJyi6VHkhvvv0RSoO36BO6dPddN41 XX7MNVLSxnKz5xGjtsKq57Gx7TJJt9aR+7vSErCq7fcwPbUEv5fZRx7kauIAnLruqp0ykw9bDoR FPgMd0MNFGL/B/Dso/oxH3YUefj9ZgYQWynR31Nzh/JWxwtWNKr1MIVJYb/3fCvNDJ7hYp2d0J9 HUnEDxcYOIHlgQWNOJxQDEBZr5o0O266aOo//DWWNJWuTJRcOzEKvQ3OOZ5w5IKWcsljPS7Jmm0 cyilxznT5bx+35y0KlaLAb2wquPebkKGcBBS/P6XXD35xzXRDA5n7XFPdDPauexXB0fZLHYDyU+ eOiw+H/b4x2WvxRbjFbvTupHaCNXaJz9OvSiw/Jr1y8BjyCTwFRZUY0293wEiU5z3tHJLIMqFV9 nwnZzbIDa3aKpO2TsMSnfvUDce58YxtGmPMbgpWrtDgOoy8EpxAVxu1IWNUjWJqgJqKqiZULUWM Pbo1DyBEkdq2q X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao X-Received-Bytes: 11716