From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: "Alexander Lobakin" <alexandr.lobakin@intel.com>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH bpf-next 1/6] ice: fix ice_tx_ring::xdp_tx_active underflow
Date: Fri, 10 Feb 2023 18:06:13 +0100 [thread overview]
Message-ID: <20230210170618.1973430-2-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20230210170618.1973430-1-alexandr.lobakin@intel.com>
xdp_tx_active is used to indicate whether an XDP ring has any %XDP_TX
frames queued to shortcut processing Tx cleaning for XSk-enabled queues.
When !XSk, it simply indicates whether the ring has any queued frames in
general.
It gets increased on each frame placed onto the ring and counts the
whole frame, not each frag. However, currently it gets decremented in
ice_clean_xdp_tx_buf(), which is called per each buffer, i.e. per each
frag. Thus, on completing multi-frag frames, an underflow happens.
Move the decrement to the outer function and do it once per frame, not
buf. Also, do that on the stack and update the ring counter after the
loop is done to save several cycles.
XSk rings are fine since there are no frags at the moment.
Fixes: 3246a10752a7 ("ice: Add support for XDP multi-buffer on Tx side")
Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
---
drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
index 9bbed3f14e42..d1a7171e618b 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
@@ -231,7 +231,6 @@ ice_clean_xdp_tx_buf(struct ice_tx_ring *xdp_ring, struct ice_tx_buf *tx_buf)
dma_unmap_single(xdp_ring->dev, dma_unmap_addr(tx_buf, dma),
dma_unmap_len(tx_buf, len), DMA_TO_DEVICE);
dma_unmap_len_set(tx_buf, len, 0);
- xdp_ring->xdp_tx_active--;
page_frag_free(tx_buf->raw_buf);
tx_buf->raw_buf = NULL;
}
@@ -246,8 +245,8 @@ static u32 ice_clean_xdp_irq(struct ice_tx_ring *xdp_ring)
u32 ntc = xdp_ring->next_to_clean;
struct ice_tx_desc *tx_desc;
u32 cnt = xdp_ring->count;
+ u32 frags, xdp_tx = 0;
u32 ready_frames = 0;
- u32 frags;
u32 idx;
u32 ret;
@@ -274,6 +273,7 @@ static u32 ice_clean_xdp_irq(struct ice_tx_ring *xdp_ring)
total_pkts++;
/* count head + frags */
ready_frames -= frags + 1;
+ xdp_tx++;
if (xdp_ring->xsk_pool)
xsk_buff_free(tx_buf->xdp);
@@ -295,6 +295,7 @@ static u32 ice_clean_xdp_irq(struct ice_tx_ring *xdp_ring)
tx_desc->cmd_type_offset_bsz = 0;
xdp_ring->next_to_clean = ntc;
+ xdp_ring->xdp_tx_active -= xdp_tx;
ice_update_tx_ring_stats(xdp_ring, total_pkts, total_bytes);
return ret;
--
2.39.1
next prev parent reply other threads:[~2023-02-10 17:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 17:06 [PATCH bpf-next 0/6] ice: post-mbuf fixes Alexander Lobakin
2023-02-10 17:06 ` Alexander Lobakin [this message]
2023-02-10 17:06 ` [PATCH bpf-next 2/6] ice: fix XDP Tx ring overrun Alexander Lobakin
2023-02-10 17:06 ` [PATCH bpf-next 3/6] ice: remove two impossible branches on XDP Tx cleaning Alexander Lobakin
2023-02-10 17:06 ` [PATCH bpf-next 4/6] ice: robustify cleaning/completing XDP Tx buffers Alexander Lobakin
2023-02-10 17:06 ` [PATCH bpf-next 5/6] ice: fix freeing XDP frames backed by Page Pool Alexander Lobakin
2023-02-10 17:06 ` [PATCH bpf-next 6/6] ice: micro-optimize .ndo_xdp_xmit() path Alexander Lobakin
2023-02-10 18:09 ` [PATCH bpf-next 0/6] ice: post-mbuf fixes Toke Høiland-Jørgensen
2023-02-13 14:53 ` Alexander Lobakin
2023-02-13 17:57 ` Maciej Fijalkowski
2023-02-13 18:21 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230210170618.1973430-2-alexandr.lobakin@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=hawk@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=song@kernel.org \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox