* [PATCH] bpf: add schedule points in percpu arrays management
@ 2018-02-22 16:33 Eric Dumazet
2018-02-22 20:32 ` Daniel Borkmann
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2018-02-22 16:33 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
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>
---
kernel/bpf/arraymap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index a364c408f25a54a8175c92b6004a5e7e15f198cb..14750e7c5ee4872e4a7426e960bea7ae001e6623 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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bpf: add schedule points in percpu arrays management
2018-02-22 16:33 [PATCH] bpf: add schedule points in percpu arrays management Eric Dumazet
@ 2018-02-22 20:32 ` Daniel Borkmann
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2018-02-22 20:32 UTC (permalink / raw)
To: Eric Dumazet, Alexei Starovoitov; +Cc: netdev, dennisszhou
[ +Dennis for mm/pcpu ]
On 02/22/2018 05:33 PM, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> 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>
Applied to bpf tree, thanks Eric!
> ---
> kernel/bpf/arraymap.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
> index a364c408f25a54a8175c92b6004a5e7e15f198cb..14750e7c5ee4872e4a7426e960bea7ae001e6623 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;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-22 20:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 16:33 [PATCH] bpf: add schedule points in percpu arrays management Eric Dumazet
2018-02-22 20:32 ` Daniel Borkmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.