bpf: Allow numa selection in INNER_LRU_HASH_PREALLOC test of map_perf_test
This patch makes the needed changes to allow each process of the INNER_LRU_HASH_PREALLOC test to provide its numa node id when creating the lru map. Signed-off-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
96eabe7a40
commit
ad17d0e6c7
@@ -201,7 +201,7 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
|
||||
static int load_maps(struct bpf_map_data *maps, int nr_maps,
|
||||
fixup_map_cb fixup_map)
|
||||
{
|
||||
int i;
|
||||
int i, numa_node;
|
||||
|
||||
for (i = 0; i < nr_maps; i++) {
|
||||
if (fixup_map) {
|
||||
@@ -213,21 +213,26 @@ static int load_maps(struct bpf_map_data *maps, int nr_maps,
|
||||
}
|
||||
}
|
||||
|
||||
numa_node = maps[i].def.map_flags & BPF_F_NUMA_NODE ?
|
||||
maps[i].def.numa_node : -1;
|
||||
|
||||
if (maps[i].def.type == BPF_MAP_TYPE_ARRAY_OF_MAPS ||
|
||||
maps[i].def.type == BPF_MAP_TYPE_HASH_OF_MAPS) {
|
||||
int inner_map_fd = map_fd[maps[i].def.inner_map_idx];
|
||||
|
||||
map_fd[i] = bpf_create_map_in_map(maps[i].def.type,
|
||||
map_fd[i] = bpf_create_map_in_map_node(maps[i].def.type,
|
||||
maps[i].def.key_size,
|
||||
inner_map_fd,
|
||||
maps[i].def.max_entries,
|
||||
maps[i].def.map_flags);
|
||||
maps[i].def.map_flags,
|
||||
numa_node);
|
||||
} else {
|
||||
map_fd[i] = bpf_create_map(maps[i].def.type,
|
||||
maps[i].def.key_size,
|
||||
maps[i].def.value_size,
|
||||
maps[i].def.max_entries,
|
||||
maps[i].def.map_flags);
|
||||
map_fd[i] = bpf_create_map_node(maps[i].def.type,
|
||||
maps[i].def.key_size,
|
||||
maps[i].def.value_size,
|
||||
maps[i].def.max_entries,
|
||||
maps[i].def.map_flags,
|
||||
numa_node);
|
||||
}
|
||||
if (map_fd[i] < 0) {
|
||||
printf("failed to create a map: %d %s\n",
|
||||
|
@@ -13,6 +13,7 @@ struct bpf_map_def {
|
||||
unsigned int max_entries;
|
||||
unsigned int map_flags;
|
||||
unsigned int inner_map_idx;
|
||||
unsigned int numa_node;
|
||||
};
|
||||
|
||||
struct bpf_map_data {
|
||||
|
@@ -40,6 +40,8 @@ struct bpf_map_def SEC("maps") inner_lru_hash_map = {
|
||||
.key_size = sizeof(u32),
|
||||
.value_size = sizeof(long),
|
||||
.max_entries = MAX_ENTRIES,
|
||||
.map_flags = BPF_F_NUMA_NODE,
|
||||
.numa_node = 0,
|
||||
};
|
||||
|
||||
struct bpf_map_def SEC("maps") array_of_lru_hashs = {
|
||||
|
@@ -97,14 +97,20 @@ static void do_test_lru(enum test_type test, int cpu)
|
||||
|
||||
if (test == INNER_LRU_HASH_PREALLOC) {
|
||||
int outer_fd = map_fd[array_of_lru_hashs_idx];
|
||||
unsigned int mycpu, mynode;
|
||||
|
||||
assert(cpu < MAX_NR_CPUS);
|
||||
|
||||
if (cpu) {
|
||||
ret = syscall(__NR_getcpu, &mycpu, &mynode, NULL);
|
||||
assert(!ret);
|
||||
|
||||
inner_lru_map_fds[cpu] =
|
||||
bpf_create_map(BPF_MAP_TYPE_LRU_HASH,
|
||||
sizeof(uint32_t), sizeof(long),
|
||||
inner_lru_hash_size, 0);
|
||||
bpf_create_map_node(BPF_MAP_TYPE_LRU_HASH,
|
||||
sizeof(uint32_t),
|
||||
sizeof(long),
|
||||
inner_lru_hash_size, 0,
|
||||
mynode);
|
||||
if (inner_lru_map_fds[cpu] == -1) {
|
||||
printf("cannot create BPF_MAP_TYPE_LRU_HASH %s(%d)\n",
|
||||
strerror(errno), errno);
|
||||
|
Reference in New Issue
Block a user