diff options
author | Wang Nan <wangnan0@huawei.com> | 2015-11-06 13:58:09 +0000 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-11-06 17:14:20 -0300 |
commit | d3e0ce393057cfa907a0c4fe7b1ff56d5c30cca5 (patch) | |
tree | abd8dc974a4323430790c78edfc917c4e0a330ad /tools/perf/util/util.h | |
parent | 07bc5c699a3d8fe5e26dbcd72e4103c7988055ba (diff) | |
download | lwn-d3e0ce393057cfa907a0c4fe7b1ff56d5c30cca5.tar.gz lwn-d3e0ce393057cfa907a0c4fe7b1ff56d5c30cca5.zip |
perf bpf: Improve BPF related error messages
A series of bpf loader related error codes were introduced to help error
reporting. Functions were improved to return these new error codes.
Functions which return pointers were adjusted to encode error codes into
return value using the ERR_PTR() interface.
bpf_loader_strerror() was improved to convert these error messages to
strings. It checks the error codes and calls libbpf_strerror() and
strerror_r() accordingly, so caller don't need to consider checking the
range of the error code.
In bpf__strerror_load(), print kernel version of running kernel and the
object's 'version' section to notify user how to fix his/her program.
v1 -> v2:
Use macro for error code.
Fetch error message based on array index, eliminate for-loop.
Print version strings.
Before:
# perf record -e ./test_kversion_nomatch_program.o sleep 1
event syntax error: './test_kversion_nomatch_program.o'
\___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
SKIP
After:
# perf record -e ./test_kversion_nomatch_program.o ls
event syntax error: './test_kversion_nomatch_program.o'
\___ 'version' (4.4.0) doesn't match running kernel (4.3.0)
SKIP
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1446818289-87444-1-git-send-email-wangnan0@huawei.com
[ Add 'static inline' to bpf__strerror_prepare_load() when LIBBPF is disabled ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.h')
-rw-r--r-- | tools/perf/util/util.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 2665126267dc..dcc659017976 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -352,5 +352,10 @@ int get_stack_size(const char *str, unsigned long *_size); int fetch_kernel_version(unsigned int *puint, char *str, size_t str_sz); +#define KVER_VERSION(x) (((x) >> 16) & 0xff) +#define KVER_PATCHLEVEL(x) (((x) >> 8) & 0xff) +#define KVER_SUBLEVEL(x) ((x) & 0xff) +#define KVER_FMT "%d.%d.%d" +#define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) #endif /* GIT_COMPAT_UTIL_H */ |