linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf/devmap: remove drops variable from bq_xmit_all()
@ 2021-05-28  2:43 Hangbin Liu
  2021-05-28  4:02 ` John Fastabend
  2021-05-28 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Hangbin Liu @ 2021-05-28  2:43 UTC (permalink / raw)
  To: bpf
  Cc: Daniel Borkmann, Toke Høiland-Jørgensen,
	John Fastabend, linux-kernel, netdev, Jesper Dangaard Brouer,
	Hangbin Liu

As Colin pointed out, the first drops assignment after declaration will
be overwritten by the second drops assignment before using, which makes
it useless.

Since the drops variable will be used only once. Just remove it and
use "cnt - sent" in trace_xdp_devmap_xmit()

Reported-by: Colin Ian King <colin.king@canonical.com>
Fixes: cb261b594b41 ("bpf: Run devmap xdp_prog on flush instead of bulk enqueue")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 kernel/bpf/devmap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index f9148daab0e3..2a75e6c2d27d 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -370,8 +370,8 @@ static int dev_map_bpf_prog_run(struct bpf_prog *xdp_prog,
 static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
 {
 	struct net_device *dev = bq->dev;
-	int sent = 0, drops = 0, err = 0;
 	unsigned int cnt = bq->count;
+	int sent = 0, err = 0;
 	int to_send = cnt;
 	int i;
 
@@ -388,8 +388,6 @@ static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
 		to_send = dev_map_bpf_prog_run(bq->xdp_prog, bq->q, cnt, dev);
 		if (!to_send)
 			goto out;
-
-		drops = cnt - to_send;
 	}
 
 	sent = dev->netdev_ops->ndo_xdp_xmit(dev, to_send, bq->q, flags);
@@ -408,9 +406,8 @@ static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
 		xdp_return_frame_rx_napi(bq->q[i]);
 
 out:
-	drops = cnt - sent;
 	bq->count = 0;
-	trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, drops, err);
+	trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, cnt - sent, err);
 }
 
 /* __dev_flush is called from xdp_do_flush() which _must_ be signaled
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH bpf-next] bpf/devmap: remove drops variable from bq_xmit_all()
  2021-05-28  2:43 [PATCH bpf-next] bpf/devmap: remove drops variable from bq_xmit_all() Hangbin Liu
@ 2021-05-28  4:02 ` John Fastabend
  2021-05-28 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: John Fastabend @ 2021-05-28  4:02 UTC (permalink / raw)
  To: Hangbin Liu, bpf
  Cc: Daniel Borkmann, Toke Høiland-Jørgensen,
	John Fastabend, linux-kernel, netdev, Jesper Dangaard Brouer,
	Hangbin Liu

Hangbin Liu wrote:
> As Colin pointed out, the first drops assignment after declaration will
> be overwritten by the second drops assignment before using, which makes
> it useless.
> 
> Since the drops variable will be used only once. Just remove it and
> use "cnt - sent" in trace_xdp_devmap_xmit()
> 
> Reported-by: Colin Ian King <colin.king@canonical.com>
> Fixes: cb261b594b41 ("bpf: Run devmap xdp_prog on flush instead of bulk enqueue")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  kernel/bpf/devmap.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 

Thanks

Acked-by: John Fastabend <john.fastabend@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] bpf/devmap: remove drops variable from bq_xmit_all()
  2021-05-28  2:43 [PATCH bpf-next] bpf/devmap: remove drops variable from bq_xmit_all() Hangbin Liu
  2021-05-28  4:02 ` John Fastabend
@ 2021-05-28 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-28 20:20 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: bpf, daniel, toke, john.fastabend, linux-kernel, netdev, brouer

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Thu, 27 May 2021 22:43:56 -0400 you wrote:
> As Colin pointed out, the first drops assignment after declaration will
> be overwritten by the second drops assignment before using, which makes
> it useless.
> 
> Since the drops variable will be used only once. Just remove it and
> use "cnt - sent" in trace_xdp_devmap_xmit()
> 
> [...]

Here is the summary with links:
  - [bpf-next] bpf/devmap: remove drops variable from bq_xmit_all()
    https://git.kernel.org/bpf/bpf-next/c/e8e0f0f48478

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-28 20:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28  2:43 [PATCH bpf-next] bpf/devmap: remove drops variable from bq_xmit_all() Hangbin Liu
2021-05-28  4:02 ` John Fastabend
2021-05-28 20:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).