* [PATCH bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv
@ 2024-09-06 1:22 Daniel Xu
2024-09-10 8:48 ` Jesper Dangaard Brouer
2024-09-11 14:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Xu @ 2024-09-06 1:22 UTC (permalink / raw)
To: davem, ast, hawk, kuba, daniel, john.fastabend, andrii
Cc: martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf, haoluo,
jolsa, netdev, bpf, linux-kernel, lorenzo, aleksander.lobakin,
kernel-team
cpumap takes RX processing out of softirq and onto a separate kthread.
Since the kthread needs to be scheduled in order to run (versus softirq
which does not), we can theoretically experience extra latency if the
system is under load and the scheduler is being unfair to us.
Moving the tracepoint to before passing the skb list up the stack allows
users to more accurately measure enqueue/dequeue latency introduced by
cpumap via xdp:xdp_cpumap_enqueue and xdp:xdp_cpumap_kthread tracepoints.
f9419f7bd7a5 ("bpf: cpumap add tracepoints") which added the tracepoints
states that the intent behind them was for general observability and for
a feedback loop to see if the queues are being overwhelmed. This change
does not mess with either of those use cases but rather adds a third
one.
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
kernel/bpf/cpumap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index fbdf5a1aabfe..a2f46785ac3b 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -354,12 +354,14 @@ static int cpu_map_kthread_run(void *data)
list_add_tail(&skb->list, &list);
}
- netif_receive_skb_list(&list);
- /* Feedback loop via tracepoint */
+ /* Feedback loop via tracepoint.
+ * NB: keep before recv to allow measuring enqueue/dequeue latency.
+ */
trace_xdp_cpumap_kthread(rcpu->map_id, n, kmem_alloc_drops,
sched, &stats);
+ netif_receive_skb_list(&list);
local_bh_enable(); /* resched point, may call do_softirq() */
}
__set_current_state(TASK_RUNNING);
--
2.46.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv
2024-09-06 1:22 [PATCH bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv Daniel Xu
@ 2024-09-10 8:48 ` Jesper Dangaard Brouer
2024-09-11 14:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2024-09-10 8:48 UTC (permalink / raw)
To: Daniel Xu, davem, ast, kuba, daniel, john.fastabend, andrii
Cc: martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf, haoluo,
jolsa, netdev, bpf, linux-kernel, lorenzo, aleksander.lobakin,
kernel-team
On 06/09/2024 03.22, Daniel Xu wrote:
> cpumap takes RX processing out of softirq and onto a separate kthread.
> Since the kthread needs to be scheduled in order to run (versus softirq
> which does not), we can theoretically experience extra latency if the
> system is under load and the scheduler is being unfair to us.
>
> Moving the tracepoint to before passing the skb list up the stack allows
> users to more accurately measure enqueue/dequeue latency introduced by
> cpumap via xdp:xdp_cpumap_enqueue and xdp:xdp_cpumap_kthread tracepoints.
>
It makes sense for me to move this :-)
It actually fits my use-case even better.
> f9419f7bd7a5 ("bpf: cpumap add tracepoints") which added the tracepoints
> states that the intent behind them was for general observability and for
> a feedback loop to see if the queues are being overwhelmed. This change
> does not mess with either of those use cases but rather adds a third
> one.
Yes, my use-case is to this as a feedback loop, to see when queue is
overwhelmed as you say. I will soon be playing with this feature in
production environments, so I'm excited that it looks like you have
similar use-cases for this :-)
>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
> ---
> kernel/bpf/cpumap.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index fbdf5a1aabfe..a2f46785ac3b 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -354,12 +354,14 @@ static int cpu_map_kthread_run(void *data)
>
> list_add_tail(&skb->list, &list);
> }
> - netif_receive_skb_list(&list);
>
> - /* Feedback loop via tracepoint */
> + /* Feedback loop via tracepoint.
> + * NB: keep before recv to allow measuring enqueue/dequeue latency.
> + */
> trace_xdp_cpumap_kthread(rcpu->map_id, n, kmem_alloc_drops,
> sched, &stats);
>
> + netif_receive_skb_list(&list);
> local_bh_enable(); /* resched point, may call do_softirq() */
> }
> __set_current_state(TASK_RUNNING);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv
2024-09-06 1:22 [PATCH bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv Daniel Xu
2024-09-10 8:48 ` Jesper Dangaard Brouer
@ 2024-09-11 14:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-11 14:50 UTC (permalink / raw)
To: Daniel Xu
Cc: davem, ast, hawk, kuba, daniel, john.fastabend, andrii,
martin.lau, eddyz87, song, yonghong.song, kpsingh, sdf, haoluo,
jolsa, netdev, bpf, linux-kernel, lorenzo, aleksander.lobakin,
kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (net)
by Daniel Borkmann <daniel@iogearbox.net>:
On Thu, 5 Sep 2024 19:22:44 -0600 you wrote:
> cpumap takes RX processing out of softirq and onto a separate kthread.
> Since the kthread needs to be scheduled in order to run (versus softirq
> which does not), we can theoretically experience extra latency if the
> system is under load and the scheduler is being unfair to us.
>
> Moving the tracepoint to before passing the skb list up the stack allows
> users to more accurately measure enqueue/dequeue latency introduced by
> cpumap via xdp:xdp_cpumap_enqueue and xdp:xdp_cpumap_kthread tracepoints.
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv
https://git.kernel.org/bpf/bpf-next/c/23dc9867329c
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:[~2024-09-11 14:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 1:22 [PATCH bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv Daniel Xu
2024-09-10 8:48 ` Jesper Dangaard Brouer
2024-09-11 14:50 ` 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