From: Hou Tao <houtao1@xxxxxxxxxx> Use BPF_MA_NO_REUSE in htab map to disable the immediate reuse of free elements, so the lookup procedure will not return incorrect result. After the change, the performance of "./map_perf_test 4 18 8192" will drop from 520K to 330K events per sec on one CPU. Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> --- kernel/bpf/hashtab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index 623111d4276d..e1636c5d0051 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -574,14 +574,14 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) goto free_prealloc; } } else { - err = bpf_mem_alloc_init(&htab->ma, htab->elem_size, 0, + err = bpf_mem_alloc_init(&htab->ma, htab->elem_size, BPF_MA_NO_REUSE, htab_elem_ctor); if (err) goto free_map_locked; if (percpu) { err = bpf_mem_alloc_init(&htab->pcpu_ma, round_up(htab->map.value_size, 8), - BPF_MA_PERCPU, NULL); + BPF_MA_PERCPU | BPF_MA_NO_REUSE, NULL); if (err) goto free_map_locked; } -- 2.29.2