Skip to content

Commit 23dc986

Browse files
danobiborkmann
authored andcommitted
bpf, cpumap: Move xdp:xdp_cpumap_kthread tracepoint before rcv
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. f9419f7 ("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 <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Jesper Dangaard Brouer <[email protected]> Link: https://lore.kernel.org/bpf/47615d5b5e302e4bd30220473779e98b492d47cd.1725585718.git.dxu@dxuuu.xyz
1 parent d41905b commit 23dc986

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/bpf/cpumap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,14 @@ static int cpu_map_kthread_run(void *data)
354354

355355
list_add_tail(&skb->list, &list);
356356
}
357-
netif_receive_skb_list(&list);
358357

359-
/* Feedback loop via tracepoint */
358+
/* Feedback loop via tracepoint.
359+
* NB: keep before recv to allow measuring enqueue/dequeue latency.
360+
*/
360361
trace_xdp_cpumap_kthread(rcpu->map_id, n, kmem_alloc_drops,
361362
sched, &stats);
362363

364+
netif_receive_skb_list(&list);
363365
local_bh_enable(); /* resched point, may call do_softirq() */
364366
}
365367
__set_current_state(TASK_RUNNING);

0 commit comments

Comments
 (0)