linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] perf bpf: Improve error code delivering and output
@ 2015-11-03 10:44 Wang Nan
  2015-11-03 10:44 ` [PATCH 1/5] perf test: Keep test result clean if '-v' not set Wang Nan
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Wang Nan @ 2015-11-03 10:44 UTC (permalink / raw)
  To: acme; +Cc: lizefan, pi3orama, linux-kernel, Wang Nan

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 [<options>] [<command>]
     or: perf record [<options>] -- <command> [<options>]

     -e, --event <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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-11-08  7:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-03 10:44 [PATCH 0/5] perf bpf: Improve error code delivering and output Wang Nan
2015-11-03 10:44 ` [PATCH 1/5] perf test: Keep test result clean if '-v' not set Wang Nan
2015-11-03 11:19   ` Namhyung Kim
2015-11-08  7:27   ` [tip:perf/urgent] " tip-bot for Wang Nan
2015-11-03 10:44 ` [PATCH 2/5] perf tools: Mute libbpf when " Wang Nan
2015-11-03 10:49   ` Wangnan (F)
2015-11-08  7:27   ` [tip:perf/urgent] perf bpf: " tip-bot for Wang Nan
2015-11-03 10:44 ` [PATCH 3/5] perf tools: Parsing libbpf return value using err.h Wang Nan
2015-11-03 15:17   ` Arnaldo Carvalho de Melo
2015-11-03 15:20     ` Arnaldo Carvalho de Melo
2015-11-03 10:44 ` [PATCH 4/5] bpf tools: Improve libbpf error reporting Wang Nan
2015-11-03 10:44 ` [PATCH 5/5] perf tools: Improve BPF related error messages output Wang Nan
2015-11-03 15:43 ` [PATCH 0/5] perf bpf: Improve error code delivering and output Arnaldo Carvalho de Melo
2015-11-04  1:43   ` Wangnan (F)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).