]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, lpm: Make locking RT friendly
authorThomas Gleixner <tglx@linutronix.de>
Mon, 24 Feb 2020 14:01:52 +0000 (15:01 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Feb 2020 00:20:10 +0000 (16:20 -0800)
commitea84c32eca401c6fc8ea7c116708dc1b821431ec
tree0d39c932913bd7bd18238e6cdd60393292c0a0c7
parentcb777b3d6b5f5702b90ac0d86dcc561754ae450a
bpf, lpm: Make locking RT friendly

The LPM trie map cannot be used in contexts like perf, kprobes and tracing
as this map type dynamically allocates memory.

The memory allocation happens with a raw spinlock held which is a truly
spinning lock on a PREEMPT RT enabled kernel which disables preemption and
interrupts.

As RT does not allow memory allocation from such a section for various
reasons, convert the raw spinlock to a regular spinlock.

On a RT enabled kernel these locks are substituted by 'sleeping' spinlocks
which provide the proper protection but keep the code preemptible.

On a non-RT kernel regular spinlocks map to raw spinlocks, i.e. this does
not cause any functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200224145644.602129531@linutronix.de
kernel/bpf/lpm_trie.c