@@ -112,32 +112,6 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...)
va_end(args);
}
-static void pr_perm_msg(int err)
-{
- struct rlimit limit;
- char buf[100];
-
- if (err != -EPERM || geteuid() != 0)
- return;
-
- err = getrlimit(RLIMIT_MEMLOCK, &limit);
- if (err)
- return;
-
- if (limit.rlim_cur == RLIM_INFINITY)
- return;
-
- if (limit.rlim_cur < 1024)
- snprintf(buf, sizeof(buf), "%zu bytes", (size_t)limit.rlim_cur);
- else if (limit.rlim_cur < 1024*1024)
- snprintf(buf, sizeof(buf), "%.1f KiB", (double)limit.rlim_cur / 1024);
- else
- snprintf(buf, sizeof(buf), "%.1f MiB", (double)limit.rlim_cur / (1024*1024));
-
- pr_warn("permission error while running as root; try raising 'ulimit -l'? current value: %s\n",
- buf);
-}
-
#define STRERR_BUFSIZE 128
/* Copied from tools/perf/util/util.h */
@@ -3420,8 +3394,7 @@ bpf_object__probe_loading(struct bpf_object *obj)
cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg));
pr_warn("Error in %s():%s(%d). Couldn't load trivial BPF "
"program. Make sure your kernel supports BPF "
- "(CONFIG_BPF_SYSCALL=y) and/or that RLIMIT_MEMLOCK is "
- "set to big enough value.\n", __func__, cp, ret);
+ "(CONFIG_BPF_SYSCALL=y)", __func__, cp, ret);
return -ret;
}
close(ret);
@@ -3918,7 +3891,6 @@ bpf_object__create_maps(struct bpf_object *obj)
err_out:
cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg));
pr_warn("map '%s': failed to create: %s(%d)\n", map->name, cp, err);
- pr_perm_msg(err);
for (j = 0; j < i; j++)
zclose(obj->maps[j].fd);
return err;
@@ -5419,7 +5391,6 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
ret = -errno;
cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
pr_warn("load bpf program failed: %s\n", cp);
- pr_perm_msg(ret);
if (log_buf && log_buf[0] != '\0') {
ret = -LIBBPF_ERRNO__VERIFY;
@@ -610,11 +610,6 @@ bpf_prog_linfo__lfind(const struct bpf_prog_linfo *prog_linfo,
/*
* Probe for supported system features
- *
- * Note that running many of these probes in a short amount of time can cause
- * the kernel to reach the maximal size of lockable memory allowed for the
- * user, causing subsequent probes to fail. In this case, the caller may want
- * to adjust that limit with setrlimit().
*/
LIBBPF_API bool bpf_probe_prog_type(enum bpf_prog_type prog_type,
__u32 ifindex);
As bpf is not using memlock rlimit for memory accounting anymore, let's remove the related code from libbpf. Bpf operations can't fail because of exceeding the limit anymore. Signed-off-by: Roman Gushchin <guro@fb.com> --- tools/lib/bpf/libbpf.c | 31 +------------------------------ tools/lib/bpf/libbpf.h | 5 ----- 2 files changed, 1 insertion(+), 35 deletions(-)