Blob Blame History Raw
From: Eric Dumazet <edumazet@google.com>
Date: Tue, 12 Dec 2017 14:22:39 -0800
Subject: bpf: add schedule points to map alloc/free
Patch-mainline: v4.15-rc4
Git-commit: 9147efcbe0b7cc96b18eb64b1a3f0d4bba81443c
References: bsc#1083647

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>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Gary Lin <glin@suse.com>
---
 kernel/bpf/hashtab.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -110,6 +110,7 @@ static void htab_free_elems(struct bpf_h
 		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);
@@ -154,6 +155,7 @@ static int prealloc_init(struct bpf_htab
 			goto free_elems;
 		htab_elem_set_ptr(get_htab_elem(htab, i), htab->map.key_size,
 				  pptr);
+		cond_resched();
 	}
 
 skip_percpu_elems: