]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Allow RCU-protected lookups to happen from bh context
authorToke Høiland-Jørgensen <toke@redhat.com>
Thu, 24 Jun 2021 16:05:54 +0000 (18:05 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 24 Jun 2021 17:41:15 +0000 (19:41 +0200)
commit0a169e75c3918cc50694e963c458066015601be3
treebe068946c3b7fd801c7d8854947c4d090de9896b
parentecd9bdcea579e4fa2bb5522a48ca8200d9d4b64a
bpf: Allow RCU-protected lookups to happen from bh context

XDP programs are called from a NAPI poll context, which means the RCU
reference liveness is ensured by local_bh_disable(). Add
rcu_read_lock_bh_held() as a condition to the RCU checks for map lookups so
lockdep understands that the dereferences are safe from inside *either* an
rcu_read_lock() section *or* a local_bh_disable() section. While both
bh_disabled and rcu_read_lock() provide RCU protection, they are
semantically distinct, so we need both conditions to prevent lockdep
complaints.

This change is done in preparation for removing the redundant
rcu_read_lock()s from drivers.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20210624160609.292325-5-toke@redhat.com
kernel/bpf/hashtab.c
kernel/bpf/helpers.c
kernel/bpf/lpm_trie.c