mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-15 14:32:06 +00:00
Add test cases to verify the following four update operations on htab of maps don't trigger lockdep warning: (1) add then delete (2) add, overwrite, then delete (3) add, then lookup_and_delete (4) add two elements, then lookup_and_delete_batch Test cases are added for pre-allocated and non-preallocated htab of maps respectively. Signed-off-by: Hou Tao <houtao1@huawei.com> Link: https://lore.kernel.org/r/20241106063542.357743-4-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
31 lines
764 B
C
31 lines
764 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (C) 2024. Huawei Technologies Co., Ltd */
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
struct inner_map_type {
|
|
__uint(type, BPF_MAP_TYPE_ARRAY);
|
|
__uint(key_size, 4);
|
|
__uint(value_size, 4);
|
|
__uint(max_entries, 1);
|
|
} inner_map SEC(".maps");
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
|
|
__type(key, int);
|
|
__type(value, int);
|
|
__uint(max_entries, 2);
|
|
__array(values, struct inner_map_type);
|
|
} outer_htab_map SEC(".maps");
|
|
|
|
struct {
|
|
__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
|
|
__uint(map_flags, BPF_F_NO_PREALLOC);
|
|
__type(key, int);
|
|
__type(value, int);
|
|
__uint(max_entries, 2);
|
|
__array(values, struct inner_map_type);
|
|
} outer_alloc_htab_map SEC(".maps");
|
|
|
|
char _license[] SEC("license") = "GPL";
|