Re: [PATCH net-next 14/15] net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: 2024-05-07 12:36:39
Also in:
bpf, lkml
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: 2024-05-07 12:36:39
Also in:
bpf, lkml
On 2024-05-06 16:09:47 [-0700], Alexei Starovoitov wrote:
quoted
quoted
On PREEMPT_RT the pointer to bpf_net_context is saved task's task_struct. On non-PREEMPT_RT builds the pointer saved in a per-CPU variable (which is always NODE-local memory). Using always the bpf_net_context approach has the advantage that there is almost zero differences between PREEMPT_RT and non-PREEMPT_RT builds.Did you ever manage to get any performance data to see if this has an impact? [...]quoted
+static inline struct bpf_net_context *bpf_net_ctx_get(void) +{ + struct bpf_net_context *bpf_net_ctx = this_cpu_read(bpf_net_context); + + WARN_ON_ONCE(!bpf_net_ctx);If we have this WARN...quoted
+static inline struct bpf_redirect_info *bpf_net_ctx_get_ri(void) +{ + struct bpf_net_context *bpf_net_ctx = bpf_net_ctx_get(); + + if (!bpf_net_ctx) + return NULL;... do we really need all the NULL checks?Indeed. Let's drop all NULL checks, since they definitely add overhead. I'd also remove ifdef CONFIG_PREEMPT_RT and converge on single implementation: static inline struct bpf_net_context * bpf_net_ctx_get(void) { return current->bpf_net_context; }
Okay, let me do that then. Sebastian