]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Provide recursion prevention helpers
authorThomas Gleixner <tglx@linutronix.de>
Mon, 24 Feb 2020 14:01:47 +0000 (15:01 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Feb 2020 00:20:09 +0000 (16:20 -0800)
commit1be10e012c65a83e770fde1485a8f5a1ec35741d
treedc1af99817725ada8e5cae4c91e49dd113d41d0b
parent4087d78fde26e63e0b42733397ec5f6809af5788
bpf: Provide recursion prevention helpers

The places which need to prevent the execution of trace type BPF programs
to prevent deadlocks on the hash bucket lock do this open coded.

Provide two inline functions, bpf_disable/enable_instrumentation() to
replace these open coded protection constructs.

Use migrate_disable/enable() instead of preempt_disable/enable() right away
so this works on RT enabled kernels. On a !RT kernel migrate_disable /
enable() are mapped to preempt_disable/enable().

These helpers use this_cpu_inc/dec() instead of __this_cpu_inc/dec() on an
RT enabled kernel because migrate disabled regions are preemptible and
preemption might hit in the middle of a RMW operation which can lead to
inconsistent state.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200224145644.103910133@linutronix.de
include/linux/bpf.h