1. 30 5月, 2020 1 次提交
    • S
      perf tools: Add optional support for libpfm4 · 70943490
      Stephane Eranian 提交于
      This patch links perf with the libpfm4 library if it is available and
      LIBPFM4 is passed to the build. The libpfm4 library contains hardware
      event tables for all processors supported by perf_events. It is a helper
      library that helps convert from a symbolic event name to the event
      encoding required by the underlying kernel interface. This library is
      open-source and available from: http://perfmon2.sf.net.
      
      With this patch, it is possible to specify full hardware events by name.
      Hardware filters are also supported. Events must be specified via the
      --pfm-events and not -e option. Both options are active at the same time
      and it is possible to mix and match:
      
        $ perf stat --pfm-events inst_retired:any_p:c=1:i -e cycles ....
      
      One needs to explicitely ask for its inclusion by using the LIBPFM4 make
      command line option, ie its opt-in rather than opt-out of feature
      detection and build support.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: yuzhoujian <yuzhoujian@didichuxing.com>
      Link: http://lore.kernel.org/lkml/20200505182943.218248-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      70943490
  2. 28 5月, 2020 1 次提交
    • N
      perf tests: Add test for the java demangler · 525c821d
      Nick Gasson 提交于
      Split from a larger patch that was also fixing a problem with the java
      demangler, so, before applying that patch we see:
      
        $ perf test java
        65: Demangle Java                                         : FAILED!
        $ perf test -v java
        65: Demangle Java                                         :
        --- start ---
        test child forked, pid 307264
        FAILED: Ljava/lang/StringLatin1;equals([B[B)Z: bool class java.lang.StringLatin1.equals(byte[], byte[]) != boolean java.lang.StringLatin1.equals(byte[], byte[])
        FAILED: Ljava/util/zip/ZipUtils;CENSIZ([BI)J: long class java.util.zip.ZipUtils.CENSIZ(byte[], int) != long java.util.zip.ZipUtils.CENSIZ(byte[], int)
        FAILED: Ljava/util/regex/Pattern$BmpCharProperty;match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z: bool class java.util.regex.Pattern$BmpCharProperty.match(class java.util.regex.Matcher., int, class java.lang., charhar, shortequence) != boolean java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence)
        FAILED: Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V: void class java.lang.AbstractStringBuilder.appendChars(class java.lang., shorttring., int, int) != void java.lang.AbstractStringBuilder.appendChars(java.lang.String, int, int)
        FAILED: Ljava/lang/Object;<init>()V: void class java.lang.Object<init>() != void java.lang.Object<init>()
        test child finished with -1
        ---- end ----
        Demangle Java: FAILED!
        $
      
      Next patch should fix this.
      Signed-off-by: NNick Gasson <nick.gasson@arm.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200427061520.24905-4-nick.gasson@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      525c821d
  3. 30 4月, 2020 1 次提交
  4. 24 3月, 2020 1 次提交
    • J
      perf test: Add pmu-events test · a6c925fd
      John Garry 提交于
      The initial test will verify that the test tables in generated pmu-events.c
      match against known, expected values.
      
      For known events added in pmu-events/arch/test, we need to add an entry
      in test_cpu_aliases_events[] or test_uncore_events[].
      
      A sample run is as follows for x86:
      
        john@linux-3c19:~/linux> tools/perf/perf test -vv 10
        10: PMU event aliases                                     :
        --- start ---
        test child forked, pid 5316
        testing event table bp_l1_btb_correct: pass
        testing event table bp_l2_btb_correct: pass
        testing event table segment_reg_loads.any: pass
        testing event table dispatch_blocked.any: pass
        testing event table eist_trans: pass
        testing event table uncore_hisi_ddrc.flux_wcmd: pass
        testing event table unc_cbo_xsnp_response.miss_eviction: pass
        test child finished with 0
        ---- end ----
        PMU event aliases: Ok
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linuxarm@huawei.com
      [ Fixup test_cpu_events[] and test_uncore_events[] sentinels to initialize one of its members to NULL, fixing the build in older compilers ]
      Link: http://lore.kernel.org/lkml/1584442939-8911-5-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a6c925fd
  5. 29 11月, 2019 1 次提交
    • I
      perf jit: Move test functionality in to a test · fa7f7e73
      Ian Rogers 提交于
      Adds a test for minimal jit_write_elf functionality.
      
      Committer testing:
      
        # perf test jit
        61: Test jit_write_elf                                    : Ok
        #
      
        # perf test -v jit
        61: Test jit_write_elf                                    :
        --- start ---
        test child forked, pid 10460
        Writing jit code to: /tmp/perf-test-KqxURR
        test child finished with 0
        ---- end ----
        Test jit_write_elf: Ok
        #
      
      Committer notes:
      
      Fix up the case where HAVE_JITDUMP is no defined.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexios Zavras <alexios.zavras@intel.com>
      Cc: Allison Randal <allison@lohutok.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lore.kernel.org/lkml/20191126235913.41855-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fa7f7e73
  6. 26 11月, 2019 2 次提交
  7. 18 6月, 2019 1 次提交
  8. 11 6月, 2019 1 次提交
    • A
      perf tests: Add a test for time-utils · e39a12cb
      Adrian Hunter 提交于
      Test time ranges work as expected.
      
      Committer testing:
      
        $ perf test "time utils"
        59: time utils                                            : Ok
        $ perf test -v "time utils"
        59: time utils                                            :
        --- start ---
        test child forked, pid 31711
      
        parse_nsec_time("0")
        0
      
        parse_nsec_time("1")
        1000000000
      
        parse_nsec_time("0.000000001")
        1
      
        parse_nsec_time("1.000000001")
        1000000001
      
        parse_nsec_time("123456.123456")
        123456123456000
      
        parse_nsec_time("1234567.123456789")
        1234567123456789
      
        parse_nsec_time("18446744073.709551615")
        18446744073709551615
      
        perf_time__parse_str("1234567.123456789,1234567.123456789")
        start time 1234567123456789, end time 1234567123456789
      
        perf_time__parse_str("1234567.123456789,1234567.123456790")
        start time 1234567123456789, end time 1234567123456790
      
        perf_time__parse_str("1234567.123456789,")
        start time 1234567123456789, end time 0
      
        perf_time__parse_str(",1234567.123456789")
        start time 0, end time 1234567123456789
      
        perf_time__parse_str("0,1234567.123456789")
        start time 0, end time 1234567123456789
      
        perf_time__parse_for_ranges("1234567.123456789,1234567.123456790")
        start time 1234567123456789, end time 1234567123456790
      
        perf_time__parse_for_ranges("10%/1")
        first_sample_time 7654321000000000 last_sample_time 7654321000000100
        start time 0: 7654321000000000, end time 0: 7654321000000009
      
        perf_time__parse_for_ranges("10%/2")
        first_sample_time 7654321000000000 last_sample_time 7654321000000100
        start time 0: 7654321000000010, end time 0: 7654321000000019
      
        perf_time__parse_for_ranges("10%/1,10%/2")
        first_sample_time 11223344000000000 last_sample_time 11223344000000100
        start time 0: 11223344000000000, end time 0: 11223344000000009
        start time 1: 11223344000000010, end time 1: 11223344000000019
      
        perf_time__parse_for_ranges("10%/1,10%/3,10%/10")
        first_sample_time 11223344000000000 last_sample_time 11223344000000100
        start time 0: 11223344000000000, end time 0: 11223344000000009
        start time 1: 11223344000000020, end time 1: 11223344000000029
        start time 2: 11223344000000090, end time 2: 11223344000000100
      
        test child finished with 0
        ---- end ----
        time utils: Ok
        $
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20190604130017.31207-19-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e39a12cb
  9. 29 5月, 2019 1 次提交
  10. 19 9月, 2018 1 次提交
  11. 17 3月, 2018 1 次提交
  12. 13 3月, 2018 1 次提交
    • J
      perf tests: Add breakpoint accounting/modify test · 032db28e
      Jiri Olsa 提交于
      Adding test that:
      
        - detects the number of watch/break-points,
          skip test if any is missing
        - detects PERF_EVENT_IOC_MODIFY_ATTRIBUTES ioctl,
          skip test if it's missing
        - detects if watchpoints and breakpoints share
          same slots
        - create all possible watchpoints on cpu 0
        - change one of it to breakpoint
        - in case wp and bp do not share slots,
          we create another watchpoint to ensure
          the slot accounting is correct
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Hari Bathini <hbathini@linux.vnet.ibm.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Milind Chabbi <chabbi.milind@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <onestero@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Link: http://lkml.kernel.org/r/20180312134548.31532-9-jolsa@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      032db28e
  13. 23 8月, 2017 1 次提交
  14. 15 6月, 2017 1 次提交
    • J
      perf tools: Fix build with ARCH=x86_64 · 7a759cd8
      Jiada Wang 提交于
      With commit: 0a943cb1 (tools build: Add HOSTARCH Makefile variable)
      when building for ARCH=x86_64, ARCH=x86_64 is passed to perf instead of
      ARCH=x86, so the perf build process searchs header files from
      tools/arch/x86_64/include, which doesn't exist.
      
      The following build failure is seen:
      
        In file included from util/event.c:2:0:
          tools/include/uapi/linux/mman.h:4:27: fatal error: uapi/asm/mman.h: No such file or directory
          compilation terminated.
      
      Fix this issue by using SRCARCH instead of ARCH in perf, just like the
      main kernel Makefile and tools/objtool's.
      Signed-off-by: NJiada Wang <jiada_wang@mentor.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Eugeniu Rosca <erosca@de.adit-jv.com>
      Cc: Jan Stancek <jstancek@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Rui Teng <rui.teng@linux.vnet.ibm.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 0a943cb1 ("tools build: Add HOSTARCH Makefile variable")
      Link: http://lkml.kernel.org/r/1491793357-14977-2-git-send-email-jiada_wang@mentor.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7a759cd8
  15. 23 3月, 2017 1 次提交
    • A
      perf tools: Add a simple expression parser for JSON · 07516736
      Andi Kleen 提交于
      Add a simple expression parser good enough to parse JSON relation
      expressions. The parser is implemented using bison.
      
      This is just intended as an simple parser for internal usage in the
      event lists, not the beginning of a "perf scripting language"
      
      v2: Use expr__ prefix instead of expr_
          Support multiple free variables for parser
      
      Committer note:
      
      The v2 patch had:
      
        %define api.pure full
      
      In expr.y, that is a feature introduced in bison 2.7, to have reentrant
      parsers, not using global variables, which would make tools/perf stop
      building with the bison version shipped in older distros, so Andi
      realised that the other parsers (e.g. parse-events.y) were using:
      
        %pure-parser
      
      Which is present in older versions of bison and fits the bill.
      
      I added:
      
        CFLAGS_expr-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w
      
      To finally make it build, copying what was there for pmu-bison.o,
      another parser.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/20170320201711.14142-8-andi@firstfloor.org
      [ stdlib.h is needed in tests/expr.c for free() fixing build in systems such as ubuntu:16.04-x-s390 ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      07516736
  16. 12 1月, 2017 1 次提交
  17. 06 12月, 2016 1 次提交
    • W
      perf clang: Add builtin clang support ant test case · 00b86691
      Wang Nan 提交于
      Add basic clang support in clang.cpp and test__clang() testcase. The
      first testcase checks if builtin clang is able to generate LLVM IR.
      
      tests/clang.c is a proxy. Real testcase resides in
      utils/c++/clang-test.cpp in c++ and exports C interface to perf test
      subsystem.
      
      Test result:
      
         $ perf test -v clang
         51: builtin clang support                               :
         51.1: Test builtin clang compile C source to IR              :
         --- start ---
         test child forked, pid 13215
         test child finished with 0
         ---- end ----
         Test builtin clang support subtest 0: Ok
      
      Committer note:
      
      Make sure you've enabled CLANG and LLVM builtin support by setting
      the LIBCLANGLLVM variable on the make command line, e.g.:
      
        make LIBCLANGLLVM=1 O=/tmp/build/perf -C tools/perf install-bin
      
      Otherwise you'll get this when trying to do the 'perf test' call above:
      
        # perf test clang
        51: builtin clang support                      : Skip (not compiled in)
        #
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Joe Stringer <joe@ovn.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/20161126070354.141764-11-wangnan0@huawei.com
      [ Removed "Test" from descriptions, redundant and already removed from all the other entries ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      00b86691
  18. 29 11月, 2016 1 次提交
    • W
      perf tools: Introduce perf hooks · a074865e
      Wang Nan 提交于
      Perf hooks allow hooking user code at perf events. They can be used for
      manipulation of BPF maps, taking snapshot and reporting results. In this
      patch two perf hook points are introduced: record_start and record_end.
      
      To avoid buggy user actions, a SIGSEGV signal handler is introduced into
      'perf record'. It turns off perf hook if it causes a segfault and report
      an error to help debugging.
      
      A test case for perf hook is introduced.
      
      Test result:
        $ ./buildperf/perf test -v hook
        50: Test perf hooks                                          :
        --- start ---
        test child forked, pid 10311
        SIGSEGV is observed as expected, try to recover.
        Fatal error (SEGFAULT) in perf hook 'test'
        test child finished with 0
        ---- end ----
        Test perf hooks: Ok
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Joe Stringer <joe@ovn.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/20161126070354.141764-5-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a074865e
  19. 29 9月, 2016 1 次提交
  20. 03 8月, 2016 1 次提交
  21. 19 7月, 2016 1 次提交
  22. 14 7月, 2016 1 次提交
  23. 10 5月, 2016 1 次提交
  24. 30 3月, 2016 1 次提交
    • J
      perf tests: Add test to check for event times · b31d660d
      Jiri Olsa 提交于
      This test creates software event 'cpu-clock' attaches it in several ways
      and checks that enabled and running times match.
      
      Committer notes:
      
      Testing it:
      
        [acme@jouet linux]$ perf test -v times
        44: Test events times                                        :
        --- start ---
        test child forked, pid 27170
        attaching to spawned child, enable on exec
          OK    : ena 307328, run 307328
        attaching to current thread as enabled
          OK    : ena 7826, run 7826
        attaching to current thread as disabled
          OK    : ena 738, run 738
        attaching to CPU 0 as enabled
          SKIP  : not enough rights
        attaching to CPU 0 as enabled
          SKIP  : not enough rights
        test child finished with -2
        ---- end ----
        Test events times: Skip
        [acme@jouet linux]$
      
        [root@jouet ~]# perf test times
        44: Test events times                                        : Ok
        [root@jouet ~]# perf test -v times
        44: Test events times                                        :
        --- start ---
        test child forked, pid 27306
        attaching to spawned child, enable on exec
          OK    : ena 479290, run 479290
        attaching to current thread as enabled
          OK    : ena 11356, run 11356
        attaching to current thread as disabled
          OK    : ena 987, run 987
        attaching to CPU 0 as enabled
          OK    : ena 3717, run 3717
        attaching to CPU 0 as enabled
          OK    : ena 2323, run 2323
        test child finished with 0
        ---- end ----
        Test events times: Ok
        [root@jouet ~]#
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1458823940-24583-7-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b31d660d
  25. 26 1月, 2016 1 次提交
    • W
      perf test: Add libbpf relocation checker · 7b6982ce
      Wang Nan 提交于
      There's a bug in LLVM that it can generate unneeded relocation
      information. See [1] and [2]. Libbpf should check the target section of
      a relocation symbol.
      
      This patch adds a testcase which references a global variable (BPF
      doesn't support global variables). Before fixing libbpf, the new test
      case can be loaded into kernel, the global variable acts like the first
      map. It is incorrect.
      
      Result:
      
        # ~/perf test BPF
        37: Test BPF filter                                          :
        37.1: Test basic BPF filtering                               : Ok
        37.2: Test BPF prologue generation                           : Ok
        37.3: Test BPF relocation checker                            : FAILED!
      
        # ~/perf test -v BPF
        ...
        libbpf: loading object '[bpf_relocation_test]' from buffer
        libbpf: section .strtab, size 126, link 0, flags 0, type=3
        libbpf: section .text, size 0, link 0, flags 6, type=1
        libbpf: section .data, size 0, link 0, flags 3, type=1
        libbpf: section .bss, size 0, link 0, flags 3, type=8
        libbpf: section func=sys_write, size 104, link 0, flags 6, type=1
        libbpf: found program func=sys_write
        libbpf: section .relfunc=sys_write, size 16, link 10, flags 0, type=9
        libbpf: section maps, size 16, link 0, flags 3, type=1
        libbpf: maps in [bpf_relocation_test]: 16 bytes
        libbpf: section license, size 4, link 0, flags 3, type=1
        libbpf: license of [bpf_relocation_test] is GPL
        libbpf: section version, size 4, link 0, flags 3, type=1
        libbpf: kernel version of [bpf_relocation_test] is 40400
        libbpf: section .symtab, size 144, link 1, flags 0, type=2
        libbpf: map 0 is "my_table"
        libbpf: collecting relocating info for: 'func=sys_write'
        libbpf: relocation: insn_idx=7
        Success unexpectedly: libbpf error when dealing with relocation
        test child finished with -1
        ---- end ----
        Test BPF filter subtest 2: FAILED!
      
      [1] https://llvm.org/bugs/show_bug.cgi?id=26243
      [2] https://patchwork.ozlabs.org/patch/571385/Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1453715801-7732-2-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b6982ce
  26. 18 12月, 2015 3 次提交
  27. 14 12月, 2015 1 次提交
  28. 19 11月, 2015 1 次提交
    • W
      perf test: Test the BPF prologue adding infrastructure · bbb7d492
      Wang Nan 提交于
      This patch introduces a new BPF script to test the BPF prologue adding
      routines. The new script probes at null_lseek, which is the function pointer
      used when we try to lseek on '/dev/null'.
      
      The null_lseek function is chosen because it is used by function pointers, so
      we don't need to consider inlining and LTO.
      
      By extracting file->f_mode, bpf-script-test-prologue.c should know whether the
      file is writable or readonly. According to llseek_loop() and
      bpf-script-test-prologue.c, one fourth of total lseeks should be collected.
      
      Committer note:
      
      Testing it:
      
        # perf test -v BPF
        <SNIP>
        Kernel build dir is set to /lib/modules/4.3.0+/build
        set env: KBUILD_DIR=/lib/modules/4.3.0+/build
        unset env: KBUILD_OPTS
        include option is set to  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include -I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude -I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/git/linux/include/uapi -Iinclude/generated/uapi -include /home/git/linux/include/linux/kconfig.h
        set env: NR_CPUS=4
        set env: LINUX_VERSION_CODE=0x40300
        set env: CLANG_EXEC=/usr/libexec/icecc/bin/clang
        set env: CLANG_OPTIONS=-xc
        set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include -I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude -I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/git/linux/include/uapi -Iinclude/generated/uapi -include /home/git/linux/include/linux/kconfig.h
        set env: WORKING_DIR=/lib/modules/4.3.0+/build
        set env: CLANG_SOURCE=-
        llvm compiling command template: echo '/*
         * bpf-script-test-prologue.c
         * Test BPF prologue
         */
        #ifndef LINUX_VERSION_CODE
        # error Need LINUX_VERSION_CODE
        # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
        #endif
        #define SEC(NAME) __attribute__((section(NAME), used))
      
        #include <uapi/linux/fs.h>
      
        #define FMODE_READ		0x1
        #define FMODE_WRITE		0x2
      
        static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =
      	  (void *) 6;
      
        SEC("func=null_lseek file->f_mode offset orig")
        int bpf_func__null_lseek(void *ctx, int err, unsigned long f_mode,
      			   unsigned long offset, unsigned long orig)
        {
      	  if (err)
      		  return 0;
      	  if (f_mode & FMODE_WRITE)
      		  return 0;
      	  if (offset & 1)
      		  return 0;
      	  if (orig == SEEK_CUR)
      		  return 0;
      	  return 1;
        }
      
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        ' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o -
        libbpf: loading object '[bpf_prologue_test]' from buffer
        libbpf: section .strtab, size 135, link 0, flags 0, type=3
        libbpf: section .text, size 0, link 0, flags 6, type=1
        libbpf: section .data, size 0, link 0, flags 3, type=1
        libbpf: section .bss, size 0, link 0, flags 3, type=8
        libbpf: section func=null_lseek file->f_mode offset orig, size 112, link 0, flags 6, type=1
        libbpf: found program func=null_lseek file->f_mode offset orig
        libbpf: section license, size 4, link 0, flags 3, type=1
        libbpf: license of [bpf_prologue_test] is GPL
        libbpf: section version, size 4, link 0, flags 3, type=1
        libbpf: kernel version of [bpf_prologue_test] is 40300
        libbpf: section .symtab, size 168, link 1, flags 0, type=2
        bpf: config program 'func=null_lseek file->f_mode offset orig'
        symbol:null_lseek file:(null) line:0 offset:0 return:0 lazy:(null)
        parsing arg: file->f_mode into file, f_mode(1)
        parsing arg: offset into offset
        parsing arg: orig into orig
        bpf: config 'func=null_lseek file->f_mode offset orig' is ok
        Looking at the vmlinux_path (7 entries long)
        Using /lib/modules/4.3.0+/build/vmlinux for symbols
        Open Debuginfo file: /lib/modules/4.3.0+/build/vmlinux
        Try to find probe point from debuginfo.
        Matched function: null_lseek
        Probe point found: null_lseek+0
        Searching 'file' variable in context.
        Converting variable file into trace event.
        converting f_mode in file
        f_mode type is unsigned int.
        Searching 'offset' variable in context.
        Converting variable offset into trace event.
        offset type is long long int.
        Searching 'orig' variable in context.
        Converting variable orig into trace event.
        orig type is int.
        Found 1 probe_trace_events.
        Opening /sys/kernel/debug/tracing//kprobe_events write=1
        Writing event: p:perf_bpf_probe/func _text+4840528 f_mode=+68(%di):u32 offset=%si:s64 orig=%dx:s32
        libbpf: don't need create maps for [bpf_prologue_test]
        prologue: pass validation
        prologue: slow path
        prologue: fetch arg 0, base reg is %di
        prologue: arg 0: offset 68
        prologue: fetch arg 1, base reg is %si
        prologue: fetch arg 2, base reg is %dx
        add bpf event perf_bpf_probe:func and attach bpf program 3
        adding perf_bpf_probe:func
        adding perf_bpf_probe:func to 0x51672c0
        mmap size 1052672B
        Opening /sys/kernel/debug/tracing//kprobe_events write=1
        Opening /sys/kernel/debug/tracing//uprobe_events write=1
        Parsing probe_events: p:perf_bpf_probe/func _text+4840528 f_mode=+68(%di):u32 offset=%si:s64 orig=%dx:s32
        Group:perf_bpf_probe Event:func probe:p
        Writing event: -:perf_bpf_probe/func
        test child finished with 0
        ---- end ----
        Test BPF filter: Ok
        #
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1447675815-166222-13-git-send-email-wangnan0@huawei.com
      [ Added tools/perf/tests/llvm-src-prologue.c to .gitignore ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bbb7d492
  29. 07 11月, 2015 3 次提交
    • W
      perf test: Add 'perf test BPF' · ba1fae43
      Wang Nan 提交于
      This patch adds BPF testcase for testing BPF event filtering.
      
      By utilizing the result of 'perf test LLVM', this patch compiles the
      eBPF sample program then test its ability. The BPF script in 'perf test
      LLVM' lets only 50% samples generated by epoll_pwait() to be captured.
      This patch runs that system call for 111 times, so the result should
      contain 56 samples.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      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/1446817783-86722-8-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ba1fae43
    • W
      perf test: Enhance the LLVM tests: add kbuild test · 7af3f3d5
      Wang Nan 提交于
      This patch adds a kbuild testcase to check whether kernel headers can be
      correctly found.
      
      For example:
        # mv /lib/modules/4.3.0-rc5{,.bak}
        # perf test LLVM
      
          38: Test LLVM searching and compiling                        : Skip
      
        # perf test -v LLVM
        ...
        <stdin>:11:10: fatal error: 'uapi/linux/fs.h' file not found
        #include <uapi/linux/fs.h>
                ^
        1 error generated.
        ERROR:	unable to compile -
        Hint:	Check error message shown above.
        Hint:	You can also pre-compile it into .o using:
           		 clang -target bpf -O2 -c -
      	 with proper -I and -D options.
        Failed to compile test case: 'Test kbuild searching'
        test child finished with -2
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo 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/1446817783-86722-7-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7af3f3d5
    • W
      perf test: Enhance the LLVM test: update basic BPF test program · b31de018
      Wang Nan 提交于
      This patch replaces the original toy BPF program with the previously
      introduced bpf-script-example.c. Dynamically embeddeding it into
      'llvm-src-base.c'.
      
      The newly introduced BPF program attaches a BPF program to
      'sys_epoll_pwait()'. perf itself never use that syscall, so further test
      can verify their result with it. The program would generate 1 sample in
      every 2 calls of epoll_pwait() system call.
      
      Since the resulting BPF object is useful per se for further tests,
      test_llvm__fetch_bpf_obj() is introduced for creating BPF objects from
      source. The LLVM test was rewritten to use it.
      
      Committer note:
      
      Running it:
      
        [root@zoo wb]# perf test -v LLVM
        35: Test LLVM searching and compiling                        :
        --- start ---
        test child forked, pid 17740
        Kernel build dir is set to /lib/modules/4.3.0-rc1+/build
        set env: KBUILD_DIR=/lib/modules/4.3.0-rc1+/build
        unset env: KBUILD_OPTS
        include option is set to  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include -I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude -I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/git/linux/include/uapi -Iinclude/generated/uapi -include /home/git/linux/include/linux/kconfig.h
        set env: NR_CPUS=4
        set env: LINUX_VERSION_CODE=0x40300
        set env: CLANG_EXEC=/usr/libexec/icecc/bin/clang
        set env: CLANG_OPTIONS=-xc
        set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include -I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude -I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/git/linux/include/uapi -Iinclude/generated/uapi -include /home/git/linux/include/linux/kconfig.h
        set env: WORKING_DIR=/lib/modules/4.3.0-rc1+/build
        set env: CLANG_SOURCE=-
        llvm compiling command template: echo '/*
         * bpf-script-example.c
         * Test basic LLVM building
         */
        #ifndef LINUX_VERSION_CODE
        # error Need LINUX_VERSION_CODE
        # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
        #endif
        #define BPF_ANY 0
        #define BPF_MAP_TYPE_ARRAY 2
        #define BPF_FUNC_map_lookup_elem 1
        #define BPF_FUNC_map_update_elem 2
      
        static void *(*bpf_map_lookup_elem)(void *map, void *key) =
      	  (void *) BPF_FUNC_map_lookup_elem;
        static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =
      	  (void *) BPF_FUNC_map_update_elem;
      
        struct bpf_map_def {
      	  unsigned int type;
      	  unsigned int key_size;
      	  unsigned int value_size;
      	  unsigned int max_entries;
        };
      
        #define SEC(NAME) __attribute__((section(NAME), used))
        struct bpf_map_def SEC("maps") flip_table = {
      	  .type = BPF_MAP_TYPE_ARRAY,
      	  .key_size = sizeof(int),
      	  .value_size = sizeof(int),
      	  .max_entries = 1,
        };
      
        SEC("func=sys_epoll_pwait")
        int bpf_func__sys_epoll_pwait(void *ctx)
        {
      	  int ind =0;
      	  int *flag = bpf_map_lookup_elem(&flip_table, &ind);
      	  int new_flag;
      	  if (!flag)
      		  return 0;
      	  /* flip flag and store back */
      	  new_flag = !*flag;
      	  bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);
      	  return new_flag;
        }
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        ' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o -
        test child finished with 0
        ---- end ----
        Test LLVM searching and compiling: Ok
        [root@zoo wb]#
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo 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/1446817783-86722-6-git-send-email-wangnan0@huawei.comSigned-off-by: NHe Kuang <hekuang@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b31de018
  30. 06 10月, 2015 1 次提交
  31. 14 9月, 2015 1 次提交
  32. 04 9月, 2015 1 次提交
    • A
      perf tools: Add a test for decoding of new x86 instructions · 98e4619f
      Adrian Hunter 提交于
      Add a new test titled:
      
      	Test x86 instruction decoder - new instructions
      
      The purpose of this test is to check the instruction decoder after new
      instructions have been added.  Initially, MPX instructions are tested
      which are already supported, but the definitions in x86-opcode-map.txt
      will be tweaked in a subsequent patch, after which this test can be run
      to verify those changes.
      
      The data for the test comes from assembly language instructions in
      insn-x86-dat-src.c which is converted into bytes by the scripts
      gen-insn-x86-dat.sh and gen-insn-x86-dat.awk, and included into the test
      program insn-x86.c as insn-x86-dat-32.c and insn-x86-dat-64.c.
      
      The conversion is not done as part of the perf tools build because the
      test data must be under (git) change control in order for the test to be
      repeatably-correct.  Also it may require a recent version of binutils.
      
      Commiter notes:
      
      Using it:
      
        # perf test decoder
        39: Test x86 instruction decoder - new instructions          : Ok
        # perf test -v decoder
        39: Test x86 instruction decoder - new instructions          :
        --- start ---
        test child forked, pid 21970
        Decoded ok: 0f 31                	rdtsc
        Decoded ok: f3 0f 1b 00          	bndmk  (%eax),%bnd0
        Decoded ok: f3 0f 1b 05 78 56 34 12 	bndmk  0x12345678,%bnd0
        Decoded ok: f3 0f 1b 18          	bndmk  (%eax),%bnd3
        <SNIP>
        Decoded ok: f2 e9 00 00 00 00    	bnd jmpq 402 <main+0x402>
        Decoded ok: f2 e9 00 00 00 00    	bnd jmpq 408 <main+0x408>
        Decoded ok: 67 f2 ff 21          	bnd jmpq *(%ecx)
        Decoded ok: f2 0f 85 00 00 00 00 	bnd jne 413 <main+0x413>
        test child finished with 0
        ---- end ----
        Test x86 instruction decoder - new instructions: Ok
        #
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qiaowei Ren <qiaowei.ren@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1441196131-20632-3-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      98e4619f
  33. 07 8月, 2015 1 次提交
    • W
      perf tests: Add LLVM test for eBPF on-the-fly compiling · 9bc898c7
      Wang Nan 提交于
      Previous patches introduce llvm__compile_bpf() to compile source file to
      eBPF object. This patch adds testcase to test it. It also tests libbpf
      by opening generated object after applying next patch which introduces
      HAVE_LIBBPF_SUPPORT option.
      
      Since llvm__compile_bpf() prints long messages which users who don't
      explicitly test llvm doesn't care, this patch set verbose to -1 to
      suppress all debug, warning and error message, and hint user use 'perf
      test -v' to see the full output.
      
      For the same reason, if clang is not found in PATH and there's no [llvm]
      section in .perfconfig, skip this test.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/n/1436445342-1402-17-git-send-email-wangnan0@huawei.com
      [ Add tools/lib/bpf/ to tools/perf/MANIFEST, so that the tarball targets build ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9bc898c7
  34. 26 6月, 2015 1 次提交
  35. 29 5月, 2015 1 次提交