From: Simon Horman <horms@kernel.org>
To: Praveen Kaligineedi <pkaligineedi@google.com>
Cc: netdev@vger.kernel.org, stable@kernel.org,
hramamurthy@google.com, jfraker@google.com, jeroendb@google.com,
shailend@google.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
ziweixiao@google.com, willemb@google.com,
Joshua Washington <joshwash@google.com>
Subject: Re: [PATCH net] gve: Fix XDP TX completion handling when counters overflow
Date: Wed, 17 Jul 2024 08:41:22 +0100 [thread overview]
Message-ID: <20240717074122.GH249423@kernel.org> (raw)
In-Reply-To: <20240716171041.1561142-1-pkaligineedi@google.com>
On Tue, Jul 16, 2024 at 10:10:41AM -0700, Praveen Kaligineedi wrote:
> From: Joshua Washington <joshwash@google.com>
>
> In gve_clean_xdp_done, the driver processes the TX completions based on
> a 32-bit NIC counter and a 32-bit completion counter stored in the tx
> queue.
>
> Fix the for loop so that the counter wraparound is handled correctly.
>
> Fixes: 75eaae158b1b ("gve: Add XDP DROP and TX support for GQI-QPL format")
> Signed-off-by: Joshua Washington <joshwash@google.com>
> Signed-off-by: Praveen Kaligineedi <pkaligineedi@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
> ---
> drivers/net/ethernet/google/gve/gve_tx.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c
> index 24a64ec1073e..e7fb7d6d283d 100644
> --- a/drivers/net/ethernet/google/gve/gve_tx.c
> +++ b/drivers/net/ethernet/google/gve/gve_tx.c
> @@ -158,15 +158,16 @@ static int gve_clean_xdp_done(struct gve_priv *priv, struct gve_tx_ring *tx,
> u32 to_do)
> {
> struct gve_tx_buffer_state *info;
> - u32 clean_end = tx->done + to_do;
> u64 pkts = 0, bytes = 0;
> size_t space_freed = 0;
> u32 xsk_complete = 0;
> u32 idx;
> + int i;
>
> - for (; tx->done < clean_end; tx->done++) {
> + for (i = 0; i < to_do; i++) {
I was slightly concerned that, as it is a u32, the value of to_do could
exceed the maximum value of i, which is an int.
But I see that in practice the value of to_do is bound by an int, budget,
in the call site, gve_xdp_poll. So I think we are ok.
Perhaps, as a clean up, the type of the to_do parameter of
gve_clean_xdp_done, and local variable in gve_xdp_poll() could be updated
from u32 to int. But, OTOH, perhaps that doesn't get us anywhere.
> idx = tx->done & tx->mask;
> info = &tx->info[idx];
> + tx->done++;
>
> if (unlikely(!info->xdp.size))
> continue;
> --
> 2.45.2.803.g4e1b14247a-goog
>
>
next prev parent reply other threads:[~2024-07-17 7:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 17:10 [PATCH net] gve: Fix XDP TX completion handling when counters overflow Praveen Kaligineedi
2024-07-17 7:41 ` Simon Horman [this message]
2024-07-18 5:30 ` 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=20240717074122.GH249423@kernel.org \
--to=horms@kernel.org \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=hramamurthy@google.com \
--cc=jeroendb@google.com \
--cc=jfraker@google.com \
--cc=john.fastabend@gmail.com \
--cc=joshwash@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pkaligineedi@google.com \
--cc=shailend@google.com \
--cc=stable@kernel.org \
--cc=willemb@google.com \
--cc=ziweixiao@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.