1. 28 5月, 2020 33 次提交
    • A
      perf intel-pt: Use allocated branch stack for PEBS sample · 961224db
      Adrian Hunter 提交于
      To avoid having struct branch_stack as a non-last structure member,
      use allocated branch stack for PEBS sample.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: NGustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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/2540ed9a-89f1-6d59-10c9-a66cc90db5d2@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      961224db
    • A
      perf tool: Make perf tool aware of SELinux access control · c1034eb0
      Alexey Budankov 提交于
      Implement selinux sysfs check to see the system is in enforcing mode and
      print warning message with pointer to check audit logs.
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-security-module@vger.kernel.org
      Cc: selinux@vger.kernel.org
      Link: http://lore.kernel.org/lkml/819338ce-d160-4a2f-f1aa-d756a2e7c6fc@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c1034eb0
    • I
      perf expr: Migrate expr ids table to a hashmap · ded80bda
      Ian Rogers 提交于
      Use a hashmap between a char* string and a double* value. While bpf's
      hashmap entries are size_t in size, we can't guarantee sizeof(size_t) >=
      sizeof(double). Avoid a memory allocation when gathering ids by making
      0.0 a special value encoded as NULL.
      
      Original map suggestion by Andi Kleen:
      
        https://lore.kernel.org/lkml/20200224210308.GQ160988@tassilo.jf.intel.com/
      
      and seconded by Jiri Olsa:
      
        https://lore.kernel.org/lkml/20200423112915.GH1136647@krava/
      
      Committer notes:
      
      There are fixes that need to land upstream before we can use libbpf's
      headers, for now use our copy unconditionally, since the data structures
      at this point are exactly the same, no problem.
      
      When the fixes for libbpf's hashmap land upstream, we can fix this up.
      
      Testing it:
      
      Building with LIBBPF=1, i.e. the default:
      
        $ perf -vv | grep -i bpf
                           bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
        $ nm ~/bin/perf | grep -i libbpf_ | wc -l
        39
        $ nm ~/bin/perf | grep -i hashmap_ | wc -l
        17
        $
      
      Explicitely building without LIBBPF:
      
        $ perf -vv | grep -i bpf
                           bpf: [ OFF ]  # HAVE_LIBBPF_SUPPORT
        $
        $ nm ~/bin/perf | grep -i libbpf_ | wc -l
        0
        $ nm ~/bin/perf | grep -i hashmap_ | wc -l
        9
        $
      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: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: kp singh <kpsingh@chromium.org>
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200515221732.44078-8-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ded80bda
    • I
      perf tools: Grab a copy of libbpf's hashmap · eee19501
      Ian Rogers 提交于
      Allow use of hashmap in perf. Modify perf's check-headers.sh script to
      check that the files are kept in sync, in the same way kernel headers
      are checked. This will warn if they are out of sync at the start of a
      perf build.
      
      Committer note:
      
      This starts out of synch as a fix went thru the bpf tree, namely the one
      removing the needless libbpf_internal.h include in hashmap.h.
      
      There is also another change related to __WORDSIZE, that as is in
      tools/lib/bpf/hashmap.h causes the tools/perf/ build to fail in systems
      such as Alpine Linus, that uses the Musl libc, so we need an alternative
      way of having __WORDSIZE available, use the one used by
      tools/include/linux/bitops.h, that builds in all the systems I have
      build containers for.
      
      These differences will be resolved at some point, so keep the warning in
      check-headers.sh as a reminder.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndrii Nakryiko <andriin@fb.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: kp singh <kpsingh@chromium.org>
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200515221732.44078-5-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      eee19501
    • I
      perf parse-events: Make add PMU verbose output clearer · 4ac22b48
      Ian Rogers 提交于
      On a CPU like skylakex an uncore_iio_0 PMU may alias with
      uncore_iio_free_running_0. The latter PMU doesn't support fc_mask as a
      parameter and so pmu_config_term fails. Typically parse_events_add_pmu
      is called in a loop where if one alias succeeds errors are ignored,
      however, if multiple errors occur parse_events__handle_error will
      currently give a WARN_ONCE.
      
      This change removes the WARN_ONCE in parse_events__handle_error and
      makes it a pr_debug. It adds verbose messages to parse_events_add_pmu
      warning that non-fatal errors may occur, while giving details on the pmu
      and config terms for useful context. pmu_config_term is altered so the
      failing term and pmu are present in the case of the 'unknown term' error
      which makes spotting the free_running case more straightforward.
      
      Before:
      
        $ perf --debug verbose=3 stat -M llc_misses.pcie_read sleep 1
        Using CPUID GenuineIntel-6-55-4
        metric expr unc_iio_data_req_of_cpu.mem_read.part0 + unc_iio_data_req_of_cpu.mem_read.part1 + unc_iio_data_req_of_cpu.mem_read.part2 + unc_iio_data_req_of_cpu.mem_read.part3 for LLC_MISSES.PCIE_READ
        found event unc_iio_data_req_of_cpu.mem_read.part0
        found event unc_iio_data_req_of_cpu.mem_read.part1
        found event unc_iio_data_req_of_cpu.mem_read.part2
        found event unc_iio_data_req_of_cpu.mem_read.part3
        metric expr unc_iio_data_req_of_cpu.mem_read.part0 + unc_iio_data_req_of_cpu.mem_read.part1 + unc_iio_data_req_of_cpu.mem_read.part2 + unc_iio_data_req_of_cpu.mem_read.part3 for LLC_MISSES.PCIE_READ
        found event unc_iio_data_req_of_cpu.mem_read.part0
        found event unc_iio_data_req_of_cpu.mem_read.part1
        found event unc_iio_data_req_of_cpu.mem_read.part2
        found event unc_iio_data_req_of_cpu.mem_read.part3
        adding {unc_iio_data_req_of_cpu.mem_read.part0,unc_iio_data_req_of_cpu.mem_read.part1,unc_iio_data_req_of_cpu.mem_read.part2,unc_iio_data_req_of_cpu.mem_read.part3}:W,{unc_iio_data_req_of_cpu.mem_read.part0,unc_iio_data_req_of_cpu.mem_read.part1,unc_iio_data_req_of_cpu.mem_read.part2,unc_iio_data_req_of_cpu.mem_read.part3}:W
        intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch
        WARNING: multiple event parsing errors
        ...
        Invalid event/parameter 'fc_mask'
        ...
      
      After:
      
        $ perf --debug verbose=3 stat -M llc_misses.pcie_read sleep 1
        Using CPUID GenuineIntel-6-55-4
        metric expr unc_iio_data_req_of_cpu.mem_read.part0 + unc_iio_data_req_of_cpu.mem_read.part1 + unc_iio_data_req_of_cpu.mem_read.part2 + unc_iio_data_req_of_cpu.mem_read.part3 for LLC_MISSES.PCIE_READ
        found event unc_iio_data_req_of_cpu.mem_read.part0
        found event unc_iio_data_req_of_cpu.mem_read.part1
        found event unc_iio_data_req_of_cpu.mem_read.part2
        found event unc_iio_data_req_of_cpu.mem_read.part3
        metric expr unc_iio_data_req_of_cpu.mem_read.part0 + unc_iio_data_req_of_cpu.mem_read.part1 + unc_iio_data_req_of_cpu.mem_read.part2 + unc_iio_data_req_of_cpu.mem_read.part3 for LLC_MISSES.PCIE_READ
        found event unc_iio_data_req_of_cpu.mem_read.part0
        found event unc_iio_data_req_of_cpu.mem_read.part1
        found event unc_iio_data_req_of_cpu.mem_read.part2
        found event unc_iio_data_req_of_cpu.mem_read.part3
        adding {unc_iio_data_req_of_cpu.mem_read.part0,unc_iio_data_req_of_cpu.mem_read.part1,unc_iio_data_req_of_cpu.mem_read.part2,unc_iio_data_req_of_cpu.mem_read.part3}:W,{unc_iio_data_req_of_cpu.mem_read.part0,unc_iio_data_req_of_cpu.mem_read.part1,unc_iio_data_req_of_cpu.mem_read.part2,unc_iio_data_req_of_cpu.mem_read.part3}:W
        intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch
        Attempting to add event pmu 'uncore_iio_free_running_5' with 'unc_iio_data_req_of_cpu.mem_read.part0,' that may result in non-fatal errors
        After aliases, add event pmu 'uncore_iio_free_running_5' with 'fc_mask,ch_mask,umask,event,' that may result in non-fatal errors
        Attempting to add event pmu 'uncore_iio_free_running_3' with 'unc_iio_data_req_of_cpu.mem_read.part0,' that may result in non-fatal errors
        After aliases, add event pmu 'uncore_iio_free_running_3' with 'fc_mask,ch_mask,umask,event,' that may result in non-fatal errors
        Attempting to add event pmu 'uncore_iio_free_running_1' with 'unc_iio_data_req_of_cpu.mem_read.part0,' that may result in non-fatal errors
        After aliases, add event pmu 'uncore_iio_free_running_1' with 'fc_mask,ch_mask,umask,event,' that may result in non-fatal errors
        Multiple errors dropping message: unknown term 'fc_mask' for pmu 'uncore_iio_free_running_3' (valid terms: event,umask,config,config1,config2,name,period,percore)
        ...
      
        So before you see a 'WARNING: multiple event parsing errors' and
        'Invalid event/parameter'. After you see 'Attempting... that may result
        in non-fatal errors' then 'Multiple errors...' with details that
        'fc_mask' wasn't known to a free running counter. While not completely
        clean, this makes it clearer that an error hasn't really occurred.
      
      v2. addresses review feedback from Jiri Olsa <jolsa@redhat.com>.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.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: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lore.kernel.org/lkml/20200513220635.54700-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4ac22b48
    • I
      perf expr: Fix memory leaks in metric bison · 63657578
      Ian Rogers 提交于
      Add a destructor for strings to reclaim memory in the event of errors.
      Free the ID given for a lookup, it was previously strdup-ed in the lex
      code.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200513000318.15166-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      63657578
    • A
      perf evsel: Initialize evsel->per_pkg_mask to NULL in evsel__init() · f0aef475
      Arnaldo Carvalho de Melo 提交于
      Just like with the other fields, this probably isn't fixing anything
      observable as evsel__new() uses zalloc() for the whole 'struct evsel',
      but since evsels can be embedded in larger structures and maybe those
      larger structures don't use zalloc() for some reason, init it to NULL
      just in case.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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>
      Cc: Stephane Eranian <eranian@google.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f0aef475
    • I
      perf evsel: Fix 2 memory leaks · 3efc899d
      Ian Rogers 提交于
      If allocated, perf_pkg_mask and metric_events need freeing.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.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>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200512235918.10732-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3efc899d
    • A
      perf parse-events: Fix incorrect conversion of 'if () free()' to 'zfree()' · 7fcdccd4
      Arnaldo Carvalho de Melo 提交于
      When applying a patch by Ian I incorrectly converted to zfree() an
      expression that involved testing some other struct member, not the one
      being freed, which lead to bugs reproduceable by:
      
        $ perf stat -e i/bs,tsc,L2/o sleep 1
        WARNING: multiple event parsing errors
        Segmentation fault (core dumped)
        $
      
      Fix it by restoring the test for pos->free_str before freeing
      pos->val.str, but continue using zfree(&pos->val.str) to set that member
      to NULL after freeing it.
      Reported-by: NIan Rogers <irogers@google.com>
      Fixes: e8dfb818 ("perf parse-events: Fix memory leaks found on parse_events")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: clang-built-linux@googlegroups.com
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7fcdccd4
    • J
      perf tools: Fix is_bpf_image function logic · e12a89ef
      Jiri Olsa 提交于
      Adrian reported that is_bpf_image is not working the way it was intended
      - passing on trampolines and dispatcher names. Instead it returned true
      for all the bpf names.
      
      The reason even this logic worked properly is that all bpf objects, even
      trampolines and dispatcher, were assigned DSO_BINARY_TYPE__BPF_IMAGE
      binary_type.
      
      The later for bpf_prog objects, the binary_type was fixed in bpf load
      event processing, which is executed after the ksymbol code.
      
      Fixing the is_bpf_image logic, so it properly recognizes trampoline and
      dispatcher objects.
      
      Fixes: 3c29d448 ("perf annotate: Add basic support for bpf_image")
      Reported-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200512122310.3154754-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e12a89ef
    • I
      perf c2c: Fix 'perf c2c record -e list' to show the default events used · b027cc6f
      Ian Rogers 提交于
      When the event is passed as list, the default events should be listed as
      per 'perf mem record -e list'. Previous behavior is:
      
        $ perf c2c record -e list
        failed: event 'list' not found, use '-e list' to get list of available events
      
         Usage: perf c2c record [<options>] [<command>]
            or: perf c2c record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event selector. Use 'perf mem record -e list' to list available events
        $
      
      New behavior:
      
        $ perf c2c record -e list
        ldlat-loads  : available
        ldlat-stores : available
      
      v3: is a rebase.
      v2: addresses review comments by Jiri Olsa.
      
      https://lore.kernel.org/lkml/20191127081844.GH32367@krava/Signed-off-by: NIan Rogers <irogers@google.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: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200507220604.3391-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b027cc6f
    • I
      perf evsel: Dummy events never triggers, no need to ask for PERF_SAMPLE_BRANCH_STACK · 5885a202
      Ian Rogers 提交于
      A dummy event never triggers any actual counter and therefore cannot be
      used with branch_stack
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200422173615.59436-1-irogers@google.com
      [ split from a larger patch ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5885a202
    • J
      perf parse-events: Use strcmp() to compare the PMU name · 8510895b
      Jin Yao 提交于
      A big uncore event group is split into multiple small groups which only
      include the uncore events from the same PMU. This has been supported in
      the commit 3cdc5c2c ("perf parse-events: Handle uncore event
      aliases in small groups properly").
      
      If the event's PMU name starts to repeat, it must be a new event.
      That can be used to distinguish the leader from other members.
      But now it only compares the pointer of pmu_name
      (leader->pmu_name == evsel->pmu_name).
      
      If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex,
      the event list is:
      
        evsel->name					evsel->pmu_name
        ---------------------------------------------------------------
        unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_4 (as leader)
        unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_2
        unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_0
        unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_5
        unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_3
        unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_1
        unc_iio_data_req_of_cpu.mem_write.part1		uncore_iio_4
        ......
      
      For the event "unc_iio_data_req_of_cpu.mem_write.part1" with
      "uncore_iio_4", it should be the event from PMU "uncore_iio_4".
      It's not a new leader for this PMU.
      
      But if we use "(leader->pmu_name == evsel->pmu_name)", the check
      would be failed and the event is stored to leaders[] as a new
      PMU leader.
      
      So this patch uses strcmp to compare the PMU name between events.
      
      Fixes: d4953f7e ("perf parse-events: Fix 3 use after frees found with clang ASAN")
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200430003618.17002-1-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8510895b
    • P
      perf stat: Increase perf metric output resolution · d4d5ca0b
      Paul A. Clarke 提交于
      Add another digit of precision to the perf metrics output.
      
      Before:
      
        $ /usr/bin/perf stat --metrics run_cpi /bin/ls
        [...]
                 4,345,526      pm_run_cyc                #      1.1 run_cpi
                 3,818,069      pm_run_inst_cmpl
        [...]
        $ /usr/bin/perf stat --metrics run_cpi --metric-only /bin/ls
        [...]
                     run_cpi
                         1.1
        [...]
      
      After:
      
        $ perf stat --metrics run_cpi /bin/ls
        [...]
                 4,280,882      pm_run_cyc                #     1.12 run_cpi
                 3,817,016      pm_run_inst_cmpl
        [...]
        $ perf stat --metrics run_cpi --metric-only /bin/ls
        [...]
                     run_cpi
                        1.06
        [...]
      
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NPaul Clarke <pc@us.ibm.com>
      LPU-Reference: 1588861087-31280-1-git-send-email-pc@us.ibm.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d4d5ca0b
    • I
      perf expr: Print a debug message for division by zero · 9be27a5d
      Ian Rogers 提交于
      If an expression yields 0 and is then divided-by/modulus-by then the
      parsing aborts. Add a debug error message to better enable debugging
      when this happens.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Haiyan Song <haiyanx.song@intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200501173333.227162-11-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9be27a5d
    • I
      perf expr: Debug lex if debugging yacc · e5e0e635
      Ian Rogers 提交于
      Only effects parser debugging (disabled by default). Enables displaying
      '--accepting rule at line .. ("...").
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Haiyan Song <haiyanx.song@intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200501173333.227162-8-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e5e0e635
    • I
      perf expr: Parse numbers as doubles · 7db2fd0b
      Ian Rogers 提交于
      This is expected in expr.y and metrics use floating point values such as
      x86 broadwell IFetch_Line_Utilization.
      
      Fixes: 26226a97 (perf expr: Move expr lexer to flex)
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NKajol Jain <kjain@linux.ibm.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Haiyan Song <haiyanx.song@intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.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: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200501173333.227162-7-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7db2fd0b
    • I
      perf expr: Increase max other · f59d3f84
      Ian Rogers 提交于
      Large metrics such as Branch_Misprediction_Cost_SMT on x86 broadwell
      need more space.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Haiyan Song <haiyanx.song@intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200501173333.227162-6-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f59d3f84
    • I
      perf expr: Allow ',' to be an other token · cb59fa79
      Ian Rogers 提交于
      Corrects parse errors in expr__find_other of expressions with min.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Haiyan Song <haiyanx.song@intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200501173333.227162-5-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cb59fa79
    • I
      perf expr: Allow for unlimited escaped characters in a symbol · 5b3141d0
      Ian Rogers 提交于
      Current expression allows 2 escaped '-,=' characters. However, some
      metrics require more, for example Haswell DRAM_BW_Use.
      
      Fixes: 26226a97 (perf expr: Move expr lexer to flex)
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Tested-by: NKajol Jain <kjain@linux.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Haiyan Song <haiyanx.song@intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.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: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200501173333.227162-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5b3141d0
    • J
      perf callchain: Setup callchain properly in pipe mode · 0d71a2b2
      Jiri Olsa 提交于
      Callchains are automatically initialized by checking on event's
      sample_type. For pipe mode we need to put this check into attr event
      code.
      
      Moving the callchains setup code into callchain_param_setup function and
      calling it from attr event process code.
      
      This enables pipe output having callchains, like:
      
        # perf record -g -e 'raw_syscalls:sys_enter' true | perf script
        # perf record -g -e 'raw_syscalls:sys_enter' true | perf report
      
      Committer notes:
      
      We still need the next patch for the above output to work.
      Reported-by: NPaul Khuong <pvk@pvk.ca>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200507095024.2789147-5-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0d71a2b2
    • J
      perf session: Try to read pipe data from file · 14d3d540
      Jiri Olsa 提交于
      Ian came with the idea of having support to read the pipe data also from
      file. Currently pipe mode files fail like:
      
        $ perf record -o - sleep 1 > /tmp/perf.pipe.data
        $ perf report -i /tmp/perf.pipe.data
        incompatible file format (rerun with -v to learn more)
      
      This patch adds the support to do that by trying the pipe header first,
      and if its successfully detected, switching the perf data to pipe mode.
      
      Committer testing:
      
        # ls
        # perf record -a -o - sleep 1 > /tmp/perf.pipe.data
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.000 MB - ]
        # ls
        # perf report -i /tmp/perf.pipe.data | head -25
        # To display the perf.data header info, please use --header/--header-only options.
        #
        #
        # Total Lost Samples: 0
        #
        # Samples: 511  of event 'cycles'
        # Event count (approx.): 178447276
        #
        # Overhead  Command   Shared Object      Symbol
        # ........  ........  .................  ...........................................................................................
        #
            65.49%  swapper   [kernel.kallsyms]  [k] native_safe_halt
             6.45%  chromium  libblink_core.so   [.] blink::SelectorChecker::CheckOne
             4.08%  chromium  libblink_core.so   [.] blink::SelectorQuery::ExecuteForTraverseRoot<blink::AllElementsSelectorQueryTrait>
             2.25%  chromium  libblink_core.so   [.] blink::SelectorQuery::FindTraverseRootsAndExecute<blink::AllElementsSelectorQueryTrait>
             2.11%  chromium  libblink_core.so   [.] blink::SelectorChecker::MatchSelector
             1.91%  chromium  libblink_core.so   [.] blink::Node::OwnerShadowHost
             1.31%  chromium  libblink_core.so   [.] blink::Node::parentNode@plt
             1.22%  chromium  libblink_core.so   [.] blink::Node::parentNode
             0.59%  chromium  libblink_core.so   [.] blink::AnyAttributeMatches
             0.58%  chromium  libv8.so           [.] v8::internal::GlobalHandles::Create
             0.58%  chromium  libblink_core.so   [.] blink::NodeTraversal::NextAncestorSibling
             0.55%  chromium  libv8.so           [.] v8::internal::RegExpGlobalCache::RegExpGlobalCache
             0.55%  chromium  libblink_core.so   [.] blink::Node::ContainingShadowRoot
             0.55%  chromium  libblink_core.so   [.] blink::NodeTraversal::NextAncestorSibling@plt
        #
      Original-patch-by: NIan Rogers <irogers@google.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Khuong <pvk@pvk.ca>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200507095024.2789147-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      14d3d540
    • J
      perf tools: Do not seek in pipe fd during tracing data processing · b491198d
      Jiri Olsa 提交于
      There's no need to set 'fd' position in pipe mode, the file descriptor
      is already in proper place. Moreover the lseek will fail on pipe
      descriptor and that's why it's been working properly.
      
      I was tempted to remove the lseek calls completely, because it seems
      that tracing data event was always synthesized only in pipe mode, so
      there's no need for 'file' mode handling. But I guess there was a reason
      behind this and there might (however unlikely) be a perf.data that we
      could break processing for.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Khuong <pvk@pvk.ca>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200507095024.2789147-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b491198d
    • M
      perf probe: Check address correctness by map instead of _etext · 2ae5d0d7
      Masami Hiramatsu 提交于
      Since commit 03db8b58 ("perf tools: Fix
      maps__find_symbol_by_name()") introduced map address range check in
      maps__find_symbol_by_name(), we can not get "_etext" from kernel map
      because _etext is placed on the edge of the kernel .text section (=
      kernel map in perf.)
      
      To fix this issue, this checks the address correctness by map address
      range information (map->start and map->end) instead of using _etext
      address.
      
      This can cause an error if the target inlined function is embedded in
      both __init function and normal function.
      
      For exaample, request_resource() is a normal function but also embedded
      in __init reserve_setup(). In this case, the probe point in
      reserve_setup() must be skipped.
      
      However, without this fix, it failes to setup all probe points:
      
        # ./perf probe -v request_resource
        probe-definition(0): request_resource
        symbol:request_resource file:(null) line:0 offset:0 return:0 lazy:(null)
        0 arguments
        Looking at the vmlinux_path (8 entries long)
        Using /usr/lib/debug/lib/modules/5.5.17-200.fc31.x86_64/vmlinux for symbols
        Open Debuginfo file: /usr/lib/debug/lib/modules/5.5.17-200.fc31.x86_64/vmlinux
        Try to find probe point from debuginfo.
        Matched function: request_resource [15e29ad]
        found inline addr: 0xffffffff82fbf892
        Probe point found: reserve_setup+204
        found inline addr: 0xffffffff810e9790
        Probe point found: request_resource+0
        Found 2 probe_trace_events.
        Opening /sys/kernel/debug/tracing//kprobe_events write=1
        Opening /sys/kernel/debug/tracing//README write=0
        Writing event: p:probe/request_resource _text+33290386
        Failed to write event: Invalid argument
          Error: Failed to add events. Reason: Invalid argument (Code: -22)
        #
      
      With this fix,
      
        # ./perf probe request_resource
        reserve_setup is out of .text, skip it.
        Added new events:
          (null):(null)        (on request_resource)
          probe:request_resource (on request_resource)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:request_resource -aR sleep 1
      
        #
      
      Fixes: 03db8b58 ("perf tools: Fix maps__find_symbol_by_name()")
      Reported-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/158763967332.30755.4922496724365529088.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2ae5d0d7
    • M
      perf probe: Fix to check blacklist address correctly · 80526491
      Masami Hiramatsu 提交于
      Fix to check kprobe blacklist address correctly with relocated address
      by adjusting debuginfo address.
      
      Since the address in the debuginfo is same as objdump, it is different
      from relocated kernel address with KASLR.  Thus, 'perf probe' always
      misses to catch the blacklisted addresses.
      
      Without this patch, 'perf probe' can not detect the blacklist addresses
      on a KASLR enabled kernel.
      
        # perf probe kprobe_dispatcher
        Failed to write event: Invalid argument
          Error: Failed to add events.
        #
      
      With this patch, it correctly shows the error message.
      
        # perf probe kprobe_dispatcher
        kprobe_dispatcher is blacklisted function, skip it.
        Probe point 'kprobe_dispatcher' not found.
          Error: Failed to add events.
        #
      
      Fixes: 9aaf5a5f ("perf probe: Check kprobes blacklist when adding new events")
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/158763966411.30755.5882376357738273695.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      80526491
    • M
      perf probe: Accept the instance number of kretprobe event · c6aab66a
      Masami Hiramatsu 提交于
      Since the commit 6a13a0d7 ("ftrace/kprobe: Show the maxactive number
      on kprobe_events") introduced to show the instance number of kretprobe
      events, the length of the 1st format of the kprobe event will not 1, but
      it can be longer.  This caused a parser error in perf-probe.
      
      Skip the length check the 1st format of the kprobe event to accept this
      instance number.
      
      Without this fix:
      
        # perf probe -a vfs_read%return
        Added new event:
          probe:vfs_read__return (on vfs_read%return)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:vfs_read__return -aR sleep 1
      
        # perf probe -l
        Semantic error :Failed to parse event name: r16:probe/vfs_read__return
          Error: Failed to show event list.
      
      And with this fixes:
      
        # perf probe -a vfs_read%return
        ...
        # perf probe -l
          probe:vfs_read__return (on vfs_read%return)
      
      Fixes: 6a13a0d7 ("ftrace/kprobe: Show the maxactive number on kprobe_events")
      Reported-by: NYuxuan Shui <yshuiv7@gmail.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NYuxuan Shui <yshuiv7@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: stable@vger.kernel.org
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207587
      Link: http://lore.kernel.org/lkml/158877535215.26469.1113127926699134067.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c6aab66a
    • A
      perf counts: Rename perf_evsel__*counts() to evsel__*counts() · 7d1e239e
      Arnaldo Carvalho de Melo 提交于
      As these are 'struct evsel' methods, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7d1e239e
    • A
      perf evsel: Rename perf_evsel__[hs]w_cache* to evsel__[hs]w_cache* · c64e85e1
      Arnaldo Carvalho de Melo 提交于
      As those are 'struct evsel' methods, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c64e85e1
    • A
      perf evsel: Rename perf_evsel__new*() to evsel__new*() · 8f6725a2
      Arnaldo Carvalho de Melo 提交于
      As these are 'struct evsel' methods, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8f6725a2
    • A
      perf evsel: Rename *perf_evsel__get_config_term() & friends to evsel__env() · 35ac0cad
      Arnaldo Carvalho de Melo 提交于
      As it is a 'struct evsel' method, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      35ac0cad
    • A
      perf evsel: Rename perf_evsel__fprintf() to evsel__fprintf() · 2dbfc945
      Arnaldo Carvalho de Melo 提交于
      As it is a 'struct evsel' method, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2dbfc945
    • A
      perf evsel: Rename perf_evsel__resort*() to evsel__resort*() · 10c513f7
      Arnaldo Carvalho de Melo 提交于
      As it is a 'struct evsel' method, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      10c513f7
    • A
      perf evsel: Rename perf_evsel__object_config() to evsel__object_config() · 4c703828
      Arnaldo Carvalho de Melo 提交于
      As it is a 'struct evsel' method, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4c703828
  2. 06 5月, 2020 7 次提交
    • L
      perf cs-etm: Move definition of 'traceid_list' global variable from header file · 168200b6
      Leo Yan 提交于
      The variable 'traceid_list' is defined in the header file cs-etm.h,
      if multiple C files include cs-etm.h the compiler might complaint for
      multiple definition of 'traceid_list'.
      
      To fix multiple definition error, move the definition of 'traceid_list'
      into cs-etm.c.
      
      Fixes: cd8bfd8c ("perf tools: Add processing of coresight metadata")
      Reported-by: NThomas Backlund <tmb@mageia.org>
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: NMike Leach <mike.leach@linaro.org>
      Tested-by: NMike Leach <mike.leach@linaro.org>
      Tested-by: NThomas Backlund <tmb@mageia.org>
      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>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Tor Jeremiassen <tor@ti.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20200505133642.4756-1-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      168200b6
    • I
      libsymbols kallsyms: Move hex2u64 out of header · 32add10f
      Ian Rogers 提交于
      hex2u64 is a helper that's out of place in kallsyms.h as not being
      kallsyms related. Move from kallsyms.h to the only user.
      
      Committer notes:
      
      Move it out of tools/lib/symbol/kallsyms.c as well, as we had to leave
      it there in the previous patch lest we break the build.
      Signed-off-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>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lore.kernel.org/lkml/20200501221315.54715-4-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      32add10f
    • M
      perf: cs-etm: Update to build with latest opencsd version. · 29e2eb2a
      Mike Leach 提交于
      OpenCSD version v0.14.0 adds in a new output element. This is represented
      by a new value in the generic element type enum, which must be added to
      the handling code in perf cs-etm-decoder to prevent build errors due to
      build options on the perf project.
      
      This element is not currently used by the perf decoder.
      
      Perf build feature test updated to require a minimum of 0.14.0
      
      Tested on Linux 5.7-rc3.
      Signed-off-by: NMike Leach <mike.leach@linaro.org>
      Reviewed-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20200501143615.1180-1-mike.leach@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      29e2eb2a
    • T
      perf symbol: Fix kernel symbol address display · 51d96355
      Thomas Richter 提交于
      Running commands
      
         ./perf record -e rb0000 -- find .
         ./perf report -v
      
      reveals symbol names and its addresses. There is a mismatch between
      kernel symbol and address. Here is an example for kernel symbol
      check_chain_key:
      
       3.55%  find /lib/modules/.../build/vmlinux  0xf11ec  v [k] check_chain_key
      
      This address is off by 0xff000 as can be seen with:
      
      [root@t35lp46 ~]# fgrep check_chain_key /proc/kallsyms
      00000000001f00d0 t check_chain_key
      [root@t35lp46 ~]# objdump -t ~/linux/vmlinux| fgrep check_chain_key
      00000000001f00d0 l     F .text	00000000000001e8 check_chain_key
      [root@t35lp46 ~]#
      
      This function is located in main memory 0x1f00d0 - 0x1f02b4. It has
      several entries in the perf data file with the correct address:
      
      [root@t35lp46 perf]# ./perf report -D -i perf.data.find-bad | \
      				fgrep SAMPLE| fgrep 0x1f01ec
      PERF_RECORD_SAMPLE(IP, 0x1): 22228/22228: 0x1f01ec period: 1300000 addr: 0
      PERF_RECORD_SAMPLE(IP, 0x1): 22228/22228: 0x1f01ec period: 1300000 addr: 0
      
      The root cause happens when reading symbol tables during perf report.
      A long gdb call chain leads to
      
         machine__deliver_events
           perf_evlist__deliver_event
             perf_evlist__deliver_sample
               build_id__mark_dso_hits
      	   thread__find_map(1)      Read correct address from sample entry
      	     map__load
      	       dso__load            Some more functions to end up in
      	         ....
      		 dso__load_sym.
      
      Function dso__load_syms  checks for kernel relocation and symbol
      adjustment for the kernel and results in kernel map adjustment of
      	 kernel .text segment address (0x100000 on s390)
      	 kernel .text segment offset in file (0x1000 on s390).
      This results in all kernel symbol addresses to be changed by subtracting
      0xff000 (on s390). For the symbol check_chain_key we end up with
      
          0x1f00d0 - 0x100000 + 0x1000 = 0xf11d0
      
      and this address is saved in the perf symbol table. This calculation is
      also applied by the mapping functions map__mapip() and map__unmapip()
      to map IP addresses to dso mappings.
      
      During perf report processing functions
      
         process_sample_event    (builtin-report.c)
           machine__resolve
             thread__find_map
           hist_entry_iter_add
      
      are called. Function thread__find_map(1)
      takes the correct sample address and applies the mapping function
      map__mapip() from the kernel dso and saves the modified address
      in struct addr_location for further reference. From now on this address
      is used.
      
      Funktion process_sample_event() then calls hist_entry_iter_add() to save
      the address in member ip of struct hist_entry.
      
      When samples are displayed using
      
          perf_evlist__tty_browse_hists
            hists__fprintf
              hist_entry__fprintf
      	  hist_entry__snprintf
      	    __hist_entry__snprintf
      	      _hist_entry__sym_snprintf()
      
      This simply displays the address of the symbol and ignores the dso <-> map
      mappings done in function thread__find_map. This leads to the address
      mismatch.
      
      Output before:
      
      ot@t35lp46 perf]# ./perf report -v | fgrep check_chain_key
           3.55%  find     /lib/modules/5.6.0d-perf+/build/vmlinux
           						0xf11ec v [k] check_chain_key
      [root@t35lp46 perf]#
      
      Output after:
      
      [root@t35lp46 perf]# ./perf report -v | fgrep check_chain_key
           3.55%  find     /lib/modules/5.6.0d-perf+/build/vmlinux
           						0x1f01ec v [k] check_chain_key
      [root@t35lp46 perf]#
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NSumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20200415070744.59919-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      51d96355
    • A
      perf evsel: Rename perf_evsel__store_ids() to evsel__store_id() · 34397753
      Arnaldo Carvalho de Melo 提交于
      As it is a 'struct evsel' method, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      34397753
    • A
      perf evsel: Rename perf_evsel__env() to evsel__env() · 6e6d1d65
      Arnaldo Carvalho de Melo 提交于
      As it is a 'struct evsel' method, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6e6d1d65
    • A
      perf evsel: Rename perf_evsel__group_idx() to evsel__group_idx() · 2bb72dbb
      Arnaldo Carvalho de Melo 提交于
      As it is a 'struct evsel' method, not part of tools/lib/perf/, aka
      libperf, to whom the perf_ prefix belongs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2bb72dbb