Thread (38 messages) 38 messages, 5 authors, 2024-05-24

Re: [PATCH net-next 14/15 v2] net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.

From: Alexei Starovoitov <hidden>
Date: 2024-05-21 01:52:43
Also in: bpf, lkml

On Wed, May 15, 2024 at 6:43 AM Sebastian Andrzej Siewior
[off-list ref] wrote:
On 2024-05-14 13:54:43 [+0200], Toke Høiland-Jørgensen wrote:
quoted
quoted
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1504,6 +1505,8 @@ struct task_struct {
    /* Used for BPF run context */
    struct bpf_run_ctx              *bpf_ctx;
 #endif
+   /* Used by BPF for per-TASK xdp storage */
+   struct bpf_net_context          *bpf_net_context;
Okay, so if we are going the route of always putting this in 'current',
why not just embed the whole struct bpf_net_context inside task_struct,
instead of mucking about with the stack-allocated structures and
setting/clearing of pointers?
The whole struct bpf_net_context has 112 bytes. task_struct has 12352
bytes in my debug-config or 7296 bytes with defconfig on x86-64. Adding
it unconditionally would grow task_struct by ~1% but it would make
things way easier: The NULL case goes away, the assignment and cleanup
goes away, the INIT_LIST_HEAD can be moved to fork(). If the size
increase is not an issue then why not. Let me prepare…
I think 112 bytes or whatever the size of bpf_net_context is a bit
too much to consume in task_struct.
Yes, it's big, but there are systems with 1m threads. 112Mbyte is not
that small.
bpf_net_ctx_set/get are not in critical path and get_ri will be
inlined without any conditionals, so performance should be the same.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help