diff options
author | Martin KaFai Lau <kafai@fb.com> | 2017-08-18 14:28:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-20 00:35:43 -0400 |
commit | ad17d0e6c708805bf9e6686eb747cc528b702e67 (patch) | |
tree | d6350b4b468bb9ca5ebb40f73758af26ec36082f /tools/lib/bpf/bpf.c | |
parent | 96eabe7a40aa17e613cf3db2c742ee8b1fc764d0 (diff) |
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>
Diffstat (limited to 'tools/lib/bpf/bpf.c')
-rw-r--r-- | tools/lib/bpf/bpf.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 77660157a684..a0717610b116 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
@@ -57,8 +57,9 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, | |||
57 | return syscall(__NR_bpf, cmd, attr, size); | 57 | return syscall(__NR_bpf, cmd, attr, size); |
58 | } | 58 | } |
59 | 59 | ||
60 | int bpf_create_map(enum bpf_map_type map_type, int key_size, | 60 | int bpf_create_map_node(enum bpf_map_type map_type, int key_size, |
61 | int value_size, int max_entries, __u32 map_flags) | 61 | int value_size, int max_entries, __u32 map_flags, |
62 | int node) | ||
62 | { | 63 | { |
63 | union bpf_attr attr; | 64 | union bpf_attr attr; |
64 | 65 | ||
@@ -69,12 +70,24 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size, | |||
69 | attr.value_size = value_size; | 70 | attr.value_size = value_size; |
70 | attr.max_entries = max_entries; | 71 | attr.max_entries = max_entries; |
71 | attr.map_flags = map_flags; | 72 | attr.map_flags = map_flags; |
73 | if (node >= 0) { | ||
74 | attr.map_flags |= BPF_F_NUMA_NODE; | ||
75 | attr.numa_node = node; | ||
76 | } | ||
72 | 77 | ||
73 | return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); | 78 | return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); |
74 | } | 79 | } |
75 | 80 | ||
76 | int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size, | 81 | int bpf_create_map(enum bpf_map_type map_type, int key_size, |
77 | int inner_map_fd, int max_entries, __u32 map_flags) | 82 | int value_size, int max_entries, __u32 map_flags) |
83 | { | ||
84 | return bpf_create_map_node(map_type, key_size, value_size, | ||
85 | max_entries, map_flags, -1); | ||
86 | } | ||
87 | |||
88 | int bpf_create_map_in_map_node(enum bpf_map_type map_type, int key_size, | ||
89 | int inner_map_fd, int max_entries, | ||
90 | __u32 map_flags, int node) | ||
78 | { | 91 | { |
79 | union bpf_attr attr; | 92 | union bpf_attr attr; |
80 | 93 | ||
@@ -86,10 +99,21 @@ int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size, | |||
86 | attr.inner_map_fd = inner_map_fd; | 99 | attr.inner_map_fd = inner_map_fd; |
87 | attr.max_entries = max_entries; | 100 | attr.max_entries = max_entries; |
88 | attr.map_flags = map_flags; | 101 | attr.map_flags = map_flags; |
102 | if (node >= 0) { | ||
103 | attr.map_flags |= BPF_F_NUMA_NODE; | ||
104 | attr.numa_node = node; | ||
105 | } | ||
89 | 106 | ||
90 | return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); | 107 | return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); |
91 | } | 108 | } |
92 | 109 | ||
110 | int bpf_create_map_in_map(enum bpf_map_type map_type, int key_size, | ||
111 | int inner_map_fd, int max_entries, __u32 map_flags) | ||
112 | { | ||
113 | return bpf_create_map_in_map_node(map_type, key_size, inner_map_fd, | ||
114 | max_entries, map_flags, -1); | ||
115 | } | ||
116 | |||
93 | int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 117 | int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, |
94 | size_t insns_cnt, const char *license, | 118 | size_t insns_cnt, const char *license, |
95 | __u32 kern_version, char *log_buf, size_t log_buf_sz) | 119 | __u32 kern_version, char *log_buf, size_t log_buf_sz) |