Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964890AbbKCPnT (ORCPT ); Tue, 3 Nov 2015 10:43:19 -0500 Received: from mail.kernel.org ([198.145.29.136]:41332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964839AbbKCPnP (ORCPT ); Tue, 3 Nov 2015 10:43:15 -0500 Date: Tue, 3 Nov 2015 12:43:00 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: lizefan@huawei.com, pi3orama@163.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/5] perf bpf: Improve error code delivering and output Message-ID: <20151103154259.GR21609@kernel.org> References: <1446547486-229499-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1446547486-229499-1-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4175 Lines: 117 Em Tue, Nov 03, 2015 at 10:44:41AM +0000, Wang Nan escreveu: > This patchset is based on tip/core. > > Arnaldo found some confusing error reports when reviewing BPF related > patches. This patch set makes some changes: Thanks for working on this! I applied the first two and made comments about the conversion to using err.h, please check, - Arnaldo > - perf test only print ok, failed or skip. Extra messages can be seen > by '-v'. > > - libbpf not output anything when called from perf without '-v'. > > - Create libbpf and bpf-loader specific error number group to deliver > precise error. New strerror framework makes adding new error code > easier. > > - Improve error messages. > > After applying this patch: > > When target object not exist: > > $ ls ./foo.o > ls: cannot access ./foo.o: No such file or directory > $ ./perf record --event foo.o sleep > event syntax error: 'foo.o' > \___ Failed to load foo.o: No such file or directory > > (add -v to see detail) > Run 'perf list' for a list of valid events > > Usage: perf record [] [] > or: perf record [] -- [] > > -e, --event event selector. use 'perf list' to list available events > > When target object format invalid: > > $ cp /etc/passwd ./badbpf.o > $ ./perf record --event ./badbpf.o sleep > event syntax error: './badbpf.o' > \___ Failed to load ./badbpf.o: BPF object format invalid > (... skip ...) > > When run by normal user and /proc/sys/kernel/kptr_restrict is 1: > > $ cat /proc/sys/kernel/kptr_restrict > 1 > $ ./perf record --event ./bpf-script-example.o sleep > Failed to init vmlinux path. > event syntax error: './bpf-script-example.o' > \___ You need to be root, and /proc/sys/kernel/kptr_restrict should be 0 > (... skip ...) > > After fixing /proc/sys/kernel/kptr_restrict: > > $ sudo -s > # echo 0 > /proc/sys/kernel/kptr_restrict > # exit > $ ./perf record --event ./bpf-script-example.o sleep > Failed to open kprobe_events: Permission denied > event syntax error: './bpf-script-example.o' > \___ You need to be root > (... skip ...) > > Load an object with no 'version' section: > > # ./perf record --event ./bpf-script-example.o sleep > event syntax error: './bpf-script-example.o' > \___ Failed to load ./bpf-script-example.o: 'version' section incorrect or lost > (... skip ...) > > Load an object with incorrect 'version' section: > # ./perf record --event ./bpf-script-example.o sleep > event syntax error: './bpf-script-example.o' > \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object > (... skip ...) > > When event name not set: > > # ./perf record --event ./bpf-script-example.o sleep > event syntax error: './bpf-script-example.o' > \___ No event name found in config string > (... skip ...) > > Wang Nan (5): > perf test: Keep test result clean if '-v' not set > perf tools: Mute libbpf when '-v' not set > perf tools: Parsing libbpf return value using err.h > bpf tools: Improve libbpf error reporting > perf tools: Improve BPF related error messages output > > tools/lib/bpf/libbpf.c | 149 +++++++++++++++++++++++++------------ > tools/lib/bpf/libbpf.h | 12 +++ > tools/perf/tests/attr.c | 3 +- > tools/perf/tests/code-reading.c | 8 +- > tools/perf/tests/keep-tracking.c | 4 +- > tools/perf/tests/llvm.c | 13 ++-- > tools/perf/tests/switch-tracking.c | 4 +- > tools/perf/util/bpf-loader.c | 110 +++++++++++++++++++++++---- > tools/perf/util/bpf-loader.h | 18 +++++ > tools/perf/util/parse-events.c | 7 +- > 10 files changed, 243 insertions(+), 85 deletions(-) > > -- > 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/