diff options
author | Eric Dumazet <edumazet@google.com> | 2018-02-22 11:33:24 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-02-22 15:27:06 -0500 |
commit | 32fff239de37ef226d5b66329dd133f64d63b22d (patch) | |
tree | 35ee0de8ea4ebaea6511622d12bbe177f5ed45e1 | |
parent | 80475c48c6a8a65171e035e0915dc7996b5a0a65 (diff) |
bpf: add schedule points in percpu arrays management
syszbot managed to trigger RCU detected stalls in
bpf_array_free_percpu()
It takes time to allocate a huge percpu map, but even more time to free
it.
Since we run in process context, use cond_resched() to yield cpu if
needed.
Fixes: a10423b87a7e ("bpf: introduce BPF_MAP_TYPE_PERCPU_ARRAY map")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | kernel/bpf/arraymap.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index a364c408f25a..14750e7c5ee4 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c | |||
@@ -26,8 +26,10 @@ static void bpf_array_free_percpu(struct bpf_array *array) | |||
26 | { | 26 | { |
27 | int i; | 27 | int i; |
28 | 28 | ||
29 | for (i = 0; i < array->map.max_entries; i++) | 29 | for (i = 0; i < array->map.max_entries; i++) { |
30 | free_percpu(array->pptrs[i]); | 30 | free_percpu(array->pptrs[i]); |
31 | cond_resched(); | ||
32 | } | ||
31 | } | 33 | } |
32 | 34 | ||
33 | static int bpf_array_alloc_percpu(struct bpf_array *array) | 35 | static int bpf_array_alloc_percpu(struct bpf_array *array) |
@@ -43,6 +45,7 @@ static int bpf_array_alloc_percpu(struct bpf_array *array) | |||
43 | return -ENOMEM; | 45 | return -ENOMEM; |
44 | } | 46 | } |
45 | array->pptrs[i] = ptr; | 47 | array->pptrs[i] = ptr; |
48 | cond_resched(); | ||
46 | } | 49 | } |
47 | 50 | ||
48 | return 0; | 51 | return 0; |