mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
selftests/bpf: Remove explicit setrlimit(RLIMIT_MEMLOCK) in main selftests
As libbpf now is able to automatically take care of RLIMIT_MEMLOCK increase (or skip it altogether on recent enough kernels), remove explicit setrlimit() invocations in bench, test_maps, test_verifier, and test_progs. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211214195904.1785155-3-andrii@kernel.org
This commit is contained in:
parent
e542f2c4cd
commit
c164b8b404
8 changed files with 3 additions and 24 deletions
|
@ -29,26 +29,10 @@ static int libbpf_print_fn(enum libbpf_print_level level,
|
||||||
return vfprintf(stderr, format, args);
|
return vfprintf(stderr, format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bump_memlock_rlimit(void)
|
|
||||||
{
|
|
||||||
struct rlimit rlim_new = {
|
|
||||||
.rlim_cur = RLIM_INFINITY,
|
|
||||||
.rlim_max = RLIM_INFINITY,
|
|
||||||
};
|
|
||||||
|
|
||||||
return setrlimit(RLIMIT_MEMLOCK, &rlim_new);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup_libbpf(void)
|
void setup_libbpf(void)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
|
|
||||||
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
|
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
|
||||||
libbpf_set_print(libbpf_print_fn);
|
libbpf_set_print(libbpf_print_fn);
|
||||||
|
|
||||||
err = bump_memlock_rlimit();
|
|
||||||
if (err)
|
|
||||||
fprintf(stderr, "failed to increase RLIMIT_MEMLOCK: %d", err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void false_hits_report_progress(int iter, struct bench_res *res, long delta_ns)
|
void false_hits_report_progress(int iter, struct bench_res *res, long delta_ns)
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <bpf/libbpf.h>
|
#include <bpf/libbpf.h>
|
||||||
#include <bpf/btf.h>
|
#include <bpf/btf.h>
|
||||||
|
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include "bpf_util.h"
|
#include "bpf_util.h"
|
||||||
#include "../test_btf.h"
|
#include "../test_btf.h"
|
||||||
#include "test_progs.h"
|
#include "test_progs.h"
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <bpf/bpf.h>
|
#include <bpf/bpf.h>
|
||||||
#include <bpf/libbpf.h>
|
#include <bpf/libbpf.h>
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include "bpf_util.h"
|
#include "bpf_util.h"
|
||||||
|
|
||||||
#include "test_progs.h"
|
#include "test_progs.h"
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include <bpf/bpf.h>
|
#include <bpf/bpf.h>
|
||||||
|
|
||||||
#include "test_progs.h"
|
#include "test_progs.h"
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include "bpf_util.h"
|
#include "bpf_util.h"
|
||||||
#include "cgroup_helpers.h"
|
#include "cgroup_helpers.h"
|
||||||
#include "network_helpers.h"
|
#include "network_helpers.h"
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "network_helpers.h"
|
#include "network_helpers.h"
|
||||||
#include "cgroup_helpers.h"
|
#include "cgroup_helpers.h"
|
||||||
#include "test_progs.h"
|
#include "test_progs.h"
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include "test_sock_fields.skel.h"
|
#include "test_sock_fields.skel.h"
|
||||||
|
|
||||||
enum bpf_linum_array_idx {
|
enum bpf_linum_array_idx {
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <bpf/libbpf.h>
|
#include <bpf/libbpf.h>
|
||||||
|
|
||||||
#include "bpf_util.h"
|
#include "bpf_util.h"
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include "test_maps.h"
|
#include "test_maps.h"
|
||||||
#include "testing_helpers.h"
|
#include "testing_helpers.h"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include "test_progs.h"
|
#include "test_progs.h"
|
||||||
#include "cgroup_helpers.h"
|
#include "cgroup_helpers.h"
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
@ -1342,7 +1341,6 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* Use libbpf 1.0 API mode */
|
/* Use libbpf 1.0 API mode */
|
||||||
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
|
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
|
||||||
|
|
||||||
libbpf_set_print(libbpf_print_fn);
|
libbpf_set_print(libbpf_print_fn);
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
# define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1
|
# define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include "bpf_rand.h"
|
#include "bpf_rand.h"
|
||||||
#include "bpf_util.h"
|
#include "bpf_util.h"
|
||||||
#include "test_btf.h"
|
#include "test_btf.h"
|
||||||
|
@ -1395,6 +1394,9 @@ int main(int argc, char **argv)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Use libbpf 1.0 API mode */
|
||||||
|
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
|
||||||
|
|
||||||
bpf_semi_rand_init();
|
bpf_semi_rand_init();
|
||||||
return do_test(unpriv, from, to);
|
return do_test(unpriv, from, to);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue