]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Avoid hashtab deadlock with map_locked
authorSong Liu <songliubraving@fb.com>
Thu, 29 Oct 2020 07:19:25 +0000 (00:19 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 30 Oct 2020 20:03:29 +0000 (13:03 -0700)
commit6c14b32046eeba2dd2e8b87345c80ad373a1e4ce
treed3a5f38e379c3a12c5592aeec15e1806e9a26403
parent47fd02b650dd307f8ff50f4cc0017584017ffa87
bpf: Avoid hashtab deadlock with map_locked

If a hashtab is accessed in both non-NMI and NMI context, the system may
deadlock on bucket->lock. Fix this issue with percpu counter map_locked.
map_locked rejects concurrent access to the same bucket from the same CPU.
To reduce memory overhead, map_locked is not added per bucket. Instead,
8 percpu counters are added to each hashtab. buckets are assigned to these
counters based on the lower bits of its hash.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201029071925.3103400-3-songliubraving@fb.com
kernel/bpf/hashtab.c