On 2024-05-14 13:54:43 [+0200], Toke Høiland-Jørgensen wrote: > > --- 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… > -Toke Sebastian