Make libbpf bump RLIMIT_MEMLOCK, similarly to BCC, if kernel is old enough to use memcg-based memory accounting for BPF. Patch #2 drops explicit setrlimi(RLIMIT_MEMLOCK) calls in test_progs, test_maps, and test_verifier. v3->v4: - use detection based on bpf_ktime_get_coarse_ns() helper (Daniel); v2->v3: - use difference in fdinfo's memlock reporting to detect memcg; v1->v2: - fix up out-of-sync comments (Toke). Andrii Nakryiko (2): libbpf: auto-bump RLIMIT_MEMLOCK if kernel needs it for BPF selftests/bpf: remove explicit setrlimit(RLIMIT_MEMLOCK) in main selftests tools/lib/bpf/bpf.c | 81 +++++++++++++++++++ tools/lib/bpf/bpf.h | 2 + tools/lib/bpf/libbpf.c | 47 +++-------- tools/lib/bpf/libbpf.map | 1 + tools/lib/bpf/libbpf_internal.h | 39 +++++++++ tools/lib/bpf/libbpf_legacy.h | 12 ++- tools/testing/selftests/bpf/bench.c | 16 ---- tools/testing/selftests/bpf/prog_tests/btf.c | 1 - .../bpf/prog_tests/select_reuseport.c | 1 - .../selftests/bpf/prog_tests/sk_lookup.c | 1 - .../selftests/bpf/prog_tests/sock_fields.c | 1 - tools/testing/selftests/bpf/test_maps.c | 1 - tools/testing/selftests/bpf/test_progs.c | 2 - tools/testing/selftests/bpf/test_verifier.c | 4 +- 14 files changed, 146 insertions(+), 63 deletions(-) -- 2.30.2