aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2017-04-04 11:26:14 -0400
committerSean Paul <seanpaul@chromium.org>2017-04-04 11:26:14 -0400
commitc829a33253e018472335b02e6d8bb1bb4213a142 (patch)
tree3da5ab428f3d9f0812f288d32d8893a3f16868b9 /tools
parent9c4ad466d1dd2e067d5fdb2fcdbcc30fc5c145f9 (diff)
parente1b489d207c73e67810659a88c45b8db4bd62773 (diff)
Merge airlied/drm-next into drm-misc-next
Backmerging in order to pull vmwgfx [1] and the new synopsys media format [2] reqs. [1]- http://patchwork.freedesktop.org/patch/msgid/20170331233255.GA38850@syeh-m02 [2]- http://patchwork.freedesktop.org/patch/msgid/20170403163544.kcw5kk52tgku5xua@art_vandelay Signed-off-by: Sean Paul <seanpaul@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/Makefile19
-rw-r--r--tools/testing/selftests/bpf/test_maps.c29
2 files changed, 36 insertions, 12 deletions
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 67531f47781b..6a1ad58cb66f 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -1,22 +1,23 @@
1LIBDIR := ../../../lib 1LIBDIR := ../../../lib
2BPFOBJ := $(LIBDIR)/bpf/bpf.o 2BPFDIR := $(LIBDIR)/bpf
3 3
4CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) $(BPFOBJ) 4CFLAGS += -Wall -O2 -I../../../include/uapi -I$(LIBDIR)
5LDLIBS += -lcap
5 6
6TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map 7TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map
7 8
8TEST_PROGS := test_kmod.sh 9TEST_PROGS := test_kmod.sh
9 10
10all: $(TEST_GEN_PROGS) 11include ../lib.mk
12
13BPFOBJ := $(OUTPUT)/bpf.o
14
15$(TEST_GEN_PROGS): $(BPFOBJ)
11 16
12.PHONY: all clean force 17.PHONY: force
13 18
14# force a rebuild of BPFOBJ when its dependencies are updated 19# force a rebuild of BPFOBJ when its dependencies are updated
15force: 20force:
16 21
17$(BPFOBJ): force 22$(BPFOBJ): force
18 $(MAKE) -C $(dir $(BPFOBJ)) 23 $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
19
20$(test_objs): $(BPFOBJ)
21
22include ../lib.mk
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index cada17ac00b8..a0aa2009b0e0 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -80,8 +80,9 @@ static void test_hashmap(int task, void *data)
80 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == 0); 80 assert(bpf_map_update_elem(fd, &key, &value, BPF_EXIST) == 0);
81 key = 2; 81 key = 2;
82 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); 82 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0);
83 key = 1; 83 key = 3;
84 assert(bpf_map_update_elem(fd, &key, &value, BPF_ANY) == 0); 84 assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == -1 &&
85 errno == E2BIG);
85 86
86 /* Check that key = 0 doesn't exist. */ 87 /* Check that key = 0 doesn't exist. */
87 key = 0; 88 key = 0;
@@ -110,6 +111,24 @@ static void test_hashmap(int task, void *data)
110 close(fd); 111 close(fd);
111} 112}
112 113
114static void test_hashmap_sizes(int task, void *data)
115{
116 int fd, i, j;
117
118 for (i = 1; i <= 512; i <<= 1)
119 for (j = 1; j <= 1 << 18; j <<= 1) {
120 fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j,
121 2, map_flags);
122 if (fd < 0) {
123 printf("Failed to create hashmap key=%d value=%d '%s'\n",
124 i, j, strerror(errno));
125 exit(1);
126 }
127 close(fd);
128 usleep(10); /* give kernel time to destroy */
129 }
130}
131
113static void test_hashmap_percpu(int task, void *data) 132static void test_hashmap_percpu(int task, void *data)
114{ 133{
115 unsigned int nr_cpus = bpf_num_possible_cpus(); 134 unsigned int nr_cpus = bpf_num_possible_cpus();
@@ -317,7 +336,10 @@ static void test_arraymap_percpu(int task, void *data)
317static void test_arraymap_percpu_many_keys(void) 336static void test_arraymap_percpu_many_keys(void)
318{ 337{
319 unsigned int nr_cpus = bpf_num_possible_cpus(); 338 unsigned int nr_cpus = bpf_num_possible_cpus();
320 unsigned int nr_keys = 20000; 339 /* nr_keys is not too large otherwise the test stresses percpu
340 * allocator more than anything else
341 */
342 unsigned int nr_keys = 2000;
321 long values[nr_cpus]; 343 long values[nr_cpus];
322 int key, fd, i; 344 int key, fd, i;
323 345
@@ -419,6 +441,7 @@ static void test_map_stress(void)
419{ 441{
420 run_parallel(100, test_hashmap, NULL); 442 run_parallel(100, test_hashmap, NULL);
421 run_parallel(100, test_hashmap_percpu, NULL); 443 run_parallel(100, test_hashmap_percpu, NULL);
444 run_parallel(100, test_hashmap_sizes, NULL);
422 445
423 run_parallel(100, test_arraymap, NULL); 446 run_parallel(100, test_arraymap, NULL);
424 run_parallel(100, test_arraymap_percpu, NULL); 447 run_parallel(100, test_arraymap_percpu, NULL);