Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Thomas writes:
"- Provide a strerror_r wrapper so lib/bpf can be built on systems
without _GNU_SOURCE
- Unbreak the man page generator when building out of tree"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf Documentation: Fix out-of-tree asciidoctor man page generation
tools lib bpf: Provide wrapper for strerror_r to build in !_GNU_SOURCE systems

+36 -12
+1 -1
tools/lib/bpf/Build
··· 1 - libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o 1 + libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o str_error.o
+10 -10
tools/lib/bpf/libbpf.c
··· 50 50 #include "libbpf.h" 51 51 #include "bpf.h" 52 52 #include "btf.h" 53 + #include "str_error.h" 53 54 54 55 #ifndef EM_BPF 55 56 #define EM_BPF 247 ··· 470 469 obj->efile.fd = open(obj->path, O_RDONLY); 471 470 if (obj->efile.fd < 0) { 472 471 char errmsg[STRERR_BUFSIZE]; 473 - char *cp = strerror_r(errno, errmsg, sizeof(errmsg)); 472 + char *cp = str_error(errno, errmsg, sizeof(errmsg)); 474 473 475 474 pr_warning("failed to open %s: %s\n", obj->path, cp); 476 475 return -errno; ··· 811 810 data->d_size, name, idx); 812 811 if (err) { 813 812 char errmsg[STRERR_BUFSIZE]; 814 - char *cp = strerror_r(-err, errmsg, 815 - sizeof(errmsg)); 813 + char *cp = str_error(-err, errmsg, sizeof(errmsg)); 816 814 817 815 pr_warning("failed to alloc program %s (%s): %s", 818 816 name, obj->path, cp); ··· 1140 1140 1141 1141 *pfd = bpf_create_map_xattr(&create_attr); 1142 1142 if (*pfd < 0 && create_attr.btf_key_type_id) { 1143 - cp = strerror_r(errno, errmsg, sizeof(errmsg)); 1143 + cp = str_error(errno, errmsg, sizeof(errmsg)); 1144 1144 pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n", 1145 1145 map->name, cp, errno); 1146 1146 create_attr.btf_fd = 0; ··· 1155 1155 size_t j; 1156 1156 1157 1157 err = *pfd; 1158 - cp = strerror_r(errno, errmsg, sizeof(errmsg)); 1158 + cp = str_error(errno, errmsg, sizeof(errmsg)); 1159 1159 pr_warning("failed to create map (name: '%s'): %s\n", 1160 1160 map->name, cp); 1161 1161 for (j = 0; j < i; j++) ··· 1339 1339 } 1340 1340 1341 1341 ret = -LIBBPF_ERRNO__LOAD; 1342 - cp = strerror_r(errno, errmsg, sizeof(errmsg)); 1342 + cp = str_error(errno, errmsg, sizeof(errmsg)); 1343 1343 pr_warning("load bpf program failed: %s\n", cp); 1344 1344 1345 1345 if (log_buf && log_buf[0] != '\0') { ··· 1654 1654 1655 1655 dir = dirname(dname); 1656 1656 if (statfs(dir, &st_fs)) { 1657 - cp = strerror_r(errno, errmsg, sizeof(errmsg)); 1657 + cp = str_error(errno, errmsg, sizeof(errmsg)); 1658 1658 pr_warning("failed to statfs %s: %s\n", dir, cp); 1659 1659 err = -errno; 1660 1660 } ··· 1690 1690 } 1691 1691 1692 1692 if (bpf_obj_pin(prog->instances.fds[instance], path)) { 1693 - cp = strerror_r(errno, errmsg, sizeof(errmsg)); 1693 + cp = str_error(errno, errmsg, sizeof(errmsg)); 1694 1694 pr_warning("failed to pin program: %s\n", cp); 1695 1695 return -errno; 1696 1696 } ··· 1708 1708 err = -errno; 1709 1709 1710 1710 if (err) { 1711 - cp = strerror_r(-err, errmsg, sizeof(errmsg)); 1711 + cp = str_error(-err, errmsg, sizeof(errmsg)); 1712 1712 pr_warning("failed to mkdir %s: %s\n", path, cp); 1713 1713 } 1714 1714 return err; ··· 1770 1770 } 1771 1771 1772 1772 if (bpf_obj_pin(map->fd, path)) { 1773 - cp = strerror_r(errno, errmsg, sizeof(errmsg)); 1773 + cp = str_error(errno, errmsg, sizeof(errmsg)); 1774 1774 pr_warning("failed to pin map: %s\n", cp); 1775 1775 return -errno; 1776 1776 }
+18
tools/lib/bpf/str_error.c
··· 1 + // SPDX-License-Identifier: LGPL-2.1 2 + #undef _GNU_SOURCE 3 + #include <string.h> 4 + #include <stdio.h> 5 + #include "str_error.h" 6 + 7 + /* 8 + * Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl 9 + * libc, while checking strerror_r() return to avoid having to check this in 10 + * all places calling it. 11 + */ 12 + char *str_error(int err, char *dst, int len) 13 + { 14 + int ret = strerror_r(err, dst, len); 15 + if (ret) 16 + snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); 17 + return dst; 18 + }
+6
tools/lib/bpf/str_error.h
··· 1 + // SPDX-License-Identifier: LGPL-2.1 2 + #ifndef BPF_STR_ERROR 3 + #define BPF_STR_ERROR 4 + 5 + char *str_error(int err, char *dst, int len); 6 + #endif // BPF_STR_ERROR
+1 -1
tools/perf/Documentation/Makefile
··· 280 280 mv $@+ $@ 281 281 282 282 ifdef USE_ASCIIDOCTOR 283 - $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.txt 283 + $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : %.txt 284 284 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 285 285 $(ASCIIDOC) -b manpage -d manpage \ 286 286 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \