Article View: linux.kernel.netdev
Article #17708[PATCH net-next v1] net/mlx5e: TX, Do not open a multi-packet WQE for a single packet
From: Xuanqiang Luo
Date: Tue, 17 Nov 2026 08:50
Date: Tue, 17 Nov 2026 08:50
116 lines
13754 bytes
13754 bytes
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
A multi-packet WQE (MPWQE, added by commit 5af75c747e2a ("net/mlx5e:
Enhanced TX MPWQE for SKBs")) lets several packets share one WQE, so the
control and Ethernet segments are fetched by the device once per batch
instead of once per packet. This saves PCIe bandwidth and CPU cycles, but
only if the WQE carries more than one packet.
With skb_tx_mpwqe enabled, which is the default, mlx5e_xmit() sends every
skb accepted by mlx5e_tx_skb_supports_mpwqe() through an MPWQE session.
A session stays open between two calls only while the stack sets
xmit_more. A packet without xmit_more closes the session and rings the
doorbell. Hence a packet that comes without xmit_more while no session is
open opens a session just for itself and closes it right away. Such a WQE
takes one WQEBB, as a regular WQE does for the same packet, and the
doorbell is rung for each packet either way, so nothing is saved.
This is the case for the IP fragments of a large UDP datagram and for
UDP request/response traffic, which reach the driver one packet at a
time. With pktgen and burst 1 every MPWQE carries one packet (mpwqe_blks
equals mpwqe_pkts, xmit_more is 0) and the packet rate is 15% lower than
with skb_tx_mpwqe turned off.
Use the regular WQE path for a packet that has no xmit_more and no open
session. Packets with xmit_more still open and extend a session, and the
last packet of a batch still closes it, so batching is unchanged.
The only visible change besides the performance is in the statistics:
tx*_mpwqe_blks and tx*_mpwqe_pkts no longer count a packet sent alone.
Such a packet is counted in tx*_packets, as any packet sent with a
regular WQE.
pktgen, 64 B packets on one TX queue, between two 10G ConnectX-5 hosts,
2-socket Hygon C86-4G 7490 sender on net-next, the patch switched at run
time by a temporary module parameter (not part of this patch) so that
before and after run in the same boot, mean of 3 boots x 3 rounds:
test before after change
pktgen 64 B burst 1, kpps 1494 1740 +16.5%
pktgen 64 B burst 16, kpps 3236 3236 +0.0%
Batches do not regress: with burst 16, which uses xmit_more, the rate is
unchanged and 15% above skb_tx_mpwqe off, so the gain of MPWQE is kept.
The price is that the regular path runs a little more code for a packet
than a single packet MPWQE does (mlx5e_sq_calc_wqe_attr(),
mlx5e_accel_tx_finish()); the packet rate above shows that it is more
than compensated.
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
---
pktgen, 64 B UDP packets, one TX queue, 30M packets per run, sender and
IRQs pinned, interrupt coalescing fixed, before -> after, in pps:
burst 1 (no xmit_more) 1493583 -> 1739855 (+16.5%)
burst 4 2578336 -> 2576508 (-0.1%)
burst 16 3235640 -> 3235746 (+0.0%)
After vs before, 3 boots, paired t-test over the boots (2 degrees of
freedom, so a low power), the change of each boot in brackets:
- burst 1: +16.5% (p<0.001) [+16.2 +15.9 +17.3]
- burst 4: -0.1% (p=0.86) [+0.6 -0.4 -0.5]
- burst 16: +0.0% (p=0.99) [+0.3 -0.0 -0.3]
With the patch, burst 1 is within 1% of skb_tx_mpwqe turned off (1752020
pps). With burst 4 and 16 turning it off is 1% and 13% slower (2550781
and 2810510 pps), so the gain of MPWQE for batches is kept.
Single packet MPWQEs, counted with tx*_mpwqe_blks and tx*_mpwqe_pkts:
with burst 1, before the patch mpwqe_blks and mpwqe_pkts are both
29993000 for 29993000 packets, after the patch they are 0. With burst 4
(7519017 blocks, 29972000 packets) and burst 16 (1984750 blocks, 29888000
packets) the counters are the same before and after.
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 14479da98f42..7c1fcd8fb294 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -646,6 +646,7 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5e_accel_tx_state accel = {};
+ bool xmit_more = netdev_xmit_more();
struct mlx5e_tx_wqe_attr wqe_attr;
struct mlx5e_tx_attr attr;
struct mlx5e_tx_wqe *wqe;
@@ -678,11 +679,13 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)
mlx5e_sq_xmit_prepare(sq, skb, &accel, &attr);
if (test_bit(MLX5E_SQ_STATE_MPWQE, &sq->state)) {
- if (mlx5e_tx_skb_supports_mpwqe(skb, &attr)) {
+ /* An MPWQE for a lone packet saves nothing, use a regular WQE. */
+ if (mlx5e_tx_skb_supports_mpwqe(skb, &attr) &&
+ (xmit_more || mlx5e_tx_mpwqe_session_is_active(sq))) {
struct mlx5_wqe_eth_seg eseg = {};
mlx5e_txwqe_build_eseg(priv, sq, skb, &accel, &eseg, attr.ihs);
- mlx5e_sq_xmit_mpwqe(sq, skb, &eseg, netdev_xmit_more());
+ mlx5e_sq_xmit_mpwqe(sq, skb, &eseg, xmit_more);
return NETDEV_TX_OK;
}
@@ -697,7 +700,7 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)
mlx5e_accel_tx_finish(sq, wqe, &accel,
(struct mlx5_wqe_inline_seg *)(wqe->data + wqe_attr.ds_cnt_inl));
mlx5e_txwqe_build_eseg(priv, sq, skb, &accel, &wqe->eth, attr.ihs);
- mlx5e_sq_xmit_wqe(sq, skb, &attr, &wqe_attr, wqe, pi, netdev_xmit_more());
+ mlx5e_sq_xmit_wqe(sq, skb, &attr, &wqe_attr, wqe, pi, xmit_more);
return NETDEV_TX_OK;
}
--
2.43.0
Technical Details
Message-ID:
<20261117085036.3138779-1-xuanqiang.luo@linux.dev>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365068-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365068-linux-kernel-netdev=dewy.ru From: xuanqiang.luo@linux.dev (Xuanqiang Luo) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v1] net/mlx5e: TX, Do not open a multi-packet WQE for a single packet Date: Tue, 17 Nov 2026 17:50:36 +0900 Organization: Usenet Network Message-ID: <20261117085036.3138779-1-xuanqiang.luo@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2283036"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:TCMF/HKu7MmZh77FLUELGrImZlY= sha256:Nl7yWByoP/Eak9vbL8V6ucGcmFRE8wDf63QsbCdMskI= sha1:kwNU5b8rffW563TBObCeFzEbxR0= sha256:QSfwVKwvhnCHnYDnnQpJMNsLqUFp74UX7xAc3EvfRtg= 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 351E7114EA3; Tue, 17 Nov 2026 11:51:18 +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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 (1024-bit key) header.d=linux.dev 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 7D7WVXP3emd9; Tue, 17 Nov 2026 11:51:11 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-365068-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B6C2C114E98; Tue, 17 Nov 2026 11:51:02 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 9AED82F4CA; Tue, 17 Nov 2026 08:51:01 +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=1794905461; b=uOJO/dD/Yn6lHRybRA/FADPcOiSOlVFNSYM8xSYWBK/V/06TpOgqnzNFqqknO6UChXUY mSK4hGaJpAh4vo4axE5y5tfEkMZnL/RmU+FliQxlrnA6bd8rHRmSg3a1ZDwJ4oWhdckih 5IXIF8eHhwhEwwQApoywmNbCnV8No375RGSDZfPb/zRw/bJWYT4GXcj+JHrh3t8HYE2ZW WchBQc7Uq6s04heS6uR8khBpg8DxNDnGGzOwRdTrasIPT2cOz+u7OoIh6cwe5DKSjVWns 4HyDSIiCTPP/ekCA4JgjAC+xKu4NXzMemcIb6NlMKfkxTPIoE849s3KH3r18hh+ov7A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794905461; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc: Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding; bh=kktxErXVA9vzSuKDfU/GwRl9jfNN1q0kNJMaIMx7e2g=; b=casd6gacdD6nL7Bq+OZLzXHM5/uia4cxEE3QXHEFcqW5cXOupQiAZGOVJyU/Ywni7rQF 7xnygKRkFrqIIeF3ts00xEWN2uJBdaMuqEQVwuTAju/D2OJhfNwRcH/V4ydV36pFpG9Nb J4X2F2Dc5Y+gURAHJ8mMKNjG5fTiIZ1aiMLez+jkPzbQ7r5UHNhOWDQYM1sUgs7af6YfG pkuoKsZ/nZ3myEs6+U7d140ENDV37Sx5wV13jNWiozTA0or+ZereQxPA4z3eb8vPFtFXA Xuoa/bEQLxtqdW5lo/DwzcKxodmbOrPLvt5LrJhkNNU59UmbcjtUOKdyi2t4icyNkXg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="iNTI1/jw"; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 0E6EE606A89E; Tue, 17 Nov 2026 08:51:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=iNTI1/jw X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.100 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794905460; b=PjY2m2l+Oc2Kcif0dH9cCyRzFgn33JvPplCRx0JUmFmr03wOGZ6SvcRf75Yu28Vyz206 S/a46R9PTn4frhY5P4yHCopp22nR7Oquq4uPs7dy8haMenpC81fyd5+DvY7nUSOGxOvRR YyzXgQOPTyUNExJ8TCfkgygfRQKpLI1g0cuM4TZS7AWi/S+++gvtwjbfaJS/ZBbsSK8IY xYYr6f9VevELxNR57pIeq+Qzcy84GN0kZykEQGnTRHMu+iGK9EBPJL/T5MWKvH7bjTloY J9ReVi1pgCOhcIUEBsMUB/9AQnzCEtXNG6jIPudIy1ggL4tP34HyMOVjxrvk/VH8ApA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794905460; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=kktxErXVA9vzSuKDfU/GwRl9jfNN1q0kNJMaIMx7e2g=; b=LCKGB4ZXd9tfB/a4Hs4MIVGN5XdpM6MAuBkfgwXws1dLVL7d2/bnTwhQui86SPrCySSN /O5mV0Tlp2dS/E2gNg/rIw51VuxV/5TU+N6sJpQU2QU8wCbYMvCoEJVxEHZJPrZsen4QP r/Uu69p+8VO3M2YRS6t4D0MjEXsxyx0xKDF1Hu+b/y6RPf2AndLvvEdJtJMpL/OK7f9uy 90PW8lyAQySPAEAeKrHOYWxR+QOYzs9rQCUNrqwZkgbh9PZByt3kt7wb6XNLRdUc/8vj6 H/0qW8abY72pAgh3DZpgOp94WTedYBnCXaPtKdmPTzuGX21bWq6V9YWLvkEaObHmerw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="iNTI1/jw"; arc=none smtp.remote-ip=95.215.58.100 X-Received: from mta1.migadu.com (out-100.mta1.migadu.com [95.215.58.100]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFDEB606A882 for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 08:50:58 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DFDEB606A882 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=frb27RcRWqYhKgZ/jRZ/7dmrrDCCd2Sc4xBQ+/xfsgo=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794905457; v=1; x=1795510257; b=iNTI1/jwwxCNfYGWarUAmQmm3CnIp51Ytf7U2n3sLJFrtwSileU0NwsknG3ErZWt2F4H2x7B ZNovzud09h6JqoxUdYBodErZHnw6ULZKBhvI+uyU6n94Pgpos/rLhgnah0KoQYm6Mgf3u87GXFz yfXZE9OJNfsWj1B1V1PRXKWc= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 747235d7d1053b67; Tue, 17 Nov 2026 08:50:57 +0000 X-Mizu-Trace-ID: 747235d7d1053b67 X-Migadu-Flow: FLOW_OUT X-Cc: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Xuanqiang Luo <luoxuanqiang@kylinos.cn> X-Mailer: git-send-email 2.43.0 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