libbpf-tools: remove now unnecessary bump_memlock_rlimit()
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 17 Dec 2021 22:24:37 +0000 (14:24 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 20 Dec 2021 21:21:26 +0000 (13:21 -0800)
libbpf will now automatically decide whether it's necessary, and if yes,
will do it on behalf of the application.

All the subsequet tools should make sure to set:

```
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
```

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
libbpf-tools/trace_helpers.c
libbpf-tools/trace_helpers.h

index f37015e7f7c5ad7c261a7dcc6d8a8961f113f21d..322b3c4fbc68001e8ce07fb163b89d8e31e4d521 100644 (file)
@@ -967,16 +967,6 @@ unsigned long long get_ktime_ns(void)
        return ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
 }
 
-int bump_memlock_rlimit(void)
-{
-       struct rlimit rlim_new = {
-               .rlim_cur       = RLIM_INFINITY,
-               .rlim_max       = RLIM_INFINITY,
-       };
-
-       return setrlimit(RLIMIT_MEMLOCK, &rlim_new);
-}
-
 bool is_kernel_module(const char *name)
 {
        bool found = false;
@@ -1007,20 +997,22 @@ bool fentry_exists(const char *name, const char *mod)
        const struct btf_type *type;
        const struct btf_enum *e;
        char sysfs_mod[80];
-       int id = -1, i;
+       int id = -1, i, err;
 
        base = btf__parse(sysfs_vmlinux, NULL);
-       if (libbpf_get_error(base)) {
+       if (!base) {
+               err = -errno;
                fprintf(stderr, "failed to parse vmlinux BTF at '%s': %s\n",
-                       sysfs_vmlinux, strerror(-libbpf_get_error(base)));
+                       sysfs_vmlinux, strerror(-err));
                goto err_out;
        }
        if (mod && module_btf_exists(mod)) {
                snprintf(sysfs_mod, sizeof(sysfs_mod), "/sys/kernel/btf/%s", mod);
                btf = btf__parse_split(sysfs_mod, base);
-               if (libbpf_get_error(btf)) {
+               if (!btf) {
+                       err = -errno;
                        fprintf(stderr, "failed to load BTF from %s: %s\n",
-                               sysfs_mod, strerror(-libbpf_get_error(btf)));
+                               sysfs_mod, strerror(-err));
                        btf = base;
                        base = NULL;
                }
index 61cbe433784b0919e94d18b769147be26445b628..98fd640ffb09090fb7ab6fdfad516993933ae826 100644 (file)
@@ -58,7 +58,6 @@ void print_linear_hist(unsigned int *vals, int vals_size, unsigned int base,
                unsigned int step, const char *val_type);
 
 unsigned long long get_ktime_ns(void);
-int bump_memlock_rlimit(void);
 
 bool is_kernel_module(const char *name);