From: Eric Dumazet Date: Thu, 22 Feb 2018 16:33:24 +0000 (-0800) Subject: bpf: add schedule points in percpu arrays management X-Git-Tag: v4.19~1526^2~1^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32fff239de37ef226d5b66329dd133f64d63b22d;p=platform%2Fkernel%2Flinux-rpi.git 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 Reported-by: syzbot Signed-off-by: Daniel Borkmann --- diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index a364c40..14750e7 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) { int i; - for (i = 0; i < array->map.max_entries; i++) + for (i = 0; i < array->map.max_entries; i++) { free_percpu(array->pptrs[i]); + cond_resched(); + } } static int bpf_array_alloc_percpu(struct bpf_array *array) @@ -43,6 +45,7 @@ static int bpf_array_alloc_percpu(struct bpf_array *array) return -ENOMEM; } array->pptrs[i] = ptr; + cond_resched(); } return 0;