Commit 5d05dfd1 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-urgent-for-mingo-4.19-20180918' of...

Merge tag 'perf-urgent-for-mingo-4.19-20180918' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

 - Fix the build on !_GNU_SOURCE libc systems such as Alpine Linux/musl
   libc due to usage of strerror_r glibc variant on libbpf (Arnaldo Carvalho de Melo)

 - Fix out-of-tree asciidoctor man page generation (Ben Hutchings)
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents f21f7fa2 169e366c
libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o str_error.o
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "libbpf.h" #include "libbpf.h"
#include "bpf.h" #include "bpf.h"
#include "btf.h" #include "btf.h"
#include "str_error.h"
#ifndef EM_BPF #ifndef EM_BPF
#define EM_BPF 247 #define EM_BPF 247
...@@ -469,7 +470,7 @@ static int bpf_object__elf_init(struct bpf_object *obj) ...@@ -469,7 +470,7 @@ static int bpf_object__elf_init(struct bpf_object *obj)
obj->efile.fd = open(obj->path, O_RDONLY); obj->efile.fd = open(obj->path, O_RDONLY);
if (obj->efile.fd < 0) { if (obj->efile.fd < 0) {
char errmsg[STRERR_BUFSIZE]; char errmsg[STRERR_BUFSIZE];
char *cp = strerror_r(errno, errmsg, sizeof(errmsg)); char *cp = str_error(errno, errmsg, sizeof(errmsg));
pr_warning("failed to open %s: %s\n", obj->path, cp); pr_warning("failed to open %s: %s\n", obj->path, cp);
return -errno; return -errno;
...@@ -810,8 +811,7 @@ static int bpf_object__elf_collect(struct bpf_object *obj) ...@@ -810,8 +811,7 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
data->d_size, name, idx); data->d_size, name, idx);
if (err) { if (err) {
char errmsg[STRERR_BUFSIZE]; char errmsg[STRERR_BUFSIZE];
char *cp = strerror_r(-err, errmsg, char *cp = str_error(-err, errmsg, sizeof(errmsg));
sizeof(errmsg));
pr_warning("failed to alloc program %s (%s): %s", pr_warning("failed to alloc program %s (%s): %s",
name, obj->path, cp); name, obj->path, cp);
...@@ -1140,7 +1140,7 @@ bpf_object__create_maps(struct bpf_object *obj) ...@@ -1140,7 +1140,7 @@ bpf_object__create_maps(struct bpf_object *obj)
*pfd = bpf_create_map_xattr(&create_attr); *pfd = bpf_create_map_xattr(&create_attr);
if (*pfd < 0 && create_attr.btf_key_type_id) { if (*pfd < 0 && create_attr.btf_key_type_id) {
cp = strerror_r(errno, errmsg, sizeof(errmsg)); cp = str_error(errno, errmsg, sizeof(errmsg));
pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n", pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
map->name, cp, errno); map->name, cp, errno);
create_attr.btf_fd = 0; create_attr.btf_fd = 0;
...@@ -1155,7 +1155,7 @@ bpf_object__create_maps(struct bpf_object *obj) ...@@ -1155,7 +1155,7 @@ bpf_object__create_maps(struct bpf_object *obj)
size_t j; size_t j;
err = *pfd; err = *pfd;
cp = strerror_r(errno, errmsg, sizeof(errmsg)); cp = str_error(errno, errmsg, sizeof(errmsg));
pr_warning("failed to create map (name: '%s'): %s\n", pr_warning("failed to create map (name: '%s'): %s\n",
map->name, cp); map->name, cp);
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
...@@ -1339,7 +1339,7 @@ load_program(enum bpf_prog_type type, enum bpf_attach_type expected_attach_type, ...@@ -1339,7 +1339,7 @@ load_program(enum bpf_prog_type type, enum bpf_attach_type expected_attach_type,
} }
ret = -LIBBPF_ERRNO__LOAD; ret = -LIBBPF_ERRNO__LOAD;
cp = strerror_r(errno, errmsg, sizeof(errmsg)); cp = str_error(errno, errmsg, sizeof(errmsg));
pr_warning("load bpf program failed: %s\n", cp); pr_warning("load bpf program failed: %s\n", cp);
if (log_buf && log_buf[0] != '\0') { if (log_buf && log_buf[0] != '\0') {
...@@ -1654,7 +1654,7 @@ static int check_path(const char *path) ...@@ -1654,7 +1654,7 @@ static int check_path(const char *path)
dir = dirname(dname); dir = dirname(dname);
if (statfs(dir, &st_fs)) { if (statfs(dir, &st_fs)) {
cp = strerror_r(errno, errmsg, sizeof(errmsg)); cp = str_error(errno, errmsg, sizeof(errmsg));
pr_warning("failed to statfs %s: %s\n", dir, cp); pr_warning("failed to statfs %s: %s\n", dir, cp);
err = -errno; err = -errno;
} }
...@@ -1690,7 +1690,7 @@ int bpf_program__pin_instance(struct bpf_program *prog, const char *path, ...@@ -1690,7 +1690,7 @@ int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
} }
if (bpf_obj_pin(prog->instances.fds[instance], path)) { if (bpf_obj_pin(prog->instances.fds[instance], path)) {
cp = strerror_r(errno, errmsg, sizeof(errmsg)); cp = str_error(errno, errmsg, sizeof(errmsg));
pr_warning("failed to pin program: %s\n", cp); pr_warning("failed to pin program: %s\n", cp);
return -errno; return -errno;
} }
...@@ -1708,7 +1708,7 @@ static int make_dir(const char *path) ...@@ -1708,7 +1708,7 @@ static int make_dir(const char *path)
err = -errno; err = -errno;
if (err) { if (err) {
cp = strerror_r(-err, errmsg, sizeof(errmsg)); cp = str_error(-err, errmsg, sizeof(errmsg));
pr_warning("failed to mkdir %s: %s\n", path, cp); pr_warning("failed to mkdir %s: %s\n", path, cp);
} }
return err; return err;
...@@ -1770,7 +1770,7 @@ int bpf_map__pin(struct bpf_map *map, const char *path) ...@@ -1770,7 +1770,7 @@ int bpf_map__pin(struct bpf_map *map, const char *path)
} }
if (bpf_obj_pin(map->fd, path)) { if (bpf_obj_pin(map->fd, path)) {
cp = strerror_r(errno, errmsg, sizeof(errmsg)); cp = str_error(errno, errmsg, sizeof(errmsg));
pr_warning("failed to pin map: %s\n", cp); pr_warning("failed to pin map: %s\n", cp);
return -errno; return -errno;
} }
......
// SPDX-License-Identifier: LGPL-2.1
#undef _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include "str_error.h"
/*
* Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl
* libc, while checking strerror_r() return to avoid having to check this in
* all places calling it.
*/
char *str_error(int err, char *dst, int len)
{
int ret = strerror_r(err, dst, len);
if (ret)
snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret);
return dst;
}
// SPDX-License-Identifier: LGPL-2.1
#ifndef BPF_STR_ERROR
#define BPF_STR_ERROR
char *str_error(int err, char *dst, int len);
#endif // BPF_STR_ERROR
...@@ -280,7 +280,7 @@ $(MAN_HTML): $(OUTPUT)%.html : %.txt ...@@ -280,7 +280,7 @@ $(MAN_HTML): $(OUTPUT)%.html : %.txt
mv $@+ $@ mv $@+ $@
ifdef USE_ASCIIDOCTOR ifdef USE_ASCIIDOCTOR
$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.txt $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : %.txt
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
$(ASCIIDOC) -b manpage -d manpage \ $(ASCIIDOC) -b manpage -d manpage \
$(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment