From: Andrii Nakryiko Date: Fri, 17 Dec 2021 22:24:37 +0000 (-0800) Subject: libbpf-tools: remove now unnecessary bump_memlock_rlimit() X-Git-Tag: v0.24.0~33^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d8f5c45b16c389bb342d2b80c9f5e13e4f3b112;p=platform%2Fupstream%2Fbcc.git libbpf-tools: remove now unnecessary bump_memlock_rlimit() 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 --- diff --git a/libbpf-tools/trace_helpers.c b/libbpf-tools/trace_helpers.c index f37015e7..322b3c4f 100644 --- a/libbpf-tools/trace_helpers.c +++ b/libbpf-tools/trace_helpers.c @@ -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; } diff --git a/libbpf-tools/trace_helpers.h b/libbpf-tools/trace_helpers.h index 61cbe433..98fd640f 100644 --- a/libbpf-tools/trace_helpers.h +++ b/libbpf-tools/trace_helpers.h @@ -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);