blob: fe5564bff39b9004f0143ba5b59558180f830756 [file] [log] [blame]
Thomas Gleixner25763b32019-05-28 10:10:09 -07001// SPDX-License-Identifier: GPL-2.0-only
Alexei Starovoitov26e90932016-03-08 15:07:54 -08002/* Copyright (c) 2016 Facebook
Alexei Starovoitov26e90932016-03-08 15:07:54 -08003 */
4#define _GNU_SOURCE
5#include <sched.h>
6#include <stdio.h>
7#include <sys/types.h>
8#include <asm/unistd.h>
9#include <unistd.h>
10#include <assert.h>
11#include <sys/wait.h>
12#include <stdlib.h>
13#include <signal.h>
14#include <linux/bpf.h>
15#include <string.h>
16#include <time.h>
Naveen N. Rao77e63532016-04-04 22:31:32 +053017#include <sys/resource.h>
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -070018#include <arpa/inet.h>
19#include <errno.h>
20
Jakub Kicinski2bf3e2e2018-05-14 22:35:02 -070021#include <bpf/bpf.h>
Alexei Starovoitov26e90932016-03-08 15:07:54 -080022#include "bpf_load.h"
23
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070024#define TEST_BIT(t) (1U << (t))
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -070025#define MAX_NR_CPUS 1024
Alexei Starovoitov26e90932016-03-08 15:07:54 -080026
27static __u64 time_get_ns(void)
28{
29 struct timespec ts;
30
31 clock_gettime(CLOCK_MONOTONIC, &ts);
32 return ts.tv_sec * 1000000000ull + ts.tv_nsec;
33}
34
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070035enum test_type {
36 HASH_PREALLOC,
37 PERCPU_HASH_PREALLOC,
38 HASH_KMALLOC,
39 PERCPU_HASH_KMALLOC,
40 LRU_HASH_PREALLOC,
41 NOCOMMON_LRU_HASH_PREALLOC,
42 LPM_KMALLOC,
43 HASH_LOOKUP,
44 ARRAY_LOOKUP,
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -070045 INNER_LRU_HASH_PREALLOC,
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -070046 LRU_HASH_LOOKUP,
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070047 NR_TESTS,
48};
49
50const char *test_map_names[NR_TESTS] = {
51 [HASH_PREALLOC] = "hash_map",
52 [PERCPU_HASH_PREALLOC] = "percpu_hash_map",
53 [HASH_KMALLOC] = "hash_map_alloc",
54 [PERCPU_HASH_KMALLOC] = "percpu_hash_map_alloc",
55 [LRU_HASH_PREALLOC] = "lru_hash_map",
56 [NOCOMMON_LRU_HASH_PREALLOC] = "nocommon_lru_hash_map",
57 [LPM_KMALLOC] = "lpm_trie_map_alloc",
58 [HASH_LOOKUP] = "hash_map",
59 [ARRAY_LOOKUP] = "array_map",
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -070060 [INNER_LRU_HASH_PREALLOC] = "inner_lru_hash_map",
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -070061 [LRU_HASH_LOOKUP] = "lru_hash_lookup_map",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070062};
Alexei Starovoitov26e90932016-03-08 15:07:54 -080063
64static int test_flags = ~0;
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070065static uint32_t num_map_entries;
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -070066static uint32_t inner_lru_hash_size;
67static int inner_lru_hash_idx = -1;
68static int array_of_lru_hashs_idx = -1;
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -070069static int lru_hash_lookup_idx = -1;
70static int lru_hash_lookup_test_entries = 32;
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070071static uint32_t max_cnt = 1000000;
72
73static int check_test_flags(enum test_type t)
74{
75 return test_flags & TEST_BIT(t);
76}
Alexei Starovoitov26e90932016-03-08 15:07:54 -080077
78static void test_hash_prealloc(int cpu)
79{
80 __u64 start_time;
81 int i;
82
83 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070084 for (i = 0; i < max_cnt; i++)
Alexei Starovoitov26e90932016-03-08 15:07:54 -080085 syscall(__NR_getuid);
86 printf("%d:hash_map_perf pre-alloc %lld events per sec\n",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -070087 cpu, max_cnt * 1000000000ll / (time_get_ns() - start_time));
Alexei Starovoitov26e90932016-03-08 15:07:54 -080088}
89
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -070090static int pre_test_lru_hash_lookup(int tasks)
91{
92 int fd = map_fd[lru_hash_lookup_idx];
93 uint32_t key;
94 long val = 1;
95 int ret;
96
97 if (num_map_entries > lru_hash_lookup_test_entries)
98 lru_hash_lookup_test_entries = num_map_entries;
99
100 /* Populate the lru_hash_map for LRU_HASH_LOOKUP perf test.
101 *
102 * It is fine that the user requests for a map with
103 * num_map_entries < 32 and some of the later lru hash lookup
104 * may return not found. For LRU map, we are not interested
105 * in such small map performance.
106 */
107 for (key = 0; key < lru_hash_lookup_test_entries; key++) {
108 ret = bpf_map_update_elem(fd, &key, &val, BPF_NOEXIST);
109 if (ret)
110 return ret;
111 }
112
113 return 0;
114}
115
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700116static void do_test_lru(enum test_type test, int cpu)
Martin KaFai Lau5db58fa2016-11-11 10:55:11 -0800117{
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700118 static int inner_lru_map_fds[MAX_NR_CPUS];
119
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700120 struct sockaddr_in6 in6 = { .sin6_family = AF_INET6 };
121 const char *test_name;
Martin KaFai Lau5db58fa2016-11-11 10:55:11 -0800122 __u64 start_time;
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700123 int i, ret;
124
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700125 if (test == INNER_LRU_HASH_PREALLOC) {
126 int outer_fd = map_fd[array_of_lru_hashs_idx];
Martin KaFai Lauad17d0e2017-08-18 11:28:01 -0700127 unsigned int mycpu, mynode;
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700128
129 assert(cpu < MAX_NR_CPUS);
130
131 if (cpu) {
Martin KaFai Lauad17d0e2017-08-18 11:28:01 -0700132 ret = syscall(__NR_getcpu, &mycpu, &mynode, NULL);
133 assert(!ret);
134
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700135 inner_lru_map_fds[cpu] =
Martin KaFai Lauad17d0e2017-08-18 11:28:01 -0700136 bpf_create_map_node(BPF_MAP_TYPE_LRU_HASH,
Martin KaFai Lau88cda1c2017-09-27 14:37:54 -0700137 test_map_names[INNER_LRU_HASH_PREALLOC],
Martin KaFai Lauad17d0e2017-08-18 11:28:01 -0700138 sizeof(uint32_t),
139 sizeof(long),
140 inner_lru_hash_size, 0,
141 mynode);
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700142 if (inner_lru_map_fds[cpu] == -1) {
143 printf("cannot create BPF_MAP_TYPE_LRU_HASH %s(%d)\n",
144 strerror(errno), errno);
145 exit(1);
146 }
147 } else {
148 inner_lru_map_fds[cpu] = map_fd[inner_lru_hash_idx];
149 }
150
151 ret = bpf_map_update_elem(outer_fd, &cpu,
152 &inner_lru_map_fds[cpu],
153 BPF_ANY);
154 if (ret) {
155 printf("cannot update ARRAY_OF_LRU_HASHS with key:%u. %s(%d)\n",
156 cpu, strerror(errno), errno);
157 exit(1);
158 }
159 }
160
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700161 in6.sin6_addr.s6_addr16[0] = 0xdead;
162 in6.sin6_addr.s6_addr16[1] = 0xbeef;
163
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700164 if (test == LRU_HASH_PREALLOC) {
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700165 test_name = "lru_hash_map_perf";
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700166 in6.sin6_addr.s6_addr16[2] = 0;
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700167 } else if (test == NOCOMMON_LRU_HASH_PREALLOC) {
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700168 test_name = "nocommon_lru_hash_map_perf";
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700169 in6.sin6_addr.s6_addr16[2] = 1;
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700170 } else if (test == INNER_LRU_HASH_PREALLOC) {
171 test_name = "inner_lru_hash_map_perf";
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700172 in6.sin6_addr.s6_addr16[2] = 2;
173 } else if (test == LRU_HASH_LOOKUP) {
174 test_name = "lru_hash_lookup_perf";
175 in6.sin6_addr.s6_addr16[2] = 3;
176 in6.sin6_addr.s6_addr32[3] = 0;
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700177 } else {
178 assert(0);
179 }
Martin KaFai Lau5db58fa2016-11-11 10:55:11 -0800180
181 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700182 for (i = 0; i < max_cnt; i++) {
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700183 ret = connect(-1, (const struct sockaddr *)&in6, sizeof(in6));
184 assert(ret == -1 && errno == EBADF);
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700185 if (in6.sin6_addr.s6_addr32[3] <
186 lru_hash_lookup_test_entries - 32)
187 in6.sin6_addr.s6_addr32[3] += 32;
188 else
189 in6.sin6_addr.s6_addr32[3] = 0;
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700190 }
191 printf("%d:%s pre-alloc %lld events per sec\n",
192 cpu, test_name,
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700193 max_cnt * 1000000000ll / (time_get_ns() - start_time));
Martin KaFai Lau5db58fa2016-11-11 10:55:11 -0800194}
195
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700196static void test_lru_hash_prealloc(int cpu)
Martin KaFai Lau5db58fa2016-11-11 10:55:11 -0800197{
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700198 do_test_lru(LRU_HASH_PREALLOC, cpu);
199}
Martin KaFai Lau5db58fa2016-11-11 10:55:11 -0800200
Martin KaFai Laubf8db5d2017-04-14 10:30:27 -0700201static void test_nocommon_lru_hash_prealloc(int cpu)
202{
203 do_test_lru(NOCOMMON_LRU_HASH_PREALLOC, cpu);
Martin KaFai Lau5db58fa2016-11-11 10:55:11 -0800204}
205
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700206static void test_inner_lru_hash_prealloc(int cpu)
207{
208 do_test_lru(INNER_LRU_HASH_PREALLOC, cpu);
209}
210
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700211static void test_lru_hash_lookup(int cpu)
212{
213 do_test_lru(LRU_HASH_LOOKUP, cpu);
214}
215
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800216static void test_percpu_hash_prealloc(int cpu)
217{
218 __u64 start_time;
219 int i;
220
221 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700222 for (i = 0; i < max_cnt; i++)
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800223 syscall(__NR_geteuid);
224 printf("%d:percpu_hash_map_perf pre-alloc %lld events per sec\n",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700225 cpu, max_cnt * 1000000000ll / (time_get_ns() - start_time));
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800226}
227
228static void test_hash_kmalloc(int cpu)
229{
230 __u64 start_time;
231 int i;
232
233 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700234 for (i = 0; i < max_cnt; i++)
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800235 syscall(__NR_getgid);
236 printf("%d:hash_map_perf kmalloc %lld events per sec\n",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700237 cpu, max_cnt * 1000000000ll / (time_get_ns() - start_time));
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800238}
239
240static void test_percpu_hash_kmalloc(int cpu)
241{
242 __u64 start_time;
243 int i;
244
245 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700246 for (i = 0; i < max_cnt; i++)
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800247 syscall(__NR_getegid);
248 printf("%d:percpu_hash_map_perf kmalloc %lld events per sec\n",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700249 cpu, max_cnt * 1000000000ll / (time_get_ns() - start_time));
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800250}
251
David Herrmannb8a943e2017-01-21 17:26:13 +0100252static void test_lpm_kmalloc(int cpu)
253{
254 __u64 start_time;
255 int i;
256
257 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700258 for (i = 0; i < max_cnt; i++)
David Herrmannb8a943e2017-01-21 17:26:13 +0100259 syscall(__NR_gettid);
260 printf("%d:lpm_perf kmalloc %lld events per sec\n",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700261 cpu, max_cnt * 1000000000ll / (time_get_ns() - start_time));
David Herrmannb8a943e2017-01-21 17:26:13 +0100262}
263
Alexei Starovoitov95ff1412017-03-15 18:26:44 -0700264static void test_hash_lookup(int cpu)
265{
266 __u64 start_time;
267 int i;
268
269 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700270 for (i = 0; i < max_cnt; i++)
Alexei Starovoitov95ff1412017-03-15 18:26:44 -0700271 syscall(__NR_getpgid, 0);
272 printf("%d:hash_lookup %lld lookups per sec\n",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700273 cpu, max_cnt * 1000000000ll * 64 / (time_get_ns() - start_time));
Alexei Starovoitov95ff1412017-03-15 18:26:44 -0700274}
275
276static void test_array_lookup(int cpu)
277{
278 __u64 start_time;
279 int i;
280
281 start_time = time_get_ns();
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700282 for (i = 0; i < max_cnt; i++)
Joel Fernandes95ec66962017-09-20 09:11:56 -0700283 syscall(__NR_getppid, 0);
Alexei Starovoitov95ff1412017-03-15 18:26:44 -0700284 printf("%d:array_lookup %lld lookups per sec\n",
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700285 cpu, max_cnt * 1000000000ll * 64 / (time_get_ns() - start_time));
Alexei Starovoitov95ff1412017-03-15 18:26:44 -0700286}
287
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700288typedef int (*pre_test_func)(int tasks);
289const pre_test_func pre_test_funcs[] = {
290 [LRU_HASH_LOOKUP] = pre_test_lru_hash_lookup,
291};
292
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700293typedef void (*test_func)(int cpu);
294const test_func test_funcs[] = {
295 [HASH_PREALLOC] = test_hash_prealloc,
296 [PERCPU_HASH_PREALLOC] = test_percpu_hash_prealloc,
297 [HASH_KMALLOC] = test_hash_kmalloc,
298 [PERCPU_HASH_KMALLOC] = test_percpu_hash_kmalloc,
299 [LRU_HASH_PREALLOC] = test_lru_hash_prealloc,
300 [NOCOMMON_LRU_HASH_PREALLOC] = test_nocommon_lru_hash_prealloc,
301 [LPM_KMALLOC] = test_lpm_kmalloc,
302 [HASH_LOOKUP] = test_hash_lookup,
303 [ARRAY_LOOKUP] = test_array_lookup,
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700304 [INNER_LRU_HASH_PREALLOC] = test_inner_lru_hash_prealloc,
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700305 [LRU_HASH_LOOKUP] = test_lru_hash_lookup,
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700306};
307
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700308static int pre_test(int tasks)
309{
310 int i;
311
312 for (i = 0; i < NR_TESTS; i++) {
313 if (pre_test_funcs[i] && check_test_flags(i)) {
314 int ret = pre_test_funcs[i](tasks);
315
316 if (ret)
317 return ret;
318 }
319 }
320
321 return 0;
322}
323
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800324static void loop(int cpu)
325{
326 cpu_set_t cpuset;
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700327 int i;
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800328
329 CPU_ZERO(&cpuset);
330 CPU_SET(cpu, &cpuset);
331 sched_setaffinity(0, sizeof(cpuset), &cpuset);
332
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700333 for (i = 0; i < NR_TESTS; i++) {
334 if (check_test_flags(i))
335 test_funcs[i](cpu);
336 }
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800337}
338
339static void run_perf_test(int tasks)
340{
341 pid_t pid[tasks];
342 int i;
343
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700344 assert(!pre_test(tasks));
345
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800346 for (i = 0; i < tasks; i++) {
347 pid[i] = fork();
348 if (pid[i] == 0) {
349 loop(i);
350 exit(0);
351 } else if (pid[i] == -1) {
352 printf("couldn't spawn #%d process\n", i);
353 exit(1);
354 }
355 }
356 for (i = 0; i < tasks; i++) {
357 int status;
358
359 assert(waitpid(pid[i], &status, 0) == pid[i]);
360 assert(status == 0);
361 }
362}
363
David Herrmannb8a943e2017-01-21 17:26:13 +0100364static void fill_lpm_trie(void)
365{
366 struct bpf_lpm_trie_key *key;
367 unsigned long value = 0;
368 unsigned int i;
369 int r;
370
371 key = alloca(sizeof(*key) + 4);
372 key->prefixlen = 32;
373
374 for (i = 0; i < 512; ++i) {
375 key->prefixlen = rand() % 33;
376 key->data[0] = rand() & 0xff;
377 key->data[1] = rand() & 0xff;
378 key->data[2] = rand() & 0xff;
379 key->data[3] = rand() & 0xff;
380 r = bpf_map_update_elem(map_fd[6], key, &value, 0);
381 assert(!r);
382 }
383
384 key->prefixlen = 32;
385 key->data[0] = 192;
386 key->data[1] = 168;
387 key->data[2] = 0;
388 key->data[3] = 1;
389 value = 128;
390
391 r = bpf_map_update_elem(map_fd[6], key, &value, 0);
392 assert(!r);
393}
394
Jesper Dangaard Brouer6979bcc2017-05-02 14:32:01 +0200395static void fixup_map(struct bpf_map_data *map, int idx)
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700396{
397 int i;
398
Jesper Dangaard Brouer6979bcc2017-05-02 14:32:01 +0200399 if (!strcmp("inner_lru_hash_map", map->name)) {
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700400 inner_lru_hash_idx = idx;
Jesper Dangaard Brouer6979bcc2017-05-02 14:32:01 +0200401 inner_lru_hash_size = map->def.max_entries;
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700402 }
403
Jesper Dangaard Brouer6979bcc2017-05-02 14:32:01 +0200404 if (!strcmp("array_of_lru_hashs", map->name)) {
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700405 if (inner_lru_hash_idx == -1) {
406 printf("inner_lru_hash_map must be defined before array_of_lru_hashs\n");
407 exit(1);
408 }
Jesper Dangaard Brouer6979bcc2017-05-02 14:32:01 +0200409 map->def.inner_map_idx = inner_lru_hash_idx;
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700410 array_of_lru_hashs_idx = idx;
411 }
412
Martin KaFai Lau637cd8c2017-08-31 23:27:11 -0700413 if (!strcmp("lru_hash_lookup_map", map->name))
414 lru_hash_lookup_idx = idx;
415
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700416 if (num_map_entries <= 0)
417 return;
418
Martin KaFai Lau3a5795b2017-04-14 10:30:30 -0700419 inner_lru_hash_size = num_map_entries;
420
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700421 /* Only change the max_entries for the enabled test(s) */
422 for (i = 0; i < NR_TESTS; i++) {
Jesper Dangaard Brouer6979bcc2017-05-02 14:32:01 +0200423 if (!strcmp(test_map_names[i], map->name) &&
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700424 (check_test_flags(i))) {
Jesper Dangaard Brouer6979bcc2017-05-02 14:32:01 +0200425 map->def.max_entries = num_map_entries;
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700426 }
427 }
428}
429
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800430int main(int argc, char **argv)
431{
432 struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
433 char filename[256];
434 int num_cpu = 8;
435
436 snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
437 setrlimit(RLIMIT_MEMLOCK, &r);
438
439 if (argc > 1)
440 test_flags = atoi(argv[1]) ? : test_flags;
441
442 if (argc > 2)
443 num_cpu = atoi(argv[2]) ? : num_cpu;
444
Martin KaFai Lau9fd63d02017-04-14 10:30:28 -0700445 if (argc > 3)
446 num_map_entries = atoi(argv[3]);
447
448 if (argc > 4)
449 max_cnt = atoi(argv[4]);
450
451 if (load_bpf_file_fixup_map(filename, fixup_map)) {
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800452 printf("%s", bpf_log_buf);
453 return 1;
454 }
455
David Herrmannb8a943e2017-01-21 17:26:13 +0100456 fill_lpm_trie();
457
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800458 run_perf_test(num_cpu);
459
460 return 0;
461}