Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753121AbbKCLA6 (ORCPT ); Tue, 3 Nov 2015 06:00:58 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:2432 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752751AbbKCLAy (ORCPT ); Tue, 3 Nov 2015 06:00:54 -0500 From: Wang Nan To: CC: , , , Wang Nan Subject: [PATCH 0/5] perf bpf: Improve error code delivering and output Date: Tue, 3 Nov 2015 10:44:41 +0000 Message-ID: <1446547486-229499-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.563893E4.00A1,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ecd40ab6ad34a5d1632495041b1c41d7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3774 Lines: 110 This patchset is based on tip/core. Arnaldo found some confusing error reports when reviewing BPF related patches. This patch set makes some changes: - 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/