提交 9147efcb 编写于 作者: E Eric Dumazet 提交者: Alexei Starovoitov

bpf: add schedule points to map alloc/free

While using large percpu maps, htab_map_alloc() can hold
cpu for hundreds of ms.

This patch adds cond_resched() calls to percpu alloc/free
call sites, all running in process context.
Signed-off-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 9dbd2d94
...@@ -114,6 +114,7 @@ static void htab_free_elems(struct bpf_htab *htab) ...@@ -114,6 +114,7 @@ static void htab_free_elems(struct bpf_htab *htab)
pptr = htab_elem_get_ptr(get_htab_elem(htab, i), pptr = htab_elem_get_ptr(get_htab_elem(htab, i),
htab->map.key_size); htab->map.key_size);
free_percpu(pptr); free_percpu(pptr);
cond_resched();
} }
free_elems: free_elems:
bpf_map_area_free(htab->elems); bpf_map_area_free(htab->elems);
...@@ -159,6 +160,7 @@ static int prealloc_init(struct bpf_htab *htab) ...@@ -159,6 +160,7 @@ static int prealloc_init(struct bpf_htab *htab)
goto free_elems; goto free_elems;
htab_elem_set_ptr(get_htab_elem(htab, i), htab->map.key_size, htab_elem_set_ptr(get_htab_elem(htab, i), htab->map.key_size,
pptr); pptr);
cond_resched();
} }
skip_percpu_elems: skip_percpu_elems:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册