Skip to contentSkip to conversation

selftests/bpf: set RLIMIT_MEMLOCK properly for test_libbpf_open.c

PATCH Applied Yonghong Song 2 participants 2 messages Apr 29, 2019 – May 5, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: set RLIMIT_MEMLOCK properly for test_libbpf_open.c

Test test_libbpf.sh failed on my development server with failure
-bash-4.4$ sudo ./test_libbpf.sh
[0] libbpf: Error in bpf_object__probe_name():Operation not permitted(1). Couldn't load basic 'r0 = 0' BPF program.
test_libbpf: failed at file test_l4lb.o
selftests: test_libbpf [FAILED]
-bash-4.4$

The reason is because my machine has 64KB locked memory by default which is not enough for this program to get locked memory.
Similar to other bpf selftests, let us increase RLIMIT_MEMLOCK to infinity, which fixed the issue.

---
 tools/testing/selftests/bpf/test_libbpf_open.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/test_libbpf_open.c +2 -0
index 65cbd30704b5..9e9db202d218 100644
@@ -11,6 +11,8 @@ static const char *__doc__ =
 #include <bpf/libbpf.h>
 #include <getopt.h>
 
+#include "bpf_rlimit.h"
+
 static const struct option long_options[] = {
 	{"help",	no_argument,		NULL, 'h' },
 	{"debug",	no_argument,		NULL, 'D' },
Signature · 1 line
2.17.1
#1 lore raw
Quoted 9 lines · Yonghong Song

Test test_libbpf.sh failed on my development server with failure
-bash-4.4$ sudo ./test_libbpf.sh
[0] libbpf: Error in bpf_object__probe_name():Operation not permitted(1). Couldn't load basic 'r0 = 0' BPF program.
test_libbpf: failed at file test_l4lb.o
selftests: test_libbpf [FAILED]
-bash-4.4$

Quoted 6 lines

The reason is because my machine has 64KB locked memory by default which is not enough for this program to get locked memory.
Similar to other bpf selftests, let us increase RLIMIT_MEMLOCK to infinity, which fixed the issue.

Applied. Thanks