Skip to content

Commit b25acda

Browse files
laoaranakryiko
authored andcommitted
samples/bpf: Use libbpf 1.0 API mode instead of RLIMIT_MEMLOCK
We have switched to memcg-based memory accouting and thus the rlimit is not needed any more. LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK was introduced in libbpf for backward compatibility, so we can use it instead now. This patch also removes the useless header sys/resource.h from many files in samples/bpf. Signed-off-by: Yafang Shao <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent d252a4a commit b25acda

31 files changed

+7
-42
lines changed

samples/bpf/cpustat_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <sys/types.h>
1414
#include <sys/stat.h>
1515
#include <sys/time.h>
16-
#include <sys/resource.h>
1716
#include <sys/wait.h>
1817

1918
#include <bpf/bpf.h>

samples/bpf/hbm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <stdio.h>
3535
#include <stdlib.h>
3636
#include <assert.h>
37-
#include <sys/resource.h>
3837
#include <sys/time.h>
3938
#include <unistd.h>
4039
#include <errno.h>
@@ -46,7 +45,6 @@
4645
#include <bpf/bpf.h>
4746
#include <getopt.h>
4847

49-
#include "bpf_rlimit.h"
5048
#include "cgroup_helpers.h"
5149
#include "hbm.h"
5250
#include "bpf_util.h"
@@ -510,5 +508,8 @@ int main(int argc, char **argv)
510508
prog = argv[optind];
511509
printf("HBM prog: %s\n", prog != NULL ? prog : "NULL");
512510

511+
/* Use libbpf 1.0 API mode */
512+
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
513+
513514
return run_bpf_prog(prog, cg_id);
514515
}

samples/bpf/ibumad_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <sys/types.h>
2020
#include <limits.h>
2121

22-
#include <sys/resource.h>
2322
#include <getopt.h>
2423
#include <net/if.h>
2524

samples/bpf/map_perf_test_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <signal.h>
1414
#include <string.h>
1515
#include <time.h>
16-
#include <sys/resource.h>
1716
#include <arpa/inet.h>
1817
#include <errno.h>
1918

samples/bpf/offwaketime_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/perf_event.h>
99
#include <errno.h>
1010
#include <stdbool.h>
11-
#include <sys/resource.h>
1211
#include <bpf/libbpf.h>
1312
#include <bpf/bpf.h>
1413
#include "trace_helpers.h"

samples/bpf/sockex2_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "sock_example.h"
88
#include <unistd.h>
99
#include <arpa/inet.h>
10-
#include <sys/resource.h>
1110

1211
struct pair {
1312
__u64 packets;

samples/bpf/sockex3_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "sock_example.h"
77
#include <unistd.h>
88
#include <arpa/inet.h>
9-
#include <sys/resource.h>
109

1110
struct flow_key_record {
1211
__be32 src;

samples/bpf/spintest_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <unistd.h>
44
#include <string.h>
55
#include <assert.h>
6-
#include <sys/resource.h>
76
#include <bpf/libbpf.h>
87
#include <bpf/bpf.h>
98
#include "trace_helpers.h"

samples/bpf/syscall_tp_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <string.h>
99
#include <linux/perf_event.h>
1010
#include <errno.h>
11-
#include <sys/resource.h>
1211
#include <bpf/libbpf.h>
1312
#include <bpf/bpf.h>
1413

samples/bpf/task_fd_query_user.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <fcntl.h>
1111
#include <linux/bpf.h>
1212
#include <sys/ioctl.h>
13-
#include <sys/resource.h>
1413
#include <sys/types.h>
1514
#include <sys/stat.h>
1615
#include <linux/perf_event.h>

0 commit comments

Comments
 (0)