From 58145b1cff2478607f5f98e98a1c578f174c16ea Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 15 Nov 2022 01:38:22 -0500 Subject: [PATCH] import bcc-0.24.0-4.el9 --- .bcc.metadata | 1 + .gitignore | 1 + SOURCES/bcc-0.24.0-C9S-Fix-mdflush.patch | 44 + .../bcc-0.24.0-C9S-libpbf-version-fixes.patch | 297 +++ ...bcc-0.24.0-Revert-libbpf-1.0-changes.patch | 2331 +++++++++++++++++ ...tpcts-biosnoop-biotop-Build-fix-for-.patch | 125 + ...atpcts-Build-fixes-on-recent-kernels.patch | 60 + ...ow-to-use-different-cflags-for-bpf-t.patch | 49 + ...-dropped-request-rq_disk-for-kernel-.patch | 158 ++ ...-tools-include-blk-mq.h-in-bio-tools.patch | 66 + ...-include-blkdev.h-instead-of-genhd.h.patch | 30 + SPECS/bcc.spec | 498 ++++ 12 files changed, 3660 insertions(+) create mode 100644 .bcc.metadata create mode 100644 .gitignore create mode 100644 SOURCES/bcc-0.24.0-C9S-Fix-mdflush.patch create mode 100644 SOURCES/bcc-0.24.0-C9S-libpbf-version-fixes.patch create mode 100644 SOURCES/bcc-0.24.0-Revert-libbpf-1.0-changes.patch create mode 100644 SOURCES/bcc-0.24.0-biolatency-biolatpcts-biosnoop-biotop-Build-fix-for-.patch create mode 100644 SOURCES/bcc-0.24.0-biolatpcts-Build-fixes-on-recent-kernels.patch create mode 100644 SOURCES/bcc-0.24.0-libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch create mode 100644 SOURCES/bcc-0.24.0-libbpf-tools-Fix-dropped-request-rq_disk-for-kernel-.patch create mode 100644 SOURCES/bcc-0.24.0-tools-include-blk-mq.h-in-bio-tools.patch create mode 100644 SOURCES/bcc-0.24.0-tools-mdflush-include-blkdev.h-instead-of-genhd.h.patch create mode 100644 SPECS/bcc.spec diff --git a/.bcc.metadata b/.bcc.metadata new file mode 100644 index 0000000..e3a63ae --- /dev/null +++ b/.bcc.metadata @@ -0,0 +1 @@ +896d0249470dedfabfcc9a4c8b4089a55b793277 SOURCES/bcc-0.24.0.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..277ef94 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/bcc-0.24.0.tar.gz diff --git a/SOURCES/bcc-0.24.0-C9S-Fix-mdflush.patch b/SOURCES/bcc-0.24.0-C9S-Fix-mdflush.patch new file mode 100644 index 0000000..716789e --- /dev/null +++ b/SOURCES/bcc-0.24.0-C9S-Fix-mdflush.patch @@ -0,0 +1,44 @@ +From 5e7543d35596fabd9e5b02b58f8910bf572ca2fa Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Thu, 7 Oct 2021 17:31:53 +0200 +Subject: [PATCH] C9S: Fix mdflush + +Since kernel commit 309dca309fc ("block: store a block_device pointer +in struct bio") struct bio points again to a block_device and not to a +gendisk directly. However mdflush is looking at the presence or not of +the bio_dev macro to check whether to get the gendisk directly from +the bio or not, which doesn't work anymore since the bio_dev macro +still exists. Since we don't have to deal other ekrnel kernel version +but our own, just use the definition that we use in our kernels. + +Signed-off-by: Jerome Marchand +--- + tools/mdflush.py | 11 ----------- + 1 file changed, 11 deletions(-) + +diff --git a/tools/mdflush.py b/tools/mdflush.py +index 8a23520b..3581d1bf 100755 +--- a/tools/mdflush.py ++++ b/tools/mdflush.py +@@ -35,18 +35,7 @@ int kprobe__md_flush_request(struct pt_regs *ctx, void *mddev, struct bio *bio) + u32 pid = bpf_get_current_pid_tgid() >> 32; + data.pid = pid; + bpf_get_current_comm(&data.comm, sizeof(data.comm)); +-/* +- * The following deals with a kernel version change (in mainline 4.14, although +- * it may be backported to earlier kernels) with how the disk name is accessed. +- * We handle both pre- and post-change versions here. Please avoid kernel +- * version tests like this as much as possible: they inflate the code, test, +- * and maintenance burden. +- */ +-#ifdef bio_dev +- struct gendisk *bi_disk = bio->bi_disk; +-#else + struct gendisk *bi_disk = bio->bi_bdev->bd_disk; +-#endif + bpf_probe_read_kernel(&data.disk, sizeof(data.disk), bi_disk->disk_name); + events.perf_submit(ctx, &data, sizeof(data)); + return 0; +-- +2.35.1 + diff --git a/SOURCES/bcc-0.24.0-C9S-libpbf-version-fixes.patch b/SOURCES/bcc-0.24.0-C9S-libpbf-version-fixes.patch new file mode 100644 index 0000000..3c42a52 --- /dev/null +++ b/SOURCES/bcc-0.24.0-C9S-libpbf-version-fixes.patch @@ -0,0 +1,297 @@ +From a81f219d7f2bfc70dba1eb12208e3e6ab7c81b50 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Thu, 24 Mar 2022 16:08:17 +0100 +Subject: [PATCH] C9S: libpbf version fixes + +Revert "bcc: Replace deprecated libbpf APIs" since the libbpf version +provided in C9S doesn't provide the new APIs. + +Remove BPF_MAP_TYPE_BLOOM_FILTER from bps since the libbpf version in +C9S, doesn't provide bloom filter map. + +Add definition of struct bpf_core_relo. +--- + introspection/bps.c | 1 - + src/cc/bcc_btf.cc | 73 +++++++++++++++++++++++++++++++++++++++- + src/cc/libbpf.c | 82 ++++++--------------------------------------- + 3 files changed, 83 insertions(+), 73 deletions(-) + +diff --git a/introspection/bps.c b/introspection/bps.c +index 232b23d4..6ec02e6c 100644 +--- a/introspection/bps.c ++++ b/introspection/bps.c +@@ -80,7 +80,6 @@ static const char * const map_type_strings[] = { + [BPF_MAP_TYPE_RINGBUF] = "ringbuf", + [BPF_MAP_TYPE_INODE_STORAGE] = "inode_storage", + [BPF_MAP_TYPE_TASK_STORAGE] = "task_storage", +- [BPF_MAP_TYPE_BLOOM_FILTER] = "bloom_filter", + }; + + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) +diff --git a/src/cc/bcc_btf.cc b/src/cc/bcc_btf.cc +index 7f551ae8..c78ba823 100644 +--- a/src/cc/bcc_btf.cc ++++ b/src/cc/bcc_btf.cc +@@ -170,6 +170,77 @@ static int btf_ext_setup_line_info(struct btf_ext *btf_ext) + return btf_ext_setup_info(btf_ext, ¶m); + } + ++/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value ++ * has to be adjusted by relocations. ++ */ ++enum bpf_core_relo_kind { ++ BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */ ++ BPF_FIELD_BYTE_SIZE = 1, /* field size in bytes */ ++ BPF_FIELD_EXISTS = 2, /* field existence in target kernel */ ++ BPF_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */ ++ BPF_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */ ++ BPF_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */ ++ BPF_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */ ++ BPF_TYPE_ID_TARGET = 7, /* type ID in target kernel */ ++ BPF_TYPE_EXISTS = 8, /* type existence in target kernel */ ++ BPF_TYPE_SIZE = 9, /* type size in bytes */ ++ BPF_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */ ++ BPF_ENUMVAL_VALUE = 11, /* enum value integer value */ ++}; ++ ++/* The minimum bpf_core_relo checked by the loader ++ * ++ * CO-RE relocation captures the following data: ++ * - insn_off - instruction offset (in bytes) within a BPF program that needs ++ * its insn->imm field to be relocated with actual field info; ++ * - type_id - BTF type ID of the "root" (containing) entity of a relocatable ++ * type or field; ++ * - access_str_off - offset into corresponding .BTF string section. String ++ * interpretation depends on specific relocation kind: ++ * - for field-based relocations, string encodes an accessed field using ++ * a sequence of field and array indices, separated by colon (:). It's ++ * conceptually very close to LLVM's getelementptr ([0]) instruction's ++ * arguments for identifying offset to a field. ++ * - for type-based relocations, strings is expected to be just "0"; ++ * - for enum value-based relocations, string contains an index of enum ++ * value within its enum type; ++ * ++ * Example to provide a better feel. ++ * ++ * struct sample { ++ * int a; ++ * struct { ++ * int b[10]; ++ * }; ++ * }; ++ * ++ * struct sample *s = ...; ++ * int x = &s->a; // encoded as "0:0" (a is field #0) ++ * int y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1, ++ * // b is field #0 inside anon struct, accessing elem #5) ++ * int z = &s[10]->b; // encoded as "10:1" (ptr is used as an array) ++ * ++ * type_id for all relocs in this example will capture BTF type id of ++ * `struct sample`. ++ * ++ * Such relocation is emitted when using __builtin_preserve_access_index() ++ * Clang built-in, passing expression that captures field address, e.g.: ++ * ++ * bpf_probe_read(&dst, sizeof(dst), ++ * __builtin_preserve_access_index(&src->a.b.c)); ++ * ++ * In this case Clang will emit field relocation recording necessary data to ++ * be able to find offset of embedded `a.b.c` field within `src` struct. ++ * ++ * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction ++ */ ++struct bpf_core_relo { ++ __u32 insn_off; ++ __u32 type_id; ++ __u32 access_str_off; ++ enum bpf_core_relo_kind kind; ++}; ++ + static int btf_ext_setup_core_relos(struct btf_ext *btf_ext) + { + struct btf_ext_sec_setup_param param = { +@@ -597,7 +668,7 @@ int BTF::load(uint8_t *btf_sec, uintptr_t btf_sec_size, + return -1; + } + +- if (btf__load_into_kernel(btf)) { ++ if (btf__load(btf)) { + btf__free(btf); + warning("Loading .BTF section failed\n"); + return -1; +diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c +index e6403299..68af4b35 100644 +--- a/src/cc/libbpf.c ++++ b/src/cc/libbpf.c +@@ -297,25 +297,6 @@ static uint64_t ptr_to_u64(void *ptr) + return (uint64_t) (unsigned long) ptr; + } + +-static int libbpf_bpf_map_create(struct bpf_create_map_attr *create_attr) +-{ +- LIBBPF_OPTS(bpf_map_create_opts, p); +- +- p.map_flags = create_attr->map_flags; +- p.numa_node = create_attr->numa_node; +- p.btf_fd = create_attr->btf_fd; +- p.btf_key_type_id = create_attr->btf_key_type_id; +- p.btf_value_type_id = create_attr->btf_value_type_id; +- p.map_ifindex = create_attr->map_ifindex; +- if (create_attr->map_type == BPF_MAP_TYPE_STRUCT_OPS) +- p.btf_vmlinux_value_type_id = create_attr->btf_vmlinux_value_type_id; +- else +- p.inner_map_fd = create_attr->inner_map_fd; +- +- return bpf_map_create(create_attr->map_type, create_attr->name, create_attr->key_size, +- create_attr->value_size, create_attr->max_entries, &p); +-} +- + int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + { + unsigned name_len = attr->name ? strlen(attr->name) : 0; +@@ -323,7 +304,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + + memcpy(map_name, attr->name, min(name_len, BPF_OBJ_NAME_LEN - 1)); + attr->name = map_name; +- int ret = libbpf_bpf_map_create(attr); ++ int ret = bpf_create_map_xattr(attr); + + if (ret < 0 && errno == EPERM) { + if (!allow_rlimit) +@@ -335,7 +316,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + rl.rlim_max = RLIM_INFINITY; + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0) +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + } + +@@ -345,12 +326,12 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + attr->btf_fd = 0; + attr->btf_key_type_id = 0; + attr->btf_value_type_id = 0; +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + + if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) { + map_name[0] = '\0'; +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + + if (ret < 0 && errno == EPERM) { +@@ -363,7 +344,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + rl.rlim_max = RLIM_INFINITY; + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0) +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + } + return ret; +@@ -627,47 +608,6 @@ int bpf_prog_get_tag(int fd, unsigned long long *ptag) + return 0; + } + +-static int libbpf_bpf_prog_load(const struct bpf_load_program_attr *load_attr, +- char *log_buf, size_t log_buf_sz) +-{ +- LIBBPF_OPTS(bpf_prog_load_opts, p); +- +- if (!load_attr || !log_buf != !log_buf_sz) { +- errno = EINVAL; +- return -EINVAL; +- } +- +- p.expected_attach_type = load_attr->expected_attach_type; +- switch (load_attr->prog_type) { +- case BPF_PROG_TYPE_STRUCT_OPS: +- case BPF_PROG_TYPE_LSM: +- p.attach_btf_id = load_attr->attach_btf_id; +- break; +- case BPF_PROG_TYPE_TRACING: +- case BPF_PROG_TYPE_EXT: +- p.attach_btf_id = load_attr->attach_btf_id; +- p.attach_prog_fd = load_attr->attach_prog_fd; +- break; +- default: +- p.prog_ifindex = load_attr->prog_ifindex; +- p.kern_version = load_attr->kern_version; +- } +- p.log_level = load_attr->log_level; +- p.log_buf = log_buf; +- p.log_size = log_buf_sz; +- p.prog_btf_fd = load_attr->prog_btf_fd; +- p.func_info_rec_size = load_attr->func_info_rec_size; +- p.func_info_cnt = load_attr->func_info_cnt; +- p.func_info = load_attr->func_info; +- p.line_info_rec_size = load_attr->line_info_rec_size; +- p.line_info_cnt = load_attr->line_info_cnt; +- p.line_info = load_attr->line_info; +- p.prog_flags = load_attr->prog_flags; +- +- return bpf_prog_load(load_attr->prog_type, load_attr->name, load_attr->license, +- load_attr->insns, load_attr->insns_cnt, &p); +-} +- + int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + char *log_buf, unsigned log_buf_size, bool allow_rlimit) + { +@@ -750,7 +690,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + attr->name = prog_name; + } + +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + + // func_info/line_info may not be supported in old kernels. + if (ret < 0 && attr->func_info && errno == EINVAL) { +@@ -761,14 +701,14 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + attr->line_info = NULL; + attr->line_info_cnt = 0; + attr->line_info_rec_size = 0; +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + } + + // BPF object name is not supported on older Kernels. + // If we failed due to this, clear the name and try again. + if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) { + prog_name[0] = '\0'; +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + } + + if (ret < 0 && errno == EPERM) { +@@ -787,7 +727,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + rl.rlim_max = RLIM_INFINITY; + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0) +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + } + } + +@@ -805,7 +745,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + // If logging is not already enabled, enable it and do the syscall again. + if (attr->log_level == 0) { + attr->log_level = 1; +- ret = libbpf_bpf_prog_load(attr, log_buf, log_buf_size); ++ ret = bpf_load_program_xattr(attr, log_buf, log_buf_size); + } + // Print the log message and return. + bpf_print_hints(ret, log_buf); +@@ -829,7 +769,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + goto return_result; + } + tmp_log_buf[0] = 0; +- ret = libbpf_bpf_prog_load(attr, tmp_log_buf, tmp_log_buf_size); ++ ret = bpf_load_program_xattr(attr, tmp_log_buf, tmp_log_buf_size); + if (ret < 0 && errno == ENOSPC) { + // Temporary buffer size is not enough. Double it and try again. + free(tmp_log_buf); +-- +2.36.1 + diff --git a/SOURCES/bcc-0.24.0-Revert-libbpf-1.0-changes.patch b/SOURCES/bcc-0.24.0-Revert-libbpf-1.0-changes.patch new file mode 100644 index 0000000..8d86dd9 --- /dev/null +++ b/SOURCES/bcc-0.24.0-Revert-libbpf-1.0-changes.patch @@ -0,0 +1,2331 @@ +From 09cee55c78fe5c165c7d7c21f596c23831f844e1 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Tue, 19 Apr 2022 18:02:13 +0200 +Subject: [PATCH] Revert libbpf 1.0 changes + +Revert "libbpf-tools: remove now unnecessary bump_memlock_rlimit()" + +This reverts commit 5d8f5c45b16c389bb342d2b80c9f5e13e4f3b112. + +Revert "libbpf-tools: update vfsstat for libbpf 1.0" + +This reverts commit f083d3dc37372e555133519cb417f893c431eef0. + +Revert "libbpf-tools: update tcprtt for libbpf 1.0" + +This reverts commit a5b6c3cb2d20718ef002e7447046fad877590b91. + +Revert "libbpf-tools: update tcpconnlat for libbpf 1.0" + +This reverts commit aae06012af8cc8c2b592340f8783a2873aad2023. + +Revert "libbpf-tools: update tcpconnect for libbpf 1.0" + +This reverts commit 4051a9e83cb68733af20ce263fcc41c8aadc2622. + +Revert "libbpf-tools: update syscount for libbpf 1.0" + +This reverts commit d2dc7bcd0d94ef54e336119a2a79113b87839820. + +Revert "libbpf-tools: update statsnoop for libbpf 1.0" + +This reverts commit 0e348e5ed66aabd0cd5c0c75932f245bd1385b3b. + +Revert "libbpf-tools: update solisten for libbpf 1.0" + +This reverts commit 60dd074e26e762727e685334999bec5851adaef9. + +Revert "libbpf-tools: update softirqs for libbpf 1.0" + +This reverts commit 92806a435c2e1b248acdb9d0dc5b3eedc86994b0. + +Revert "libbpf-tools: update runqslower for libbpf 1.0" + +This reverts commit e6477620ccfc9abe10f7e630e65381204daa5ba8. + +Revert "libbpf-tools: update runqlen for libbpf 1.0" + +This reverts commit a7f0148372018140940d66f8faf53cb5add1e858. + +Revert "libbpf-tools: update runqlat for libbpf 1.0" + +This reverts commit 865f990b7139dca166a43bbc8159f6acd4bfbee6. + +Revert "libbpf-tools: update readahead for libbpf 1.0" + +This reverts commit 3c5dae6380dcc2034a8746c648e3bb24ea61f886. + +Revert "libbpf-tools: update opensnoop for libbpf 1.0" + +This reverts commit 34a680ba8da7e61befad67ebccb69c5041e9e288. + +Revert "libbpf-tools: update offcputime for libbpf 1.0" + +This reverts commit 5ef6d9922841d7cfde1994c25ccbac53858ed99f. + +Revert "libbpf-tools: update numamove for libbpf 1.0" + +This reverts commit 824ffd2a1fbb527f5fd25e2caa4b43fbf1ee858b. + +Revert "libbpf-tools: update mountsnoop for libbpf 1.0" + +This reverts commit 08301e93e5cea8575d5dc4b66fb7a76cebd5969b. + +Revert "libbpf-tools: update llcstat for libbpf 1.0" + +This reverts commit dbee9ea8ede33166fa70ecc33af7d7721ef26280. + +Revert "libbpf-tools: update hardirqs for libbpf 1.0" + +This reverts commit 8fcf08c81d30d80f89f995f79ef3246ce99c72dd. + +Revert "libbpf-tools: update gethostlatency for libbpf 1.0" + +This reverts commit 54a239abd21df9d6fc5d8db7ae7a26c5d8db2440. + +Revert "libbpf-tools: update funclatency for libbpf 1.0" + +This reverts commit d7b3ed3a8b2169087534738670d108489711f2d1. + +Revert "libbpf-tools: update fsslower for libbpf 1.0" + +This reverts commit 511ab72f046848d6df3f7c6ec0411b1609e165fb. + +Revert "libbpf-tools: update fsdist for libbpf 1.0" + +This reverts commit 21586658c86e1a20e9195d8715d37d714be93bb6. + +Revert "libbpf-tools: update filetop for libbpf 1.0" + +This reverts commit e6d151227f56433a317790d56ba7875ccae00448. + +Revert "libbpf-tools: update filelife for libbpf 1.0" + +This reverts commit 4ca8dd95efb7c4f149b889b700beeda036ebe822. + +Revert "libbpf-tools: update exitsnoop for libbpf 1.0" + +This reverts commit 0a035be644cf818354f3faab25a74e005a66d954. + +Revert "libbpf-tools: update execsnoop for libbpf 1.0" + +This reverts commit 7da38aabbefa41b8553e9fdec7744a5e423b5119. + +Revert "libbpf-tools: update cpudist for libbpf 1.0" + +This reverts commit dab1d09ef49e74c4c95f933e97e16dfc074338c2. + +Revert "libbpf-tools: update drsnoop for libbpf 1.0" + +This reverts commit 9cfdf5e04b32ca079a634ff60de7c08e3c41ccf5. + +Revert "libbpf-tools: fix cpufreq.bpf.c and update cpufreq for libbpf 1.0" + +This reverts commit f2006eaa5901d6ccf51d24b18c644f2fb1d41757. + +Revert "libbpf-tools: update cachestat for libbpf 1.0" + +This reverts commit 4970d23f9ff308c5860612ad6395d7692b05104e. + +Revert "libbpf-tools: update bitesize for libbpf 1.0" + +This reverts commit 7bea6c4ad9a460fc34eb618e488e44ca014e8ac7. + +Revert "libbpf-tools: update biostacks for libbpf 1.0" + +This reverts commit 49bb367628500104411d42851194162bec5d1f4c. + +Revert "libbpf-tools: update biosnoop for libbpf 1.0" + +This reverts commit 519ed8cf9c0daff75ecb3f435a3efec2087945a6. + +Revert "libbpf-tools: update biopattern for libbpf 1.0" + +This reverts commit c5b17e65a6e59fae1223bf493648050643ad9179. + +Revert "libbpf-tools: update biolatency for libbpf 1.0" + +This reverts commit 24d723699fbeeb8686acabc09ecefcceb749b9e0. + +Revert "libbpf-tools: update bindsnoop for libbpf 1.0" + +This reverts commit 7f2f4c4123a55438754b1a29f7ad3d3cfdbc7373. + +Revert "libbpf-tools: update ksnoop for libbpf 1.0" + +This reverts commit 18dc2ac7d84a854e2f5ac9ce1b532a0c59acf49e. + +Revert "libbpf-tools: update bashreadline for libbpf 1.0" + +This reverts commit 2cf0ba491d16386529c50ff0a9ec3eb9f86a2493. + +Signed-off-by: Jerome Marchand +--- + libbpf-tools/bashreadline.c | 24 ++++++++----- + libbpf-tools/bindsnoop.c | 21 +++++++---- + libbpf-tools/biolatency.c | 28 +++++++++------ + libbpf-tools/biopattern.c | 7 +++- + libbpf-tools/biosnoop.c | 67 +++++++++++++++++++++-------------- + libbpf-tools/biostacks.c | 39 ++++++++++++-------- + libbpf-tools/bitesize.c | 7 +++- + libbpf-tools/cachestat.c | 7 +++- + libbpf-tools/cpudist.c | 7 +++- + libbpf-tools/cpufreq.bpf.c | 11 ------ + libbpf-tools/cpufreq.c | 15 +++++--- + libbpf-tools/drsnoop.c | 21 +++++++---- + libbpf-tools/execsnoop.c | 22 ++++++++---- + libbpf-tools/exitsnoop.c | 20 +++++++---- + libbpf-tools/filelife.c | 21 +++++++---- + libbpf-tools/filetop.c | 6 +++- + libbpf-tools/fsdist.c | 38 +++++++++++++------- + libbpf-tools/fsslower.c | 46 ++++++++++++++++-------- + libbpf-tools/funclatency.c | 32 ++++++++++------- + libbpf-tools/gethostlatency.c | 49 +++++++++++++++---------- + libbpf-tools/hardirqs.c | 34 +++++++++++------- + libbpf-tools/ksnoop.c | 65 ++++++++++++++++----------------- + libbpf-tools/llcstat.bpf.c | 4 +-- + libbpf-tools/llcstat.c | 13 +++++-- + libbpf-tools/mountsnoop.c | 20 +++++++---- + libbpf-tools/numamove.c | 16 ++++++--- + libbpf-tools/offcputime.c | 7 +++- + libbpf-tools/opensnoop.c | 21 +++++++---- + libbpf-tools/readahead.c | 7 +++- + libbpf-tools/runqlat.c | 7 +++- + libbpf-tools/runqlen.c | 13 +++++-- + libbpf-tools/runqslower.c | 22 ++++++++---- + libbpf-tools/softirqs.c | 7 +++- + libbpf-tools/solisten.c | 20 +++++++---- + libbpf-tools/statsnoop.c | 20 +++++++---- + libbpf-tools/syscount.c | 18 ++++++---- + libbpf-tools/tcpconnect.c | 25 ++++++++----- + libbpf-tools/tcpconnlat.c | 24 +++++++++---- + libbpf-tools/tcprtt.c | 7 +++- + libbpf-tools/trace_helpers.c | 22 ++++++++---- + libbpf-tools/trace_helpers.h | 1 + + libbpf-tools/vfsstat.c | 8 ++++- + 42 files changed, 576 insertions(+), 293 deletions(-) + +diff --git a/libbpf-tools/bashreadline.c b/libbpf-tools/bashreadline.c +index 2fcb2e2c..ab3b955e 100644 +--- a/libbpf-tools/bashreadline.c ++++ b/libbpf-tools/bashreadline.c +@@ -149,6 +149,7 @@ int main(int argc, char **argv) + .doc = argp_program_doc, + }; + struct bashreadline_bpf *obj = NULL; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + char *readline_so_path; + off_t func_off; +@@ -165,7 +166,11 @@ int main(int argc, char **argv) + return 1; + } + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ goto cleanup; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = bashreadline_bpf__open_and_load(); +@@ -182,16 +187,17 @@ int main(int argc, char **argv) + + obj->links.printret = bpf_program__attach_uprobe(obj->progs.printret, true, -1, + readline_so_path, func_off); +- if (!obj->links.printret) { +- err = -errno; ++ err = libbpf_get_error(obj->links.printret); ++ if (err) { + warn("failed to attach readline: %d\n", err); + goto cleanup; + } + +- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; ++ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -205,8 +211,8 @@ int main(int argc, char **argv) + printf("%-9s %-7s %s\n", "TIME", "PID", "COMMAND"); + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- warn("error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ warn("error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + err = 0; +diff --git a/libbpf-tools/bindsnoop.c b/libbpf-tools/bindsnoop.c +index 5d87d484..c75b57e0 100644 +--- a/libbpf-tools/bindsnoop.c ++++ b/libbpf-tools/bindsnoop.c +@@ -174,6 +174,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct bindsnoop_bpf *obj; + int err, port_map_fd; +@@ -184,7 +185,11 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = bindsnoop_bpf__open(); +@@ -219,10 +224,12 @@ int main(int argc, char **argv) + goto cleanup; + } + +- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; ++ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), ++ PERF_BUFFER_PAGES, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -240,8 +247,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- warn("error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ warn("error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/biolatency.c b/libbpf-tools/biolatency.c +index 51afa509..f2cf5ffd 100644 +--- a/libbpf-tools/biolatency.c ++++ b/libbpf-tools/biolatency.c +@@ -255,9 +255,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = biolatency_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -308,22 +313,25 @@ int main(int argc, char **argv) + } + + if (env.queued) { +- obj->links.block_rq_insert = bpf_program__attach(obj->progs.block_rq_insert); +- if (!obj->links.block_rq_insert) { +- err = -errno; ++ obj->links.block_rq_insert = ++ bpf_program__attach(obj->progs.block_rq_insert); ++ err = libbpf_get_error(obj->links.block_rq_insert); ++ if (err) { + fprintf(stderr, "failed to attach: %s\n", strerror(-err)); + goto cleanup; + } + } +- obj->links.block_rq_issue = bpf_program__attach(obj->progs.block_rq_issue); +- if (!obj->links.block_rq_issue) { +- err = -errno; ++ obj->links.block_rq_issue = ++ bpf_program__attach(obj->progs.block_rq_issue); ++ err = libbpf_get_error(obj->links.block_rq_issue); ++ if (err) { + fprintf(stderr, "failed to attach: %s\n", strerror(-err)); + goto cleanup; + } +- obj->links.block_rq_complete = bpf_program__attach(obj->progs.block_rq_complete); +- if (!obj->links.block_rq_complete) { +- err = -errno; ++ obj->links.block_rq_complete = ++ bpf_program__attach(obj->progs.block_rq_complete); ++ err = libbpf_get_error(obj->links.block_rq_complete); ++ if (err) { + fprintf(stderr, "failed to attach: %s\n", strerror(-err)); + goto cleanup; + } +diff --git a/libbpf-tools/biopattern.c b/libbpf-tools/biopattern.c +index 92324702..2cc0d9a3 100644 +--- a/libbpf-tools/biopattern.c ++++ b/libbpf-tools/biopattern.c +@@ -172,9 +172,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = biopattern_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/biosnoop.c b/libbpf-tools/biosnoop.c +index f0f665a6..618af38e 100644 +--- a/libbpf-tools/biosnoop.c ++++ b/libbpf-tools/biosnoop.c +@@ -190,6 +190,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct ksyms *ksyms = NULL; + struct biosnoop_bpf *obj; +@@ -202,9 +203,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = biosnoop_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -251,55 +257,64 @@ int main(int argc, char **argv) + } + } + +- obj->links.blk_account_io_start = bpf_program__attach(obj->progs.blk_account_io_start); +- if (!obj->links.blk_account_io_start) { +- err = -errno; ++ obj->links.blk_account_io_start = ++ bpf_program__attach(obj->progs.blk_account_io_start); ++ err = libbpf_get_error(obj->links.blk_account_io_start); ++ if (err) { + fprintf(stderr, "failed to attach blk_account_io_start: %s\n", +- strerror(-err)); ++ strerror(err)); + goto cleanup; + } + ksyms = ksyms__load(); + if (!ksyms) { +- err = -ENOMEM; + fprintf(stderr, "failed to load kallsyms\n"); + goto cleanup; + } + if (ksyms__get_symbol(ksyms, "blk_account_io_merge_bio")) { + obj->links.blk_account_io_merge_bio = + bpf_program__attach(obj->progs.blk_account_io_merge_bio); +- if (!obj->links.blk_account_io_merge_bio) { +- err = -errno; +- fprintf(stderr, "failed to attach blk_account_io_merge_bio: %s\n", +- strerror(-err)); ++ err = libbpf_get_error(obj->links.blk_account_io_merge_bio); ++ if (err) { ++ fprintf(stderr, "failed to attach " ++ "blk_account_io_merge_bio: %s\n", ++ strerror(err)); + goto cleanup; + } + } + if (env.queued) { + obj->links.block_rq_insert = + bpf_program__attach(obj->progs.block_rq_insert); +- if (!obj->links.block_rq_insert) { +- err = -errno; +- fprintf(stderr, "failed to attach block_rq_insert: %s\n", strerror(-err)); ++ err = libbpf_get_error(obj->links.block_rq_insert); ++ if (err) { ++ fprintf(stderr, "failed to attach block_rq_insert: %s\n", ++ strerror(err)); + goto cleanup; + } + } +- obj->links.block_rq_issue = bpf_program__attach(obj->progs.block_rq_issue); +- if (!obj->links.block_rq_issue) { +- err = -errno; +- fprintf(stderr, "failed to attach block_rq_issue: %s\n", strerror(-err)); ++ obj->links.block_rq_issue = ++ bpf_program__attach(obj->progs.block_rq_issue); ++ err = libbpf_get_error(obj->links.block_rq_issue); ++ if (err) { ++ fprintf(stderr, "failed to attach block_rq_issue: %s\n", ++ strerror(err)); + goto cleanup; + } +- obj->links.block_rq_complete = bpf_program__attach(obj->progs.block_rq_complete); +- if (!obj->links.block_rq_complete) { +- err = -errno; +- fprintf(stderr, "failed to attach block_rq_complete: %s\n", strerror(-err)); ++ obj->links.block_rq_complete = ++ bpf_program__attach(obj->progs.block_rq_complete); ++ err = libbpf_get_error(obj->links.block_rq_complete); ++ if (err) { ++ fprintf(stderr, "failed to attach block_rq_complete: %s\n", ++ strerror(err)); + goto cleanup; + } + ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + fprintf(stderr, "failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -323,8 +338,8 @@ int main(int argc, char **argv) + /* main: poll */ + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + if (env.duration && get_ktime_ns() > time_end) +diff --git a/libbpf-tools/biostacks.c b/libbpf-tools/biostacks.c +index 260bc235..c98fd532 100644 +--- a/libbpf-tools/biostacks.c ++++ b/libbpf-tools/biostacks.c +@@ -145,9 +145,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = biostacks_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -179,10 +184,12 @@ int main(int argc, char **argv) + goto cleanup; + } + +- obj->links.blk_account_io_start = bpf_program__attach(obj->progs.blk_account_io_start); +- if (!obj->links.blk_account_io_start) { +- err = -errno; +- fprintf(stderr, "failed to attach blk_account_io_start: %s\n", strerror(-err)); ++ obj->links.blk_account_io_start = ++ bpf_program__attach(obj->progs.blk_account_io_start); ++ err = libbpf_get_error(obj->links.blk_account_io_start); ++ if (err) { ++ fprintf(stderr, "failed to attach blk_account_io_start: %s\n", ++ strerror(err)); + goto cleanup; + } + ksyms = ksyms__load(); +@@ -192,19 +199,23 @@ int main(int argc, char **argv) + } + if (ksyms__get_symbol(ksyms, "blk_account_io_merge_bio")) { + obj->links.blk_account_io_merge_bio = +- bpf_program__attach(obj->progs.blk_account_io_merge_bio); +- if (!obj->links.blk_account_io_merge_bio) { +- err = -errno; +- fprintf(stderr, "failed to attach blk_account_io_merge_bio: %s\n", +- strerror(-err)); ++ bpf_program__attach(obj-> ++ progs.blk_account_io_merge_bio); ++ err = libbpf_get_error(obj-> ++ links.blk_account_io_merge_bio); ++ if (err) { ++ fprintf(stderr, "failed to attach " ++ "blk_account_io_merge_bio: %s\n", ++ strerror(err)); + goto cleanup; + } + } +- obj->links.blk_account_io_done = bpf_program__attach(obj->progs.blk_account_io_done); +- if (!obj->links.blk_account_io_done) { +- err = -errno; ++ obj->links.blk_account_io_done = ++ bpf_program__attach(obj->progs.blk_account_io_done); ++ err = libbpf_get_error(obj->links.blk_account_io_done); ++ if (err) { + fprintf(stderr, "failed to attach blk_account_io_done: %s\n", +- strerror(-err)); ++ strerror(err)); + goto cleanup; + } + +diff --git a/libbpf-tools/bitesize.c b/libbpf-tools/bitesize.c +index 4c371508..41b1a7db 100644 +--- a/libbpf-tools/bitesize.c ++++ b/libbpf-tools/bitesize.c +@@ -167,9 +167,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = bitesize_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/cachestat.c b/libbpf-tools/cachestat.c +index 05785251..abc81878 100644 +--- a/libbpf-tools/cachestat.c ++++ b/libbpf-tools/cachestat.c +@@ -139,9 +139,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = cachestat_bpf__open_and_load(); + if (!obj) { + fprintf(stderr, "failed to open and/or load BPF object\n"); +diff --git a/libbpf-tools/cpudist.c b/libbpf-tools/cpudist.c +index f76d8a67..035100ea 100644 +--- a/libbpf-tools/cpudist.c ++++ b/libbpf-tools/cpudist.c +@@ -197,9 +197,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = cpudist_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/cpufreq.bpf.c b/libbpf-tools/cpufreq.bpf.c +index 88a1bd25..697620ba 100644 +--- a/libbpf-tools/cpufreq.bpf.c ++++ b/libbpf-tools/cpufreq.bpf.c +@@ -17,21 +17,11 @@ struct { + __type(value, struct hist); + } hists SEC(".maps"); + +-#define clamp_umax(VAR, UMAX) \ +- asm volatile ( \ +- "if %0 <= %[max] goto +1\n" \ +- "%0 = %[max]\n" \ +- : "+r"(VAR) \ +- : [max]"i"(UMAX) \ +- ) +- + SEC("tp_btf/cpu_frequency") + int BPF_PROG(cpu_frequency, unsigned int state, unsigned int cpu_id) + { + if (cpu_id >= MAX_CPU_NR) + return 0; +- +- clamp_umax(cpu_id, MAX_CPU_NR - 1); + freqs_mhz[cpu_id] = state / 1000; + return 0; + } +@@ -46,7 +36,6 @@ int do_sample(struct bpf_perf_event_data *ctx) + + if (cpu >= MAX_CPU_NR) + return 0; +- clamp_umax(cpu, MAX_CPU_NR - 1); + freq_mhz = freqs_mhz[cpu]; + if (!freq_mhz) + return 0; +diff --git a/libbpf-tools/cpufreq.c b/libbpf-tools/cpufreq.c +index c5839560..65876587 100644 +--- a/libbpf-tools/cpufreq.c ++++ b/libbpf-tools/cpufreq.c +@@ -102,8 +102,10 @@ static int open_and_attach_perf_event(int freq, struct bpf_program *prog, + return -1; + } + links[i] = bpf_program__attach_perf_event(prog, fd); +- if (!links[i]) { +- fprintf(stderr, "failed to attach perf event on cpu: %d\n", i); ++ if (libbpf_get_error(links[i])) { ++ fprintf(stderr, "failed to attach perf event on cpu: " ++ "%d\n", i); ++ links[i] = NULL; + close(fd); + return -1; + } +@@ -173,7 +175,7 @@ static void print_linear_hists(struct bpf_map *hists, + + printf("\n"); + print_linear_hist(bss->syswide.slots, MAX_SLOTS, 0, HIST_STEP_SIZE, +- "syswide"); ++ "syswide"); + } + + int main(int argc, char **argv) +@@ -191,9 +193,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + nr_cpus = libbpf_num_possible_cpus(); + if (nr_cpus < 0) { + fprintf(stderr, "failed to get # of possible cpus: '%s'!\n", +diff --git a/libbpf-tools/drsnoop.c b/libbpf-tools/drsnoop.c +index 705db9a4..89285871 100644 +--- a/libbpf-tools/drsnoop.c ++++ b/libbpf-tools/drsnoop.c +@@ -146,6 +146,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct ksyms *ksyms = NULL; + const struct ksym *ksym; +@@ -157,9 +158,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = drsnoop_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -207,10 +213,13 @@ int main(int argc, char **argv) + printf(" %8s", "FREE(KB)"); + printf("\n"); + ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + fprintf(stderr, "failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -228,8 +237,8 @@ int main(int argc, char **argv) + /* main: poll */ + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + if (env.duration && get_ktime_ns() > time_end) +diff --git a/libbpf-tools/execsnoop.c b/libbpf-tools/execsnoop.c +index 38294816..1fd573da 100644 +--- a/libbpf-tools/execsnoop.c ++++ b/libbpf-tools/execsnoop.c +@@ -263,6 +263,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct execsnoop_bpf *obj; + int err; +@@ -271,9 +272,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = execsnoop_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -311,10 +317,12 @@ int main(int argc, char **argv) + printf("%-16s %-6s %-6s %3s %s\n", "PCOMM", "PID", "PPID", "RET", "ARGS"); + + /* setup event callbacks */ +- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; ++ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + fprintf(stderr, "failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -328,8 +336,8 @@ int main(int argc, char **argv) + /* main: poll */ + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/exitsnoop.c b/libbpf-tools/exitsnoop.c +index bca9d4d3..410e00da 100644 +--- a/libbpf-tools/exitsnoop.c ++++ b/libbpf-tools/exitsnoop.c +@@ -152,6 +152,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct exitsnoop_bpf *obj; + int err; +@@ -160,7 +161,11 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = exitsnoop_bpf__open(); +@@ -185,10 +190,11 @@ int main(int argc, char **argv) + goto cleanup; + } + +- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; ++ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -206,8 +212,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- warn("error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ warn("error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/filelife.c b/libbpf-tools/filelife.c +index ba6b9440..1f94039e 100644 +--- a/libbpf-tools/filelife.c ++++ b/libbpf-tools/filelife.c +@@ -110,6 +110,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct filelife_bpf *obj; + int err; +@@ -118,9 +119,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = filelife_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -145,10 +151,13 @@ int main(int argc, char **argv) + printf("Tracing the lifespan of short-lived files ... Hit Ctrl-C to end.\n"); + printf("%-8s %-6s %-16s %-7s %s\n", "TIME", "PID", "COMM", "AGE(s)", "FILE"); + ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + fprintf(stderr, "failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -161,8 +170,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/filetop.c b/libbpf-tools/filetop.c +index 70240d85..f1f7ba96 100644 +--- a/libbpf-tools/filetop.c ++++ b/libbpf-tools/filetop.c +@@ -268,7 +268,11 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = filetop_bpf__open(); +diff --git a/libbpf-tools/fsdist.c b/libbpf-tools/fsdist.c +index f411d162..782a0e6a 100644 +--- a/libbpf-tools/fsdist.c ++++ b/libbpf-tools/fsdist.c +@@ -299,44 +299,53 @@ static int attach_kprobes(struct fsdist_bpf *obj) + + /* READ */ + obj->links.file_read_entry = bpf_program__attach_kprobe(obj->progs.file_read_entry, false, cfg->op_funcs[READ]); +- if (!obj->links.file_read_entry) ++ err = libbpf_get_error(obj->links.file_read_entry); ++ if (err) + goto errout; + obj->links.file_read_exit = bpf_program__attach_kprobe(obj->progs.file_read_exit, true, cfg->op_funcs[READ]); +- if (!obj->links.file_read_exit) ++ err = libbpf_get_error(obj->links.file_read_exit); ++ if (err) + goto errout; + /* WRITE */ + obj->links.file_write_entry = bpf_program__attach_kprobe(obj->progs.file_write_entry, false, cfg->op_funcs[WRITE]); +- if (!obj->links.file_write_entry) ++ err = libbpf_get_error(obj->links.file_write_entry); ++ if (err) + goto errout; + obj->links.file_write_exit = bpf_program__attach_kprobe(obj->progs.file_write_exit, true, cfg->op_funcs[WRITE]); +- if (!obj->links.file_write_exit) ++ err = libbpf_get_error(obj->links.file_write_exit); ++ if (err) + goto errout; + /* OPEN */ + obj->links.file_open_entry = bpf_program__attach_kprobe(obj->progs.file_open_entry, false, cfg->op_funcs[OPEN]); +- if (!obj->links.file_open_entry) ++ err = libbpf_get_error(obj->links.file_open_entry); ++ if (err) + goto errout; + obj->links.file_open_exit = bpf_program__attach_kprobe(obj->progs.file_open_exit, true, cfg->op_funcs[OPEN]); +- if (!obj->links.file_open_exit) ++ err = libbpf_get_error(obj->links.file_open_exit); ++ if (err) + goto errout; + /* FSYNC */ + obj->links.file_sync_entry = bpf_program__attach_kprobe(obj->progs.file_sync_entry, false, cfg->op_funcs[FSYNC]); +- if (!obj->links.file_sync_entry) ++ err = libbpf_get_error(obj->links.file_sync_entry); ++ if (err) + goto errout; + obj->links.file_sync_exit = bpf_program__attach_kprobe(obj->progs.file_sync_exit, true, cfg->op_funcs[FSYNC]); +- if (!obj->links.file_sync_exit) ++ err = libbpf_get_error(obj->links.file_sync_exit); ++ if (err) + goto errout; + /* GETATTR */ + if (!cfg->op_funcs[GETATTR]) + return 0; + obj->links.getattr_entry = bpf_program__attach_kprobe(obj->progs.getattr_entry, false, cfg->op_funcs[GETATTR]); +- if (!obj->links.getattr_entry) ++ err = libbpf_get_error(obj->links.getattr_entry); ++ if (err) + goto errout; + obj->links.getattr_exit = bpf_program__attach_kprobe(obj->progs.getattr_exit, true, cfg->op_funcs[GETATTR]); +- if (!obj->links.getattr_exit) ++ err = libbpf_get_error(obj->links.getattr_exit); ++ if (err) + goto errout; + return 0; + errout: +- err = -errno; + warn("failed to attach kprobe: %ld\n", err); + return err; + } +@@ -364,9 +373,14 @@ int main(int argc, char **argv) + return 1; + } + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + skel = fsdist_bpf__open(); + if (!skel) { + warn("failed to open BPF object\n"); +diff --git a/libbpf-tools/fsslower.c b/libbpf-tools/fsslower.c +index e96c9efa..2975b493 100644 +--- a/libbpf-tools/fsslower.c ++++ b/libbpf-tools/fsslower.c +@@ -256,36 +256,43 @@ static int attach_kprobes(struct fsslower_bpf *obj) + + /* READ */ + obj->links.file_read_entry = bpf_program__attach_kprobe(obj->progs.file_read_entry, false, cfg->op_funcs[READ]); +- if (!obj->links.file_read_entry) ++ err = libbpf_get_error(obj->links.file_read_entry); ++ if (err) + goto errout; + obj->links.file_read_exit = bpf_program__attach_kprobe(obj->progs.file_read_exit, true, cfg->op_funcs[READ]); +- if (!obj->links.file_read_exit) ++ err = libbpf_get_error(obj->links.file_read_exit); ++ if (err) + goto errout; + /* WRITE */ + obj->links.file_write_entry = bpf_program__attach_kprobe(obj->progs.file_write_entry, false, cfg->op_funcs[WRITE]); +- if (!obj->links.file_write_entry) ++ err = libbpf_get_error(obj->links.file_write_entry); ++ if (err) + goto errout; + obj->links.file_write_exit = bpf_program__attach_kprobe(obj->progs.file_write_exit, true, cfg->op_funcs[WRITE]); +- if (!obj->links.file_write_exit) ++ err = libbpf_get_error(obj->links.file_write_exit); ++ if (err) + goto errout; + /* OPEN */ + obj->links.file_open_entry = bpf_program__attach_kprobe(obj->progs.file_open_entry, false, cfg->op_funcs[OPEN]); +- if (!obj->links.file_open_entry) ++ err = libbpf_get_error(obj->links.file_open_entry); ++ if (err) + goto errout; + obj->links.file_open_exit = bpf_program__attach_kprobe(obj->progs.file_open_exit, true, cfg->op_funcs[OPEN]); +- if (!obj->links.file_open_exit) ++ err = libbpf_get_error(obj->links.file_open_exit); ++ if (err) + goto errout; + /* FSYNC */ + obj->links.file_sync_entry = bpf_program__attach_kprobe(obj->progs.file_sync_entry, false, cfg->op_funcs[FSYNC]); +- if (!obj->links.file_sync_entry) ++ err = libbpf_get_error(obj->links.file_sync_entry); ++ if (err) + goto errout; + obj->links.file_sync_exit = bpf_program__attach_kprobe(obj->progs.file_sync_exit, true, cfg->op_funcs[FSYNC]); +- if (!obj->links.file_sync_exit) ++ err = libbpf_get_error(obj->links.file_sync_exit); ++ if (err) + goto errout; + return 0; + + errout: +- err = -errno; + warn("failed to attach kprobe: %ld\n", err); + return err; + } +@@ -354,6 +361,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct fsslower_bpf *skel; + __u64 time_end = 0; +@@ -369,9 +377,14 @@ int main(int argc, char **argv) + return 1; + } + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + skel = fsslower_bpf__open(); + if (!skel) { + warn("failed to open BPF object\n"); +@@ -415,10 +428,13 @@ int main(int argc, char **argv) + goto cleanup; + } + ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(skel->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -437,8 +453,8 @@ int main(int argc, char **argv) + /* main: poll */ + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + if (duration && get_ktime_ns() > time_end) +diff --git a/libbpf-tools/funclatency.c b/libbpf-tools/funclatency.c +index 3ea0fec3..b079292e 100644 +--- a/libbpf-tools/funclatency.c ++++ b/libbpf-tools/funclatency.c +@@ -185,18 +185,20 @@ static int attach_kprobes(struct funclatency_bpf *obj) + { + long err; + +- obj->links.dummy_kprobe = bpf_program__attach_kprobe(obj->progs.dummy_kprobe, false, +- env.funcname); +- if (!obj->links.dummy_kprobe) { +- err = -errno; ++ obj->links.dummy_kprobe = ++ bpf_program__attach_kprobe(obj->progs.dummy_kprobe, false, ++ env.funcname); ++ err = libbpf_get_error(obj->links.dummy_kprobe); ++ if (err) { + warn("failed to attach kprobe: %ld\n", err); + return -1; + } + +- obj->links.dummy_kretprobe = bpf_program__attach_kprobe(obj->progs.dummy_kretprobe, true, +- env.funcname); +- if (!obj->links.dummy_kretprobe) { +- err = -errno; ++ obj->links.dummy_kretprobe = ++ bpf_program__attach_kprobe(obj->progs.dummy_kretprobe, true, ++ env.funcname); ++ err = libbpf_get_error(obj->links.dummy_kretprobe); ++ if (err) { + warn("failed to attach kretprobe: %ld\n", err); + return -1; + } +@@ -237,8 +239,8 @@ static int attach_uprobes(struct funclatency_bpf *obj) + obj->links.dummy_kprobe = + bpf_program__attach_uprobe(obj->progs.dummy_kprobe, false, + env.pid ?: -1, bin_path, func_off); +- if (!obj->links.dummy_kprobe) { +- err = -errno; ++ err = libbpf_get_error(obj->links.dummy_kprobe); ++ if (err) { + warn("Failed to attach uprobe: %ld\n", err); + goto out_binary; + } +@@ -246,8 +248,8 @@ static int attach_uprobes(struct funclatency_bpf *obj) + obj->links.dummy_kretprobe = + bpf_program__attach_uprobe(obj->progs.dummy_kretprobe, true, + env.pid ?: -1, bin_path, func_off); +- if (!obj->links.dummy_kretprobe) { +- err = -errno; ++ err = libbpf_get_error(obj->links.dummy_kretprobe); ++ if (err) { + warn("Failed to attach uretprobe: %ld\n", err); + goto out_binary; + } +@@ -296,7 +298,11 @@ int main(int argc, char **argv) + + sigaction(SIGINT, &sigact, 0); + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = funclatency_bpf__open(); +diff --git a/libbpf-tools/gethostlatency.c b/libbpf-tools/gethostlatency.c +index 9b3ebc28..12076e6a 100644 +--- a/libbpf-tools/gethostlatency.c ++++ b/libbpf-tools/gethostlatency.c +@@ -164,14 +164,16 @@ static int attach_uprobes(struct gethostlatency_bpf *obj, struct bpf_link *links + } + links[0] = bpf_program__attach_uprobe(obj->progs.handle_entry, false, + target_pid ?: -1, libc_path, func_off); +- if (!links[0]) { +- warn("failed to attach getaddrinfo: %d\n", -errno); ++ err = libbpf_get_error(links[0]); ++ if (err) { ++ warn("failed to attach getaddrinfo: %d\n", err); + return -1; + } + links[1] = bpf_program__attach_uprobe(obj->progs.handle_return, true, + target_pid ?: -1, libc_path, func_off); +- if (!links[1]) { +- warn("failed to attach getaddrinfo: %d\n", -errno); ++ err = libbpf_get_error(links[1]); ++ if (err) { ++ warn("failed to attach getaddrinfo: %d\n", err); + return -1; + } + +@@ -182,14 +184,16 @@ static int attach_uprobes(struct gethostlatency_bpf *obj, struct bpf_link *links + } + links[2] = bpf_program__attach_uprobe(obj->progs.handle_entry, false, + target_pid ?: -1, libc_path, func_off); +- if (!links[2]) { +- warn("failed to attach gethostbyname: %d\n", -errno); ++ err = libbpf_get_error(links[2]); ++ if (err) { ++ warn("failed to attach gethostbyname: %d\n", err); + return -1; + } + links[3] = bpf_program__attach_uprobe(obj->progs.handle_return, true, + target_pid ?: -1, libc_path, func_off); +- if (!links[3]) { +- warn("failed to attach gethostbyname: %d\n", -errno); ++ err = libbpf_get_error(links[3]); ++ if (err) { ++ warn("failed to attach gethostbyname: %d\n", err); + return -1; + } + +@@ -200,14 +204,16 @@ static int attach_uprobes(struct gethostlatency_bpf *obj, struct bpf_link *links + } + links[4] = bpf_program__attach_uprobe(obj->progs.handle_entry, false, + target_pid ?: -1, libc_path, func_off); +- if (!links[4]) { +- warn("failed to attach gethostbyname2: %d\n", -errno); ++ err = libbpf_get_error(links[4]); ++ if (err) { ++ warn("failed to attach gethostbyname2: %d\n", err); + return -1; + } + links[5] = bpf_program__attach_uprobe(obj->progs.handle_return, true, + target_pid ?: -1, libc_path, func_off); +- if (!links[5]) { +- warn("failed to attach gethostbyname2: %d\n", -errno); ++ err = libbpf_get_error(links[5]); ++ if (err) { ++ warn("failed to attach gethostbyname2: %d\n", err); + return -1; + } + +@@ -221,6 +227,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct bpf_link *links[6] = {}; + struct gethostlatency_bpf *obj; +@@ -230,7 +237,11 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = gethostlatency_bpf__open(); +@@ -251,10 +262,12 @@ int main(int argc, char **argv) + if (err) + goto cleanup; + ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -270,8 +283,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- warn("error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ warn("error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/hardirqs.c b/libbpf-tools/hardirqs.c +index a2475ef1..759b3949 100644 +--- a/libbpf-tools/hardirqs.c ++++ b/libbpf-tools/hardirqs.c +@@ -185,9 +185,14 @@ int main(int argc, char **argv) + return 1; + } + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = hardirqs_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -207,27 +212,30 @@ int main(int argc, char **argv) + } + + if (env.count) { +- obj->links.handle__irq_handler = bpf_program__attach(obj->progs.handle__irq_handler); +- if (!obj->links.handle__irq_handler) { +- err = -errno; ++ obj->links.handle__irq_handler = ++ bpf_program__attach(obj->progs.handle__irq_handler); ++ err = libbpf_get_error(obj->links.handle__irq_handler); ++ if (err) { + fprintf(stderr, + "failed to attach irq/irq_handler_entry: %s\n", +- strerror(-err)); ++ strerror(err)); + } + } else { +- obj->links.irq_handler_entry = bpf_program__attach(obj->progs.irq_handler_entry); +- if (!obj->links.irq_handler_entry) { +- err = -errno; ++ obj->links.irq_handler_entry = ++ bpf_program__attach(obj->progs.irq_handler_entry); ++ err = libbpf_get_error(obj->links.irq_handler_entry); ++ if (err) { + fprintf(stderr, + "failed to attach irq_handler_entry: %s\n", +- strerror(-err)); ++ strerror(err)); + } +- obj->links.irq_handler_exit_exit = bpf_program__attach(obj->progs.irq_handler_exit_exit); +- if (!obj->links.irq_handler_exit_exit) { +- err = -errno; ++ obj->links.irq_handler_exit_exit = ++ bpf_program__attach(obj->progs.irq_handler_exit_exit); ++ err = libbpf_get_error(obj->links.irq_handler_exit_exit); ++ if (err) { + fprintf(stderr, + "failed to attach irq_handler_exit: %s\n", +- strerror(-err)); ++ strerror(err)); + } + } + +diff --git a/libbpf-tools/ksnoop.c b/libbpf-tools/ksnoop.c +index a6ea6107..a5f59a0f 100644 +--- a/libbpf-tools/ksnoop.c ++++ b/libbpf-tools/ksnoop.c +@@ -38,6 +38,7 @@ static bool verbose = false; + static __u32 filter_pid; + static bool stack_mode; + ++#define libbpf_errstr(val) strerror(-libbpf_get_error(val)) + + static void __p(enum log_level level, char *level_str, char *fmt, ...) + { +@@ -222,12 +223,14 @@ static int get_func_btf(struct btf *btf, struct func *func) + return -ENOENT; + } + type = btf__type_by_id(btf, func->id); +- if (!type || BTF_INFO_KIND(type->info) != BTF_KIND_FUNC) { ++ if (libbpf_get_error(type) || ++ BTF_INFO_KIND(type->info) != BTF_KIND_FUNC) { + p_err("Error looking up function type via id '%d'", func->id); + return -EINVAL; + } + type = btf__type_by_id(btf, type->type); +- if (!type || BTF_INFO_KIND(type->info) != BTF_KIND_FUNC_PROTO) { ++ if (libbpf_get_error(type) || ++ BTF_INFO_KIND(type->info) != BTF_KIND_FUNC_PROTO) { + p_err("Error looking up function proto type via id '%d'", + func->id); + return -EINVAL; +@@ -341,16 +344,15 @@ static int trace_to_value(struct btf *btf, struct func *func, char *argname, + static struct btf *get_btf(const char *name) + { + struct btf *mod_btf; +- int err; + + p_debug("getting BTF for %s", + name && strlen(name) > 0 ? name : "vmlinux"); + + if (!vmlinux_btf) { + vmlinux_btf = btf__load_vmlinux_btf(); +- if (!vmlinux_btf) { +- err = -errno; +- p_err("No BTF, cannot determine type info: %s", strerror(-err)); ++ if (libbpf_get_error(vmlinux_btf)) { ++ p_err("No BTF, cannot determine type info: %s", ++ libbpf_errstr(vmlinux_btf)); + return NULL; + } + } +@@ -358,9 +360,9 @@ static struct btf *get_btf(const char *name) + return vmlinux_btf; + + mod_btf = btf__load_module_btf(name, vmlinux_btf); +- if (!mod_btf) { +- err = -errno; +- p_err("No BTF for module '%s': %s", name, strerror(-err)); ++ if (libbpf_get_error(mod_btf)) { ++ p_err("No BTF for module '%s': %s", ++ name, libbpf_errstr(mod_btf)); + return NULL; + } + return mod_btf; +@@ -394,11 +396,11 @@ static char *type_id_to_str(struct btf *btf, __s32 type_id, char *str) + default: + do { + type = btf__type_by_id(btf, type_id); +- if (!type) { ++ ++ if (libbpf_get_error(type)) { + name = "?"; + break; + } +- + switch (BTF_INFO_KIND(type->info)) { + case BTF_KIND_CONST: + case BTF_KIND_VOLATILE: +@@ -553,17 +555,16 @@ static int parse_trace(char *str, struct trace *trace) + return ret; + } + trace->btf = get_btf(func->mod); +- if (!trace->btf) { +- ret = -errno; ++ if (libbpf_get_error(trace->btf)) { + p_err("could not get BTF for '%s': %s", + strlen(func->mod) ? func->mod : "vmlinux", +- strerror(-ret)); ++ libbpf_errstr(trace->btf)); + return -ENOENT; + } + trace->dump = btf_dump__new(trace->btf, NULL, &opts, trace_printf); +- if (!trace->dump) { +- ret = -errno; +- p_err("could not create BTF dump : %n", strerror(-ret)); ++ if (libbpf_get_error(trace->dump)) { ++ p_err("could not create BTF dump : %n", ++ libbpf_errstr(trace->btf)); + return -EINVAL; + } + +@@ -823,20 +824,20 @@ static int attach_traces(struct ksnoop_bpf *skel, struct trace *traces, + bpf_program__attach_kprobe(skel->progs.kprobe_entry, + false, + traces[i].func.name); +- if (!traces[i].links[0]) { +- ret = -errno; ++ ret = libbpf_get_error(traces[i].links[0]); ++ if (ret) { + p_err("Could not attach kprobe to '%s': %s", + traces[i].func.name, strerror(-ret)); + return ret; +- } ++ } + p_debug("Attached kprobe for '%s'", traces[i].func.name); + + traces[i].links[1] = + bpf_program__attach_kprobe(skel->progs.kprobe_return, + true, + traces[i].func.name); +- if (!traces[i].links[1]) { +- ret = -errno; ++ ret = libbpf_get_error(traces[i].links[1]); ++ if (ret) { + p_err("Could not attach kretprobe to '%s': %s", + traces[i].func.name, strerror(-ret)); + return ret; +@@ -848,6 +849,7 @@ static int attach_traces(struct ksnoop_bpf *skel, struct trace *traces, + + static int cmd_trace(int argc, char **argv) + { ++ struct perf_buffer_opts pb_opts = {}; + struct bpf_map *perf_map, *func_map; + struct perf_buffer *pb = NULL; + struct ksnoop_bpf *skel; +@@ -860,8 +862,7 @@ static int cmd_trace(int argc, char **argv) + + skel = ksnoop_bpf__open_and_load(); + if (!skel) { +- ret = -errno; +- p_err("Could not load ksnoop BPF: %s", strerror(-ret)); ++ p_err("Could not load ksnoop BPF: %s", libbpf_errstr(skel)); + return 1; + } + +@@ -886,11 +887,12 @@ static int cmd_trace(int argc, char **argv) + goto cleanup; + } + +- pb = perf_buffer__new(bpf_map__fd(perf_map), pages, +- trace_handler, lost_handler, NULL, NULL); +- if (!pb) { +- ret = -errno; +- p_err("Could not create perf buffer: %s", strerror(-ret)); ++ pb_opts.sample_cb = trace_handler; ++ pb_opts.lost_cb = lost_handler; ++ pb = perf_buffer__new(bpf_map__fd(perf_map), pages, &pb_opts); ++ if (libbpf_get_error(pb)) { ++ p_err("Could not create perf buffer: %s", ++ libbpf_errstr(pb)); + goto cleanup; + } + +@@ -904,8 +906,8 @@ static int cmd_trace(int argc, char **argv) + + while (!exiting) { + ret = perf_buffer__poll(pb, 1); +- if (ret < 0 && ret != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-ret)); ++ if (ret < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset ret to return 0 if exiting */ +@@ -1005,7 +1007,6 @@ int main(int argc, char *argv[]) + if (argc < 0) + usage(); + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + + return cmd_select(argc, argv); +diff --git a/libbpf-tools/llcstat.bpf.c b/libbpf-tools/llcstat.bpf.c +index a36fc2df..fbd5b6c4 100644 +--- a/libbpf-tools/llcstat.bpf.c ++++ b/libbpf-tools/llcstat.bpf.c +@@ -36,13 +36,13 @@ int trace_event(__u64 sample_period, bool miss) + return 0; + } + +-SEC("perf_event") ++SEC("perf_event/1") + int on_cache_miss(struct bpf_perf_event_data *ctx) + { + return trace_event(ctx->sample_period, true); + } + +-SEC("perf_event") ++SEC("perf_event/2") + int on_cache_ref(struct bpf_perf_event_data *ctx) + { + return trace_event(ctx->sample_period, false); +diff --git a/libbpf-tools/llcstat.c b/libbpf-tools/llcstat.c +index be437bc2..150dd38b 100644 +--- a/libbpf-tools/llcstat.c ++++ b/libbpf-tools/llcstat.c +@@ -106,8 +106,10 @@ static int open_and_attach_perf_event(__u64 config, int period, + return -1; + } + links[i] = bpf_program__attach_perf_event(prog, fd); +- if (!links[i]) { +- fprintf(stderr, "failed to attach perf event on cpu: %d\n", i); ++ if (libbpf_get_error(links[i])) { ++ fprintf(stderr, "failed to attach perf event on cpu: " ++ "%d\n", i); ++ links[i] = NULL; + close(fd); + return -1; + } +@@ -182,9 +184,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + nr_cpus = libbpf_num_possible_cpus(); + if (nr_cpus < 0) { + fprintf(stderr, "failed to get # of possible cpus: '%s'!\n", +diff --git a/libbpf-tools/mountsnoop.c b/libbpf-tools/mountsnoop.c +index ac2acc45..0955f59e 100644 +--- a/libbpf-tools/mountsnoop.c ++++ b/libbpf-tools/mountsnoop.c +@@ -249,6 +249,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct mountsnoop_bpf *obj; + int err; +@@ -257,7 +258,11 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = mountsnoop_bpf__open(); +@@ -280,10 +285,11 @@ int main(int argc, char **argv) + goto cleanup; + } + +- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; ++ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -302,8 +308,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/numamove.c b/libbpf-tools/numamove.c +index 0747f841..66a53ed6 100644 +--- a/libbpf-tools/numamove.c ++++ b/libbpf-tools/numamove.c +@@ -80,9 +80,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = numamove_bpf__open_and_load(); + if (!obj) { + fprintf(stderr, "failed to open and/or load BPF object\n"); +@@ -102,15 +107,18 @@ int main(int argc, char **argv) + + signal(SIGINT, sig_handler); + +- printf("%-10s %18s %18s\n", "TIME", "NUMA_migrations", "NUMA_migrations_ms"); ++ printf("%-10s %18s %18s\n", "TIME", "NUMA_migrations", ++ "NUMA_migrations_ms"); + while (!exiting) { + sleep(1); + time(&t); + tm = localtime(&t); + strftime(ts, sizeof(ts), "%H:%M:%S", tm); + printf("%-10s %18lld %18lld\n", ts, +- __atomic_exchange_n(&obj->bss->num, 0, __ATOMIC_RELAXED), +- __atomic_exchange_n(&obj->bss->latency, 0, __ATOMIC_RELAXED)); ++ __atomic_exchange_n(&obj->bss->num, 0, ++ __ATOMIC_RELAXED), ++ __atomic_exchange_n(&obj->bss->latency, 0, ++ __ATOMIC_RELAXED)); + } + + cleanup: +diff --git a/libbpf-tools/offcputime.c b/libbpf-tools/offcputime.c +index 37a8ec2c..0582b158 100644 +--- a/libbpf-tools/offcputime.c ++++ b/libbpf-tools/offcputime.c +@@ -279,9 +279,14 @@ int main(int argc, char **argv) + return 1; + } + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = offcputime_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/opensnoop.c b/libbpf-tools/opensnoop.c +index 557a63cd..5cdac0e5 100644 +--- a/libbpf-tools/opensnoop.c ++++ b/libbpf-tools/opensnoop.c +@@ -219,6 +219,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct opensnoop_bpf *obj; + __u64 time_end = 0; +@@ -228,9 +229,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = opensnoop_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -276,10 +282,13 @@ int main(int argc, char **argv) + printf("%s\n", "PATH"); + + /* setup event callbacks */ ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + fprintf(stderr, "failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -297,8 +306,8 @@ int main(int argc, char **argv) + /* main: poll */ + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + if (env.duration && get_ktime_ns() > time_end) +diff --git a/libbpf-tools/readahead.c b/libbpf-tools/readahead.c +index 17079389..77986011 100644 +--- a/libbpf-tools/readahead.c ++++ b/libbpf-tools/readahead.c +@@ -109,9 +109,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = readahead_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/runqlat.c b/libbpf-tools/runqlat.c +index 5a60b874..249bf794 100644 +--- a/libbpf-tools/runqlat.c ++++ b/libbpf-tools/runqlat.c +@@ -193,9 +193,14 @@ int main(int argc, char **argv) + return 1; + } + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = runqlat_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/runqlen.c b/libbpf-tools/runqlen.c +index 9cbbc739..2f6c5789 100644 +--- a/libbpf-tools/runqlen.c ++++ b/libbpf-tools/runqlen.c +@@ -145,8 +145,10 @@ static int open_and_attach_perf_event(int freq, struct bpf_program *prog, + return -1; + } + links[i] = bpf_program__attach_perf_event(prog, fd); +- if (!links[i]) { +- fprintf(stderr, "failed to attach perf event on cpu: %d\n", i); ++ if (libbpf_get_error(links[i])) { ++ fprintf(stderr, "failed to attach perf event on cpu: " ++ "%d\n", i); ++ links[i] = NULL; + close(fd); + return -1; + } +@@ -229,9 +231,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + nr_cpus = libbpf_num_possible_cpus(); + if (nr_cpus < 0) { + printf("failed to get # of possible cpus: '%s'!\n", +diff --git a/libbpf-tools/runqslower.c b/libbpf-tools/runqslower.c +index b038173e..b21894ca 100644 +--- a/libbpf-tools/runqslower.c ++++ b/libbpf-tools/runqslower.c +@@ -145,6 +145,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct runqslower_bpf *obj; + int err; +@@ -153,9 +154,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = runqslower_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -185,10 +191,12 @@ int main(int argc, char **argv) + else + printf("%-8s %-16s %-6s %14s\n", "TIME", "COMM", "TID", "LAT(us)"); + +- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), 64, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; ++ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), 64, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + fprintf(stderr, "failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -201,8 +209,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, 100); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/softirqs.c b/libbpf-tools/softirqs.c +index 34cfdb77..f1678d4c 100644 +--- a/libbpf-tools/softirqs.c ++++ b/libbpf-tools/softirqs.c +@@ -195,9 +195,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = softirqs_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/solisten.c b/libbpf-tools/solisten.c +index adaa668d..e5812f0c 100644 +--- a/libbpf-tools/solisten.c ++++ b/libbpf-tools/solisten.c +@@ -137,6 +137,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct solisten_bpf *obj; + int err; +@@ -145,7 +146,11 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + + obj = solisten_bpf__open(); +@@ -175,10 +180,11 @@ int main(int argc, char **argv) + goto cleanup; + } + +- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; ++ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -196,8 +202,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- warn("error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ warn("error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/statsnoop.c b/libbpf-tools/statsnoop.c +index 3f8f5c58..76779da6 100644 +--- a/libbpf-tools/statsnoop.c ++++ b/libbpf-tools/statsnoop.c +@@ -127,6 +127,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct statsnoop_bpf *obj; + int err; +@@ -135,9 +136,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %d\n", err); ++ return 1; ++ } + libbpf_set_print(libbpf_print_fn); + ++ + obj = statsnoop_bpf__open(); + if (!obj) { + warn("failed to open BPF object\n"); +@@ -159,10 +165,12 @@ int main(int argc, char **argv) + goto cleanup; + } + ++ pb_opts.sample_cb = handle_event; ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -180,8 +188,8 @@ int main(int argc, char **argv) + + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- warn("error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ warn("error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/syscount.c b/libbpf-tools/syscount.c +index 2d687573..35c0e095 100644 +--- a/libbpf-tools/syscount.c ++++ b/libbpf-tools/syscount.c +@@ -390,9 +390,14 @@ int main(int argc, char **argv) + goto free_names; + } + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %s\n", strerror(errno)); ++ goto free_names; ++ } ++ + obj = syscount_bpf__open(); + if (!obj) { + warn("failed to open BPF object\n"); +@@ -418,15 +423,16 @@ int main(int argc, char **argv) + } + + obj->links.sys_exit = bpf_program__attach(obj->progs.sys_exit); +- if (!obj->links.sys_exit) { +- err = -errno; +- warn("failed to attach sys_exit program: %s\n", strerror(-err)); ++ err = libbpf_get_error(obj->links.sys_exit); ++ if (err) { ++ warn("failed to attach sys_exit program: %s\n", ++ strerror(-err)); + goto cleanup_obj; + } + if (env.latency) { + obj->links.sys_enter = bpf_program__attach(obj->progs.sys_enter); +- if (!obj->links.sys_enter) { +- err = -errno; ++ err = libbpf_get_error(obj->links.sys_enter); ++ if (err) { + warn("failed to attach sys_enter programs: %s\n", + strerror(-err)); + goto cleanup_obj; +diff --git a/libbpf-tools/tcpconnect.c b/libbpf-tools/tcpconnect.c +index 101cf72b..82b2bebb 100644 +--- a/libbpf-tools/tcpconnect.c ++++ b/libbpf-tools/tcpconnect.c +@@ -324,13 +324,17 @@ static void handle_lost_events(void *ctx, int cpu, __u64 lost_cnt) + + static void print_events(int perf_map_fd) + { +- struct perf_buffer *pb; ++ struct perf_buffer_opts pb_opts = { ++ .sample_cb = handle_event, ++ .lost_cb = handle_lost_events, ++ }; ++ struct perf_buffer *pb = NULL; + int err; + +- pb = perf_buffer__new(perf_map_fd, 128, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- err = -errno; ++ pb = perf_buffer__new(perf_map_fd, 128, &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; + warn("failed to open perf buffer: %d\n", err); + goto cleanup; + } +@@ -338,8 +342,8 @@ static void print_events(int perf_map_fd) + print_events_header(); + while (!exiting) { + err = perf_buffer__poll(pb, 100); +- if (err < 0 && err != -EINTR) { +- warn("error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ warn("error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +@@ -365,9 +369,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ warn("failed to increase rlimit: %s\n", strerror(errno)); ++ return 1; ++ } ++ + obj = tcpconnect_bpf__open(); + if (!obj) { + warn("failed to open BPF object\n"); +diff --git a/libbpf-tools/tcpconnlat.c b/libbpf-tools/tcpconnlat.c +index 8eae76ae..3cab2115 100644 +--- a/libbpf-tools/tcpconnlat.c ++++ b/libbpf-tools/tcpconnlat.c +@@ -161,6 +161,7 @@ int main(int argc, char **argv) + .parser = parse_arg, + .doc = argp_program_doc, + }; ++ struct perf_buffer_opts pb_opts; + struct perf_buffer *pb = NULL; + struct tcpconnlat_bpf *obj; + int err; +@@ -169,9 +170,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = tcpconnlat_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +@@ -193,10 +199,15 @@ int main(int argc, char **argv) + goto cleanup; + } + ++ pb_opts.sample_cb = handle_event; ++ ++ pb_opts.lost_cb = handle_lost_events; + pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, +- handle_event, handle_lost_events, NULL, NULL); +- if (!pb) { +- fprintf(stderr, "failed to open perf buffer: %d\n", errno); ++ &pb_opts); ++ err = libbpf_get_error(pb); ++ if (err) { ++ pb = NULL; ++ fprintf(stderr, "failed to open perf buffer: %d\n", err); + goto cleanup; + } + +@@ -211,6 +222,7 @@ int main(int argc, char **argv) + "PID", "COMM", "IP", "SADDR", "DADDR", "DPORT", "LAT(ms)"); + } + ++ + if (signal(SIGINT, sig_int) == SIG_ERR) { + fprintf(stderr, "can't set signal handler: %s\n", strerror(errno)); + err = 1; +@@ -220,8 +232,8 @@ int main(int argc, char **argv) + /* main: poll */ + while (!exiting) { + err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS); +- if (err < 0 && err != -EINTR) { +- fprintf(stderr, "error polling perf buffer: %s\n", strerror(-err)); ++ if (err < 0 && errno != EINTR) { ++ fprintf(stderr, "error polling perf buffer: %s\n", strerror(errno)); + goto cleanup; + } + /* reset err to return 0 if exiting */ +diff --git a/libbpf-tools/tcprtt.c b/libbpf-tools/tcprtt.c +index bed6efa7..bdff55bb 100644 +--- a/libbpf-tools/tcprtt.c ++++ b/libbpf-tools/tcprtt.c +@@ -225,9 +225,14 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %d\n", err); ++ return 1; ++ } ++ + obj = tcprtt_bpf__open(); + if (!obj) { + fprintf(stderr, "failed to open BPF object\n"); +diff --git a/libbpf-tools/trace_helpers.c b/libbpf-tools/trace_helpers.c +index 322b3c4f..f37015e7 100644 +--- a/libbpf-tools/trace_helpers.c ++++ b/libbpf-tools/trace_helpers.c +@@ -967,6 +967,16 @@ 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; +@@ -997,22 +1007,20 @@ 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, err; ++ int id = -1, i; + + base = btf__parse(sysfs_vmlinux, NULL); +- if (!base) { +- err = -errno; ++ if (libbpf_get_error(base)) { + fprintf(stderr, "failed to parse vmlinux BTF at '%s': %s\n", +- sysfs_vmlinux, strerror(-err)); ++ sysfs_vmlinux, strerror(-libbpf_get_error(base))); + 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 (!btf) { +- err = -errno; ++ if (libbpf_get_error(btf)) { + fprintf(stderr, "failed to load BTF from %s: %s\n", +- sysfs_mod, strerror(-err)); ++ sysfs_mod, strerror(-libbpf_get_error(btf))); + btf = base; + base = NULL; + } +diff --git a/libbpf-tools/trace_helpers.h b/libbpf-tools/trace_helpers.h +index 98fd640f..61cbe433 100644 +--- a/libbpf-tools/trace_helpers.h ++++ b/libbpf-tools/trace_helpers.h +@@ -58,6 +58,7 @@ 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); + +diff --git a/libbpf-tools/vfsstat.c b/libbpf-tools/vfsstat.c +index 5519c366..3a8a51d8 100644 +--- a/libbpf-tools/vfsstat.c ++++ b/libbpf-tools/vfsstat.c +@@ -150,9 +150,15 @@ int main(int argc, char **argv) + if (err) + return err; + +- libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + libbpf_set_print(libbpf_print_fn); + ++ err = bump_memlock_rlimit(); ++ if (err) { ++ fprintf(stderr, "failed to increase rlimit: %s\n", ++ strerror(errno)); ++ return 1; ++ } ++ + skel = vfsstat_bpf__open(); + if (!skel) { + fprintf(stderr, "failed to open BPF skelect\n"); +-- +2.35.1 + diff --git a/SOURCES/bcc-0.24.0-biolatency-biolatpcts-biosnoop-biotop-Build-fix-for-.patch b/SOURCES/bcc-0.24.0-biolatency-biolatpcts-biosnoop-biotop-Build-fix-for-.patch new file mode 100644 index 0000000..da15c6e --- /dev/null +++ b/SOURCES/bcc-0.24.0-biolatency-biolatpcts-biosnoop-biotop-Build-fix-for-.patch @@ -0,0 +1,125 @@ +From 879792d2d47c1308e884fb59d92fe535f7bb8d71 Mon Sep 17 00:00:00 2001 +From: Tejun Heo +Date: Thu, 10 Mar 2022 08:37:21 -1000 +Subject: [PATCH 1/2] biolatency, biolatpcts, biosnoop, biotop: Build fix for + v5.17+ + +During 5.17 dev cycle, the kernel dropped request->rq_disk. It can now be +accessed through request->q->disk. Fix the python ones in tools/. There are +more usages in other places which need to be fixed too. + +Signed-off-by: Tejun Heo +Signed-off-by: Jerome Marchand +--- + tools/biolatency.py | 8 ++++++-- + tools/biolatpcts.py | 11 ++++++++--- + tools/biosnoop.py | 6 +++++- + tools/biotop.py | 9 +++++++-- + 4 files changed, 26 insertions(+), 8 deletions(-) + +diff --git a/tools/biolatency.py b/tools/biolatency.py +index 427cee47..10c852ac 100755 +--- a/tools/biolatency.py ++++ b/tools/biolatency.py +@@ -128,12 +128,16 @@ storage_str = "" + store_str = "" + if args.disks: + storage_str += "BPF_HISTOGRAM(dist, disk_key_t);" +- store_str += """ ++ disks_str = """ + disk_key_t key = {.slot = bpf_log2l(delta)}; +- void *__tmp = (void *)req->rq_disk->disk_name; ++ void *__tmp = (void *)req->__RQ_DISK__->disk_name; + bpf_probe_read(&key.disk, sizeof(key.disk), __tmp); + dist.atomic_increment(key); + """ ++ if BPF.kernel_struct_has_field(b'request', b'rq_disk'): ++ store_str += disks_str.replace('__RQ_DISK__', 'rq_disk') ++ else: ++ store_str += disks_str.replace('__RQ_DISK__', 'q->disk') + elif args.flags: + storage_str += "BPF_HISTOGRAM(dist, flag_key_t);" + store_str += """ +diff --git a/tools/biolatpcts.py b/tools/biolatpcts.py +index 0f334419..ea8b1ce6 100755 +--- a/tools/biolatpcts.py ++++ b/tools/biolatpcts.py +@@ -72,9 +72,9 @@ void kprobe_blk_account_io_done(struct pt_regs *ctx, struct request *rq, u64 now + if (!rq->__START_TIME_FIELD__) + return; + +- if (!rq->rq_disk || +- rq->rq_disk->major != __MAJOR__ || +- rq->rq_disk->first_minor != __MINOR__) ++ if (!rq->__RQ_DISK__ || ++ rq->__RQ_DISK__->major != __MAJOR__ || ++ rq->__RQ_DISK__->first_minor != __MINOR__) + return; + + cmd_flags = rq->cmd_flags; +@@ -142,6 +142,11 @@ bpf_source = bpf_source.replace('__START_TIME_FIELD__', start_time_field) + bpf_source = bpf_source.replace('__MAJOR__', str(major)) + bpf_source = bpf_source.replace('__MINOR__', str(minor)) + ++if BPF.kernel_struct_has_field(b'request', b'rq_disk'): ++ bpf_source = bpf_source.replace('__RQ_DISK__', 'rq_disk') ++else: ++ bpf_source = bpf_source.replace('__RQ_DISK__', 'q->disk') ++ + bpf = BPF(text=bpf_source) + if BPF.get_kprobe_functions(b'__blk_account_io_done'): + bpf.attach_kprobe(event="__blk_account_io_done", fn_name="kprobe_blk_account_io_done") +diff --git a/tools/biosnoop.py b/tools/biosnoop.py +index ae38e384..a2b636aa 100755 +--- a/tools/biosnoop.py ++++ b/tools/biosnoop.py +@@ -125,7 +125,7 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req) + data.pid = valp->pid; + data.sector = req->__sector; + bpf_probe_read_kernel(&data.name, sizeof(data.name), valp->name); +- struct gendisk *rq_disk = req->rq_disk; ++ struct gendisk *rq_disk = req->__RQ_DISK__; + bpf_probe_read_kernel(&data.disk_name, sizeof(data.disk_name), + rq_disk->disk_name); + } +@@ -156,6 +156,10 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req) + bpf_text = bpf_text.replace('##QUEUE##', '1') + else: + bpf_text = bpf_text.replace('##QUEUE##', '0') ++if BPF.kernel_struct_has_field(b'request', b'rq_disk'): ++ bpf_text = bpf_text.replace('__RQ_DISK__', 'rq_disk') ++else: ++ bpf_text = bpf_text.replace('__RQ_DISK__', 'q->disk') + if debug or args.ebpf: + print(bpf_text) + if args.ebpf: +diff --git a/tools/biotop.py b/tools/biotop.py +index b3e3ea00..882835f6 100755 +--- a/tools/biotop.py ++++ b/tools/biotop.py +@@ -129,8 +129,8 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req) + + // setup info_t key + struct info_t info = {}; +- info.major = req->rq_disk->major; +- info.minor = req->rq_disk->first_minor; ++ info.major = req->__RQ_DISK__->major; ++ info.minor = req->__RQ_DISK__->first_minor; + /* + * The following deals with a kernel version change (in mainline 4.7, although + * it may be backported to earlier kernels) with how block request write flags +@@ -174,6 +174,11 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req) + print(bpf_text) + exit() + ++if BPF.kernel_struct_has_field(b'request', b'rq_disk'): ++ bpf_text = bpf_text.replace('__RQ_DISK__', 'rq_disk') ++else: ++ bpf_text = bpf_text.replace('__RQ_DISK__', 'q->disk') ++ + b = BPF(text=bpf_text) + if BPF.get_kprobe_functions(b'__blk_account_io_start'): + b.attach_kprobe(event="__blk_account_io_start", fn_name="trace_pid_start") +-- +2.35.1 + diff --git a/SOURCES/bcc-0.24.0-biolatpcts-Build-fixes-on-recent-kernels.patch b/SOURCES/bcc-0.24.0-biolatpcts-Build-fixes-on-recent-kernels.patch new file mode 100644 index 0000000..e190cd5 --- /dev/null +++ b/SOURCES/bcc-0.24.0-biolatpcts-Build-fixes-on-recent-kernels.patch @@ -0,0 +1,60 @@ +From 2ada4cee035c4d07391faa870a5df1874d657b65 Mon Sep 17 00:00:00 2001 +From: Tejun Heo +Date: Thu, 27 Jan 2022 06:25:31 -1000 +Subject: [PATCH 2/3] biolatpcts: Build fixes on recent kernels + +* `struct request` definition recently moved from blkdev.h to blk-mq.h + breaking both tools/biolatpcts and examples/tracing/biolatpcts. Fix them + by also including blk-mq.h. + +* blk_account_io_done() got split into two parts - inline condition checks + and the actual accounting with the latter now done in + __blk_account_io_done(). The kprobe attachment needs to be conditionalized + to work across the change. tools/biolatpcts was already updated but + examples/tracing/biolatpcts wasn't. Fix it. + +Signed-off-by: Tejun Heo +--- + examples/tracing/biolatpcts.py | 6 +++++- + tools/biolatpcts.py | 1 + + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/examples/tracing/biolatpcts.py b/examples/tracing/biolatpcts.py +index c9bb834e..68a59516 100755 +--- a/examples/tracing/biolatpcts.py ++++ b/examples/tracing/biolatpcts.py +@@ -11,6 +11,7 @@ from time import sleep + + bpf_source = """ + #include ++#include + #include + #include + +@@ -45,7 +46,10 @@ void kprobe_blk_account_io_done(struct pt_regs *ctx, struct request *rq, u64 now + """ + + bpf = BPF(text=bpf_source) +-bpf.attach_kprobe(event='blk_account_io_done', fn_name='kprobe_blk_account_io_done') ++if BPF.get_kprobe_functions(b'__blk_account_io_done'): ++ bpf.attach_kprobe(event="__blk_account_io_done", fn_name="kprobe_blk_account_io_done") ++else: ++ bpf.attach_kprobe(event="blk_account_io_done", fn_name="kprobe_blk_account_io_done") + + cur_lat_100ms = bpf['lat_100ms'] + cur_lat_1ms = bpf['lat_1ms'] +diff --git a/tools/biolatpcts.py b/tools/biolatpcts.py +index a2f59592..0f334419 100755 +--- a/tools/biolatpcts.py ++++ b/tools/biolatpcts.py +@@ -56,6 +56,7 @@ parser.add_argument('--verbose', '-v', action='count', default = 0) + bpf_source = """ + #include + #include ++#include + #include + + BPF_PERCPU_ARRAY(rwdf_100ms, u64, 400); +-- +2.35.1 + diff --git a/SOURCES/bcc-0.24.0-libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch b/SOURCES/bcc-0.24.0-libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch new file mode 100644 index 0000000..5d40363 --- /dev/null +++ b/SOURCES/bcc-0.24.0-libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch @@ -0,0 +1,49 @@ +From a6a5dba23d19f6a900b0359a7390df4a6b9a42f4 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Tue, 15 Mar 2022 17:59:24 +0100 +Subject: [PATCH 1/3] libbpf-tools: Allow to use different cflags for bpf + targets + +commit 531b698cdc20 ("libbpf-tools: Enable compilation warnings for +BPF programs") applies CFLAGS to all targets. However, some of the c +flags typically used by distribution are not available to the bpf +target. Add a new BPFCFLAGS macro to take care of that. + +Fixes the following compilation error on fedora: + + BPF bashreadline.bpf.o +clang-13: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument] +clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Wunused-command-line-argument] +clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1' [-Wunused-command-line-argument] +clang-13: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument] +error: option 'cf-protection=return' cannot be specified on this target +error: option 'cf-protection=branch' cannot be specified on this target +2 errors generated. +--- + libbpf-tools/Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libbpf-tools/Makefile b/libbpf-tools/Makefile +index 6bf1ed08..39af95ec 100644 +--- a/libbpf-tools/Makefile ++++ b/libbpf-tools/Makefile +@@ -7,6 +7,7 @@ LIBBPF_SRC := $(abspath ../src/cc/libbpf/src) + LIBBPF_OBJ := $(abspath $(OUTPUT)/libbpf.a) + INCLUDES := -I$(OUTPUT) -I../src/cc/libbpf/include/uapi + CFLAGS := -g -O2 -Wall ++BPFCFLAGS := -g -O2 -Wall + INSTALL ?= install + prefix ?= /usr/local + ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/') +@@ -106,7 +107,7 @@ $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(OUTPUT) + + $(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(ARCH)/vmlinux.h | $(OUTPUT) + $(call msg,BPF,$@) +- $(Q)$(CLANG) $(CFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \ ++ $(Q)$(CLANG) $(BPFCFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \ + -I$(ARCH)/ $(INCLUDES) -c $(filter %.c,$^) -o $@ && \ + $(LLVM_STRIP) -g $@ + +-- +2.35.1 + diff --git a/SOURCES/bcc-0.24.0-libbpf-tools-Fix-dropped-request-rq_disk-for-kernel-.patch b/SOURCES/bcc-0.24.0-libbpf-tools-Fix-dropped-request-rq_disk-for-kernel-.patch new file mode 100644 index 0000000..8134d1f --- /dev/null +++ b/SOURCES/bcc-0.24.0-libbpf-tools-Fix-dropped-request-rq_disk-for-kernel-.patch @@ -0,0 +1,158 @@ +From 50480835adf15a389267393674504551b68987a2 Mon Sep 17 00:00:00 2001 +From: xingfeng2510 +Date: Wed, 30 Mar 2022 16:10:51 +0800 +Subject: [PATCH 2/2] libbpf-tools: Fix dropped request->rq_disk for kernel + 5.17+ + +Signed-off-by: Jerome Marchand +--- + libbpf-tools/biolatency.bpf.c | 20 ++++++++++++++++++-- + libbpf-tools/biosnoop.bpf.c | 12 +++++++++++- + libbpf-tools/biostacks.bpf.c | 12 +++++++++++- + libbpf-tools/bitesize.bpf.c | 12 +++++++++++- + 4 files changed, 51 insertions(+), 5 deletions(-) + +diff --git a/libbpf-tools/biolatency.bpf.c b/libbpf-tools/biolatency.bpf.c +index 648dda78..8f325046 100644 +--- a/libbpf-tools/biolatency.bpf.c ++++ b/libbpf-tools/biolatency.bpf.c +@@ -19,6 +19,10 @@ const volatile bool targ_ms = false; + const volatile bool filter_dev = false; + const volatile __u32 targ_dev = 0; + ++struct request_queue___x { ++ struct gendisk *disk; ++} __attribute__((preserve_access_index)); ++ + struct { + __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY); + __type(key, u32); +@@ -53,9 +57,15 @@ int trace_rq_start(struct request *rq, int issue) + u64 ts = bpf_ktime_get_ns(); + + if (filter_dev) { +- struct gendisk *disk = BPF_CORE_READ(rq, rq_disk); ++ struct request_queue___x *q = (void *)BPF_CORE_READ(rq, q); ++ struct gendisk *disk; + u32 dev; + ++ if (bpf_core_field_exists(q->disk)) ++ disk = BPF_CORE_READ(q, disk); ++ else ++ disk = BPF_CORE_READ(rq, rq_disk); ++ + dev = disk ? MKDEV(BPF_CORE_READ(disk, major), + BPF_CORE_READ(disk, first_minor)) : 0; + if (targ_dev != dev) +@@ -119,7 +129,13 @@ int BPF_PROG(block_rq_complete, struct request *rq, int error, + goto cleanup; + + if (targ_per_disk) { +- struct gendisk *disk = BPF_CORE_READ(rq, rq_disk); ++ struct request_queue___x *q = (void *)BPF_CORE_READ(rq, q); ++ struct gendisk *disk; ++ ++ if (bpf_core_field_exists(q->disk)) ++ disk = BPF_CORE_READ(q, disk); ++ else ++ disk = BPF_CORE_READ(rq, rq_disk); + + hkey.dev = disk ? MKDEV(BPF_CORE_READ(disk, major), + BPF_CORE_READ(disk, first_minor)) : 0; +diff --git a/libbpf-tools/biosnoop.bpf.c b/libbpf-tools/biosnoop.bpf.c +index 54226e43..05903473 100644 +--- a/libbpf-tools/biosnoop.bpf.c ++++ b/libbpf-tools/biosnoop.bpf.c +@@ -15,6 +15,10 @@ const volatile __u32 targ_dev = 0; + + extern __u32 LINUX_KERNEL_VERSION __kconfig; + ++struct request_queue___x { ++ struct gendisk *disk; ++} __attribute__((preserve_access_index)); ++ + struct { + __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY); + __type(key, u32); +@@ -92,7 +96,13 @@ int trace_rq_start(struct request *rq, bool insert) + + stagep = bpf_map_lookup_elem(&start, &rq); + if (!stagep) { +- struct gendisk *disk = BPF_CORE_READ(rq, rq_disk); ++ struct request_queue___x *q = (void *)BPF_CORE_READ(rq, q); ++ struct gendisk *disk; ++ ++ if (bpf_core_field_exists(q->disk)) ++ disk = BPF_CORE_READ(q, disk); ++ else ++ disk = BPF_CORE_READ(rq, rq_disk); + + stage.dev = disk ? MKDEV(BPF_CORE_READ(disk, major), + BPF_CORE_READ(disk, first_minor)) : 0; +diff --git a/libbpf-tools/biostacks.bpf.c b/libbpf-tools/biostacks.bpf.c +index 01993737..c13975fa 100644 +--- a/libbpf-tools/biostacks.bpf.c ++++ b/libbpf-tools/biostacks.bpf.c +@@ -14,6 +14,10 @@ const volatile bool targ_ms = false; + const volatile bool filter_dev = false; + const volatile __u32 targ_dev = -1; + ++struct request_queue___x { ++ struct gendisk *disk; ++} __attribute__((preserve_access_index)); ++ + struct internal_rqinfo { + u64 start_ts; + struct rqinfo rqinfo; +@@ -41,9 +45,15 @@ static __always_inline + int trace_start(void *ctx, struct request *rq, bool merge_bio) + { + struct internal_rqinfo *i_rqinfop = NULL, i_rqinfo = {}; +- struct gendisk *disk = BPF_CORE_READ(rq, rq_disk); ++ struct request_queue___x *q = (void *)BPF_CORE_READ(rq, q); ++ struct gendisk *disk; + u32 dev; + ++ if (bpf_core_field_exists(q->disk)) ++ disk = BPF_CORE_READ(q, disk); ++ else ++ disk = BPF_CORE_READ(rq, rq_disk); ++ + dev = disk ? MKDEV(BPF_CORE_READ(disk, major), + BPF_CORE_READ(disk, first_minor)) : 0; + if (filter_dev && targ_dev != dev) +diff --git a/libbpf-tools/bitesize.bpf.c b/libbpf-tools/bitesize.bpf.c +index 80672c9b..5066ca33 100644 +--- a/libbpf-tools/bitesize.bpf.c ++++ b/libbpf-tools/bitesize.bpf.c +@@ -13,6 +13,10 @@ const volatile __u32 targ_dev = 0; + + extern __u32 LINUX_KERNEL_VERSION __kconfig; + ++struct request_queue___x { ++ struct gendisk *disk; ++} __attribute__((preserve_access_index)); ++ + struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, 10240); +@@ -41,9 +45,15 @@ static int trace_rq_issue(struct request *rq) + u64 slot; + + if (filter_dev) { +- struct gendisk *disk = BPF_CORE_READ(rq, rq_disk); ++ struct request_queue___x *q = (void *)BPF_CORE_READ(rq, q); ++ struct gendisk *disk; + u32 dev; + ++ if (bpf_core_field_exists(q->disk)) ++ disk = BPF_CORE_READ(q, disk); ++ else ++ disk = BPF_CORE_READ(rq, rq_disk); ++ + dev = disk ? MKDEV(BPF_CORE_READ(disk, major), + BPF_CORE_READ(disk, first_minor)) : 0; + if (targ_dev != dev) +-- +2.35.1 + diff --git a/SOURCES/bcc-0.24.0-tools-include-blk-mq.h-in-bio-tools.patch b/SOURCES/bcc-0.24.0-tools-include-blk-mq.h-in-bio-tools.patch new file mode 100644 index 0000000..1f7ce06 --- /dev/null +++ b/SOURCES/bcc-0.24.0-tools-include-blk-mq.h-in-bio-tools.patch @@ -0,0 +1,66 @@ +From 1eafb1f5aa0d3a9f60f89aad0ea55ae93899baff Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Wed, 23 Feb 2022 16:04:30 +0100 +Subject: [PATCH 3/3] tools: include blk-mq.h in bio tools + +Kernel commit 24b83deb29b ("block: move struct request to blk-mq.h") +has moved struct request from blkdev.h to blk-mq.h. It results in +several bio tools to fail with errors of the following type: + +error: incomplete definition of type 'struct request' + +Since blk-mq.h had always included blkdev.h. it is safe to simply +replace the inclusion of blkdev.h by blk-mq-h. It works on both older +and newer kernel. + +Fixes: #3869 + +Signed-off-by: Jerome Marchand +--- + tools/biolatency.py | 2 +- + tools/biosnoop.py | 2 +- + tools/biotop.py | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/biolatency.py b/tools/biolatency.py +index f4e2c9ea..427cee47 100755 +--- a/tools/biolatency.py ++++ b/tools/biolatency.py +@@ -64,7 +64,7 @@ debug = 0 + # define BPF program + bpf_text = """ + #include +-#include ++#include + + typedef struct disk_key { + char disk[DISK_NAME_LEN]; +diff --git a/tools/biosnoop.py b/tools/biosnoop.py +index 2b954ac9..ae38e384 100755 +--- a/tools/biosnoop.py ++++ b/tools/biosnoop.py +@@ -37,7 +37,7 @@ debug = 0 + # define BPF program + bpf_text=""" + #include +-#include ++#include + + // for saving the timestamp and __data_len of each request + struct start_req_t { +diff --git a/tools/biotop.py b/tools/biotop.py +index eac4dab9..b3e3ea00 100755 +--- a/tools/biotop.py ++++ b/tools/biotop.py +@@ -54,7 +54,7 @@ diskstats = "/proc/diskstats" + # load BPF program + bpf_text = """ + #include +-#include ++#include + + // for saving the timestamp and __data_len of each request + struct start_req_t { +-- +2.35.1 + diff --git a/SOURCES/bcc-0.24.0-tools-mdflush-include-blkdev.h-instead-of-genhd.h.patch b/SOURCES/bcc-0.24.0-tools-mdflush-include-blkdev.h-instead-of-genhd.h.patch new file mode 100644 index 0000000..18edfb4 --- /dev/null +++ b/SOURCES/bcc-0.24.0-tools-mdflush-include-blkdev.h-instead-of-genhd.h.patch @@ -0,0 +1,30 @@ +From 93a464e2ef05b7ef78b5679e366b89fcddf6a575 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Mon, 1 Aug 2022 11:45:41 +0200 +Subject: [PATCH] tools/mdflush: include blkdev.h instead of genhd.h + +In recent kernels, i.e. since commit 322cbb50de71 ("block: remove +genhd.h"), genhd.h header has been removed and its content moved to +blkdev.h. Since genhd.h has been included in blkdev.h since forever, +including blkdev instead of genhd in the mdflush tool works for both +older and newer kernel. +--- + tools/mdflush.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/mdflush.py b/tools/mdflush.py +index 3581d1bf..6741d563 100755 +--- a/tools/mdflush.py ++++ b/tools/mdflush.py +@@ -19,7 +19,7 @@ from time import strftime + b = BPF(text=""" + #include + #include +-#include ++#include + #include + + struct data_t { +-- +2.37.1 + diff --git a/SPECS/bcc.spec b/SPECS/bcc.spec new file mode 100644 index 0000000..42396df --- /dev/null +++ b/SPECS/bcc.spec @@ -0,0 +1,498 @@ +# We don't want to bring luajit in RHEL +%if 0%{?rhel} > 0 +%bcond_with lua +%else +# luajit is not available for some architectures +%ifarch ppc64 ppc64le s390x +%bcond_with lua +%else +%bcond_without lua +%endif +%endif + +%ifarch x86_64 ppc64 ppc64le aarch64 +%bcond_without libbpf_tools +%else +%bcond_with libbpf_tools +%endif + +%bcond_with llvm_static + +%if %{without llvm_static} +%global with_llvm_shared 1 +%endif + + +Name: bcc +Version: 0.24.0 +Release: 4%{?dist} +Summary: BPF Compiler Collection (BCC) +License: ASL 2.0 +URL: https://github.com/iovisor/bcc +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch0: %{name}-%{version}-libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch +Patch1: %{name}-%{version}-biolatpcts-Build-fixes-on-recent-kernels.patch +Patch2: %{name}-%{version}-tools-include-blk-mq.h-in-bio-tools.patch +Patch3: %{name}-%{version}-C9S-libpbf-version-fixes.patch +Patch4: %{name}-%{version}-Revert-libbpf-1.0-changes.patch +Patch5: %{name}-%{version}-C9S-Fix-mdflush.patch +Patch6: %{name}-%{version}-biolatency-biolatpcts-biosnoop-biotop-Build-fix-for-.patch +Patch7: %{name}-%{version}-libbpf-tools-Fix-dropped-request-rq_disk-for-kernel-.patch +Patch8: %{name}-%{version}-tools-mdflush-include-blkdev.h-instead-of-genhd.h.patch + +# Arches will be included as upstream support is added and dependencies are +# satisfied in the respective arches +ExclusiveArch: x86_64 %{power64} aarch64 s390x armv7hl + +BuildRequires: bison +BuildRequires: cmake >= 2.8.7 +BuildRequires: flex +BuildRequires: libxml2-devel +BuildRequires: python3-devel +BuildRequires: elfutils-libelf-devel +BuildRequires: elfutils-debuginfod-client-devel +BuildRequires: llvm-devel +BuildRequires: clang-devel +%if %{with llvm_static} +BuildRequires: llvm-static +%endif +BuildRequires: ncurses-devel +%if %{with lua} +BuildRequires: pkgconfig(luajit) +%endif +BuildRequires: libbpf-devel >= 0.6.0, libbpf-static >= 0.6.0 + +Requires: libbpf >= 0.6.0 +Requires: tar +Recommends: kernel-devel + +Recommends: %{name}-tools = %{version}-%{release} + +%description +BCC is a toolkit for creating efficient kernel tracing and manipulation +programs, and includes several useful tools and examples. It makes use of +extended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature +that was first added to Linux 3.15. BCC makes BPF programs easier to write, +with kernel instrumentation in C (and includes a C wrapper around LLVM), and +front-ends in Python and lua. It is suited for many tasks, including +performance analysis and network traffic control. + + +%package devel +Summary: Shared library for BPF Compiler Collection (BCC) +Requires: %{name}%{?_isa} = %{version}-%{release} +Suggests: elfutils-debuginfod-client + +%description devel +The %{name}-devel package contains libraries and header files for developing +application that use BPF Compiler Collection (BCC). + + +%package doc +Summary: Examples for BPF Compiler Collection (BCC) +Recommends: python3-%{name} = %{version}-%{release} +Recommends: %{name}-lua = %{version}-%{release} +BuildArch: noarch + +%description doc +Examples for BPF Compiler Collection (BCC) + + +%package -n python3-%{name} +Summary: Python3 bindings for BPF Compiler Collection (BCC) +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description -n python3-%{name} +Python3 bindings for BPF Compiler Collection (BCC) + + +%if %{with lua} +%package lua +Summary: Standalone tool to run BCC tracers written in Lua +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description lua +Standalone tool to run BCC tracers written in Lua +%endif + + +%package tools +Summary: Command line tools for BPF Compiler Collection (BCC) +Requires: bcc = %{version}-%{release} +Requires: python3-%{name} = %{version}-%{release} +Requires: python3-netaddr + +%description tools +Command line tools for BPF Compiler Collection (BCC) + +%if %{with libbpf_tools} +%package -n libbpf-tools +Summary: Command line libbpf tools for BPF Compiler Collection (BCC) +BuildRequires: bpftool + +%description -n libbpf-tools +Command line libbpf tools for BPF Compiler Collection (BCC) +%endif + +%prep +%autosetup -p1 + + +%build +%cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DREVISION_LAST=%{version} -DREVISION=%{version} -DPYTHON_CMD=python3 \ + -DCMAKE_USE_LIBBPF_PACKAGE:BOOL=TRUE \ + %{?with_llvm_shared:-DENABLE_LLVM_SHARED=1} +%cmake_build + +# It was discussed and agreed to package libbpf-tools with +# 'bpf-' prefix (https://github.com/iovisor/bcc/pull/3263) +# Installing libbpf-tools binaries in temp directory and +# renaming them in there and the install code will just +# take them. +%if %{with libbpf_tools} +pushd libbpf-tools; +make BPFTOOL=bpftool LIBBPF_OBJ=%{_libdir}/libbpf.a CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}" +make DESTDIR=./tmp-install prefix= install +( + cd tmp-install/bin + for file in *; do + mv $file bpf-$file + done + # now fix the broken symlinks + for file in `find . -type l`; do + dest=$(readlink "$file") + ln -s -f bpf-$dest $file + done +) +popd +%endif + +%install +%cmake_install + +# Fix python shebangs +find %{buildroot}%{_datadir}/%{name}/{tools,examples} -type f -exec \ + sed -i -e '1s=^#!/usr/bin/python\([0-9.]\+\)\?$=#!%{__python3}=' \ + -e '1s=^#!/usr/bin/env python\([0-9.]\+\)\?$=#!%{__python3}=' \ + -e '1s=^#!/usr/bin/env bcc-lua$=#!/usr/bin/bcc-lua=' {} \; + +# Move man pages to the right location +mkdir -p %{buildroot}%{_mandir} +mv %{buildroot}%{_datadir}/%{name}/man/* %{buildroot}%{_mandir}/ +# Avoid conflict with other manpages +# https://bugzilla.redhat.com/show_bug.cgi?id=1517408 +for i in `find %{buildroot}%{_mandir} -name "*.gz"`; do + tname=$(basename $i) + rename $tname %{name}-$tname $i +done +mkdir -p %{buildroot}%{_docdir}/%{name} +mv %{buildroot}%{_datadir}/%{name}/examples %{buildroot}%{_docdir}/%{name}/ + +# Delete old tools we don't want to ship +rm -rf %{buildroot}%{_datadir}/%{name}/tools/old/ + +# We cannot run the test suit since it requires root and it makes changes to +# the machine (e.g, IP address) +#%check + +%if %{with libbpf_tools} +mkdir -p %{buildroot}/%{_sbindir} +# We cannot use `install` because some of the tools are symlinks and `install` +# follows those. Since all the tools already have the correct permissions set, +# we just need to copy them to the right place while preserving those +cp -a libbpf-tools/tmp-install/bin/* %{buildroot}/%{_sbindir}/ +%endif + +%ldconfig_scriptlets + +%files +%doc README.md +%license LICENSE.txt +%{_libdir}/lib%{name}.so.* +%{_libdir}/libbcc_bpf.so.* + +%files devel +%exclude %{_libdir}/lib%{name}*.a +%exclude %{_libdir}/lib%{name}*.la +%{_libdir}/lib%{name}.so +%{_libdir}/libbcc_bpf.so +%{_libdir}/pkgconfig/lib%{name}.pc +%{_includedir}/%{name}/ + +%files -n python3-%{name} +%{python3_sitelib}/%{name}* + +%files doc +%dir %{_docdir}/%{name} +%doc %{_docdir}/%{name}/examples/ + +%files tools +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/tools/ +%{_datadir}/%{name}/introspection/ +%if 0%{?rhel} > 0 +# inject relies on BPF_KPROBE_OVERRIDE which is not set on RHEL +%exclude %{_datadir}/%{name}/tools/inject +%exclude %{_datadir}/%{name}/tools/doc/inject_example.txt +%exclude %{_mandir}/man8/bcc-inject.8.gz +# Neither btrfs nor zfs are available on RHEL +%exclude %{_datadir}/%{name}/tools/btrfs* +%exclude %{_datadir}/%{name}/tools/doc/btrfs* +%exclude %{_mandir}/man8/bcc-btrfs* +%exclude %{_datadir}/%{name}/tools/zfs* +%exclude %{_datadir}/%{name}/tools/doc/zfs* +%exclude %{_mandir}/man8/bcc-zfs* +# criticalstat relies on CONFIG_PREEMPTIRQ_EVENTS which is disabled on RHEL +%exclude %{_datadir}/%{name}/tools/criticalstat +%exclude %{_datadir}/%{name}/tools/doc/criticalstat_example.txt +%exclude %{_mandir}/man8/bcc-criticalstat.8.gz +%endif +%{_mandir}/man8/* + +%if %{with lua} +%files lua +%{_bindir}/bcc-lua +%endif + +%if %{with libbpf_tools} +%files -n libbpf-tools +%{_sbindir}/bpf-* +%endif + +%changelog +* Tue Aug 23 2022 Jerome Marchand - 0.24.1-4 +- Fix mdflush tool (rhbz#2108001) + +* Fri Jul 01 2022 Jerome Marchand - 0.24.1-3 +- Rebuild for libbpf 0.6.0 + +* Wed May 18 2022 Jerome Marchand - 0.24.1-2 +- Rebuild (previous build failed with UNKNOWN_KOJI_ERROR) + +* Thu Mar 24 2022 Jerome Marchand - 0.24.0-1 +- Rebase to v0.24.0 +- Fix cmake build + +* Fri Feb 25 2022 Jerome Marchand - 0.20.0-10 +- Remove deprecated python_provides macro (needed for gating) + +* Thu Feb 24 2022 Jerome Marchand - 0.20.0-9 +- Fix bio tools (rhbz#2039595) + +* Mon Nov 22 2021 Jerome Marchand - 0.20.0-8 +- Rebuild for LLVM 13 + +* Thu Oct 14 2021 Jerome Marchand - 0.20.0-7 +- Sync with latest libbpf (fixes BPF_F_BROADCAST breakages of rhbz#1992430) +- Fix cpudist, mdflush, readahead and threadsnoop (rhbz#1992430) +- Handle the renaming of task_struct_>state field +- Drop tools that relies on features disabled on RHEL + +* Mon Aug 09 2021 Mohan Boddu - 0.20.0-6 +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 + +* Tue Aug 03 2021 Jerome Marchand - 0.20.0-5 +- Add gating + +* Mon Jul 26 2021 Jerome Marchand - 0.20.0-4 +- Don't require bcc-tools by default (#1967550) +- Add explicit bcc requirement to bcc-tools +- Build bcc from standard sources + +* Wed Jun 02 2021 Jerome Marchand - 0.20.0-3 +- Don't ignore LDFLAGS for libbpf-tools + +* Wed Jun 02 2021 Jerome Marchand - 0.20.0-2 +- Don't override cflags for libbpf-tools + +* Thu May 27 2021 Jerome Marchand - 0.20.0-1 +- Rebase to bcc 0.20.0 + +* Thu May 13 2021 Tom Stellard - 0.18.0-6 +- Rebuild for LLVM 12 + +* Thu Apr 15 2021 Mohan Boddu - 0.18.0-5 +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 + +* Thu Feb 18 2021 Jerome Marchand - 0.18.0-4 +- Disable lua for RHEL + +* Tue Jan 26 2021 Fedora Release Engineering - 0.18.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Fri Jan 22 2021 Tom Stellard - 0.18.0-2 +- Rebuild for clang-11.1.0 + +* Tue Jan 5 15:08:26 CET 2021 Rafael dos Santos - 0.18.0-1 +- Rebase to latest upstream (#1912875) + +* Fri Oct 30 11:25:46 CET 2020 Rafael dos Santos - 0.17.0-1 +- Rebase to latest upstream (#1871417) + +* Mon Oct 12 2020 Jerome Marchand - 0.16.0.3 +- Rebuild for LLVM 11.0.0-rc6 + +* Fri Aug 28 2020 Rafael dos Santos - 0.16.0-2 +- Enable build for armv7hl + +* Sun Aug 23 2020 Rafael dos Santos - 0.16.0-1 +- Rebase to latest upstream (#1871417) + +* Tue Aug 04 2020 Rafael dos Santos - 0.15.0-6 +- Fix build with cmake (#1863243) + +* Sat Aug 01 2020 Fedora Release Engineering - 0.15.0-5 +- Second attempt - Rebuilt for + https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Mon Jul 27 2020 Fedora Release Engineering - 0.15.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Thu Jul 09 2020 Tom Stellard - 0.15.0-3 +- Drop llvm-static dependency +- https://docs.fedoraproject.org/en-US/packaging-guidelines/#_statically_linking_executables + +* Thu Jul 02 2020 Rafael dos Santos - 0.15.0-2 +- Reinstate a function needed by bpftrace + +* Tue Jun 23 2020 Rafael dos Santos - 0.15.0-1 +- Rebase to latest upstream version (#1849239) + +* Tue May 26 2020 Miro Hrončok - 0.14.0-2 +- Rebuilt for Python 3.9 + +* Tue Apr 21 2020 Rafael dos Santos - 0.14.0-1 +- Rebase to latest upstream version (#1826281) + +* Wed Feb 26 2020 Rafael dos Santos - 0.13.0-1 +- Rebase to latest upstream version (#1805072) + +* Tue Jan 28 2020 Fedora Release Engineering - 0.12.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Mon Jan 06 2020 Tom Stellard - 0.12.0-2 +- Link against libclang-cpp.so +- https://fedoraproject.org/wiki/Changes/Stop-Shipping-Individual-Component-Libraries-In-clang-lib-Package + +* Tue Dec 17 2019 Rafael dos Santos - 0.12.0-1 +- Rebase to latest upstream version (#1758417) + +* Thu Dec 05 2019 Jiri Olsa - 0.11.0-2 +- Add libbpf support + +* Fri Oct 04 2019 Rafael dos Santos - 0.11.0-1 +- Rebase to latest upstream version (#1758417) + +* Thu Oct 03 2019 Miro Hrončok - 0.10.0-4 +- Rebuilt for Python 3.8.0rc1 (#1748018) + +* Mon Aug 19 2019 Miro Hrončok - 0.10.0-3 +- Rebuilt for Python 3.8 + +* Wed Jul 24 2019 Fedora Release Engineering - 0.10.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Wed May 29 2019 Rafael dos Santos - 0.10.0-1 +- Rebase to latest upstream version (#1714902) + +* Thu Apr 25 2019 Rafael dos Santos - 0.9.0-1 +- Rebase to latest upstream version (#1686626) +- Rename libbpf header to libbcc_bpf + +* Mon Apr 22 2019 Neal Gompa - 0.8.0-5 +- Make the Python 3 bindings package noarch +- Small cleanups to the spec + +* Tue Mar 19 2019 Rafael dos Santos - 0.8.0-4 +- Add s390x support (#1679310) + +* Wed Feb 20 2019 Rafael dos Santos - 0.8.0-3 +- Add aarch64 support (#1679310) + +* Thu Jan 31 2019 Fedora Release Engineering - 0.8.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Thu Jan 17 2019 Rafael dos Santos - 0.8.0-1 +- Rebase to new released version + +* Thu Nov 01 2018 Rafael dos Santos - 0.7.0-4 +- Fix attaching to usdt probes (#1634684) + +* Mon Oct 22 2018 Rafael dos Santos - 0.7.0-3 +- Fix encoding of non-utf8 characters (#1516678) +- Fix str-bytes conversion in killsnoop (#1637515) + +* Sat Oct 06 2018 Rafael dos Santos - 0.7.0-2 +- Fix str/bytes conversion in uflow (#1636293) + +* Tue Sep 25 2018 Rafael Fonseca - 0.7.0-1 +- Rebase to new released version + +* Wed Aug 22 2018 Rafael Fonseca - 0.6.1-2 +- Fix typo when mangling shebangs. + +* Thu Aug 16 2018 Rafael Fonseca - 0.6.1-1 +- Rebase to new released version (#1609485) + +* Thu Jul 12 2018 Fedora Release Engineering - 0.6.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Tue Jun 19 2018 Miro Hrončok - 0.6.0-2 +- Rebuilt for Python 3.7 + +* Mon Jun 18 2018 Rafael dos Santos - 0.6.0-1 +- Rebase to new released version (#1591989) + +* Thu Apr 05 2018 Rafael Santos - 0.5.0-4 +- Resolves #1555627 - fix compilation error with latest llvm/clang + +* Wed Feb 07 2018 Fedora Release Engineering - 0.5.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Fri Feb 02 2018 Igor Gnatenko - 0.5.0-2 +- Switch to %%ldconfig_scriptlets + +* Wed Jan 03 2018 Rafael Santos - 0.5.0-1 +- Rebase to new released version + +* Thu Nov 16 2017 Rafael Santos - 0.4.0-4 +- Resolves #1517408 - avoid conflict with other manpages + +* Thu Nov 02 2017 Rafael Santos - 0.4.0-3 +- Use weak deps to not require lua subpkg on ppc64(le) + +* Wed Nov 01 2017 Igor Gnatenko - 0.4.0-2 +- Rebuild for LLVM5 + +* Wed Nov 01 2017 Rafael Fonseca - 0.4.0-1 +- Resolves #1460482 - rebase to new release +- Resolves #1505506 - add support for LLVM 5.0 +- Resolves #1460482 - BPF module compilation issue +- Partially address #1479990 - location of man pages +- Enable ppc64(le) support without lua +- Soname versioning for libbpf by ignatenkobrain + +* Wed Aug 02 2017 Fedora Release Engineering - 0.3.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 0.3.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Thu Mar 30 2017 Igor Gnatenko - 0.3.0-2 +- Rebuild for LLVM4 +- Trivial fixes in spec + +* Fri Mar 10 2017 Rafael Fonseca - 0.3.0-1 +- Rebase to new release. + +* Fri Feb 10 2017 Fedora Release Engineering - 0.2.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Tue Jan 10 2017 Rafael Fonseca - 0.2.0-2 +- Fix typo + +* Tue Nov 29 2016 Rafael Fonseca - 0.2.0-1 +- Initial import