Skip to content

Commit

Permalink
bpf: add schedule points in percpu arrays management
Browse files Browse the repository at this point in the history
[ 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 <[email protected]>
Reported-by: syzbot <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Eric Dumazet authored and gregkh committed Mar 11, 2018
1 parent 03549a3 commit e1760b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/bpf/arraymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,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)
Expand All @@ -40,6 +42,7 @@ static int bpf_array_alloc_percpu(struct bpf_array *array)
return -ENOMEM;
}
array->pptrs[i] = ptr;
cond_resched();
}

return 0;
Expand Down

0 comments on commit e1760b3

Please sign in to comment.