lkml.org 
[lkml]   [2022]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: BUG: unable to handle kernel paging request in bpf_dispatcher_xdp
On Fri, Dec 09, 2022 at 03:34:45PM -0800, Jakub Kicinski wrote:
> On Sat, 10 Dec 2022 00:32:07 +0100 Daniel Borkmann wrote:
> > fwiw, these should not be necessary, Documentation/RCU/checklist.rst :
> >
> > [...] One example of non-obvious pairing is the XDP feature in networking,
> > which calls BPF programs from network-driver NAPI (softirq) context. BPF
> > relies heavily on RCU protection for its data structures, but because the
> > BPF program invocation happens entirely within a single local_bh_disable()
> > section in a NAPI poll cycle, this usage is safe. The reason that this usage
> > is safe is that readers can use anything that disables BH when updaters use
> > call_rcu() or synchronize_rcu(). [...]
>
> FWIW I sent a link to the thread to Paul and he confirmed
> the RCU will wait for just the BH.

so IIUC we can omit the rcu_read_lock/unlock on bpf_prog_run_xdp side

Paul,
any thoughts on what we can use in here to synchronize bpf_dispatcher_change_prog
with bpf_prog_run_xdp callers?

with synchronize_rcu_tasks I'm getting splats like:
https://lore.kernel.org/bpf/20221209153445.22182ca5@kernel.org/T/#m0a869f93404a2744884d922bc96d497ffe8f579f

synchronize_rcu_tasks_rude seems to work (patch below), but it also sounds special ;-)

thanks,
jirka


---
diff --git a/kernel/bpf/dispatcher.c b/kernel/bpf/dispatcher.c
index c19719f48ce0..e6126f07e85b 100644
--- a/kernel/bpf/dispatcher.c
+++ b/kernel/bpf/dispatcher.c
@@ -124,6 +124,7 @@ static void bpf_dispatcher_update(struct bpf_dispatcher *d, int prev_num_progs)
}

__BPF_DISPATCHER_UPDATE(d, new ?: (void *)&bpf_dispatcher_nop_func);
+ synchronize_rcu_tasks_rude();

if (new)
d->image_off = noff;
\
 
 \ /
  Last update: 2022-12-10 01:07    [W:0.059 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site