Skip to content

Commit

Permalink
libbpf-tools: remove now unnecessary bump_memlock_rlimit()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
anakryiko committed Dec 20, 2021
1 parent f083d3d commit 5d8f5c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
22 changes: 7 additions & 15 deletions libbpf-tools/trace_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion libbpf-tools/trace_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5d8f5c4

Please sign in to comment.