diff mbox series

[net] bpf: add schedule points to map alloc/free

Message ID 1513117359.25033.56.camel@gmail.com
State Accepted, archived
Delegated to: BPF Maintainers
Headers show
Series [net] bpf: add schedule points to map alloc/free | expand

Commit Message

Eric Dumazet Dec. 12, 2017, 10:22 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

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: Eric Dumazet <edumazet@google.com>
---
 kernel/bpf/hashtab.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Alexei Starovoitov Dec. 12, 2017, 11:33 p.m. UTC | #1
On Tue, Dec 12, 2017 at 02:22:39PM -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> 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: Eric Dumazet <edumazet@google.com>

Applied, thanks Eric!
diff mbox series

Patch

diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index e469e05c8e83bc3256378644e3f3c26555651261..3905d4bc5b80d74f0b8f9e2e8f8526a0115ce239 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -114,6 +114,7 @@  static void htab_free_elems(struct bpf_htab *htab)
 		pptr = htab_elem_get_ptr(get_htab_elem(htab, i),
 					 htab->map.key_size);
 		free_percpu(pptr);
+		cond_resched();
 	}
 free_elems:
 	bpf_map_area_free(htab->elems);
@@ -159,6 +160,7 @@  static int prealloc_init(struct bpf_htab *htab)
 			goto free_elems;
 		htab_elem_set_ptr(get_htab_elem(htab, i), htab->map.key_size,
 				  pptr);
+		cond_resched();
 	}
 
 skip_percpu_elems: