From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Daniel Xu <dxu@dxuuu.xyz>,
davem@davemloft.net, ast@kernel.org, kuba@kernel.org,
daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org
Cc: martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
lorenzo@kernel.org, aleksander.lobakin@intel.com,
kernel-team@meta.com
Subject: Re: [PATCH bpf-next] bpf: cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv
Date: Tue, 10 Sep 2024 10:48:03 +0200 [thread overview]
Message-ID: <e34bc47d-aada-4bf8-ac29-d3462f351f20@kernel.org> (raw)
In-Reply-To: <47615d5b5e302e4bd30220473779e98b492d47cd.1725585718.git.dxu@dxuuu.xyz>
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);
next prev parent reply other threads:[~2024-09-10 8:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-09-11 14:50 ` 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=e34bc47d-aada-4bf8-ac29-d3462f351f20@kernel.org \
--to=hawk@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dxu@dxuuu.xyz \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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