Skip to content

Commit 2a8bc53

Browse files
edumazetgregkh
authored andcommitted
bpf: add schedule points in percpu arrays management
[ upstream commit 32fff23 ] 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: a10423b ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 54c6d01 commit 2a8bc53

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

kernel/bpf/arraymap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ static void bpf_array_free_percpu(struct bpf_array *array)
2020
{
2121
int i;
2222

23-
for (i = 0; i < array->map.max_entries; i++)
23+
for (i = 0; i < array->map.max_entries; i++) {
2424
free_percpu(array->pptrs[i]);
25+
cond_resched();
26+
}
2527
}
2628

2729
static int bpf_array_alloc_percpu(struct bpf_array *array)
@@ -37,6 +39,7 @@ static int bpf_array_alloc_percpu(struct bpf_array *array)
3739
return -ENOMEM;
3840
}
3941
array->pptrs[i] = ptr;
42+
cond_resched();
4043
}
4144

4245
return 0;

0 commit comments

Comments
 (0)