1. 25 4月, 2018 1 次提交
    • K
      perf evsel: Only fall back group read for leader · 121f325f
      Kan Liang 提交于
      Perf doesn't support mixed events from different PMUs (except software
      event) in a group. The perf stat should output <not counted>/<not
      supported> for all events, but it doesn't. For example,
      
        perf stat -e '{cycles,uncore_imc_5/umask=0xF,event=0x4/,instructions}'
             <not counted>      cycles
             <not supported>    uncore_imc_5/umask=0xF,event=0x4/
                 1,024,300      instructions
      
      If perf fails to open an event, it doesn't error out directly. It will
      disable some features and retry, until the event is opened or all
      features are disabled. The disabled features will not be re-enabled. The
      group read is one of these features.
      
      For the example as above, the IMC event and the leader event "cycles"
      are from different PMUs. Opening the IMC event must fail. The group read
      feature must be disabled for IMC event and the followed event
      "instructions". The "instructions" event has the same PMU as the leader
      "cycles". It can be opened successfully. Since the group read feature
      has been disabled, the "instructions" event will be read as a single
      event, which definitely has a value.
      
      The group read fallback is still useful for the case which kernel
      doesn't support group read. It is good enough to be handled only by the
      leader.
      
      For the fallback request from members, it must be caused by an error.
      The fallback only breaks the semantics of group.  Limit the group read
      fallback only for the leader.
      
      Committer testing:
      
      On a broadwell t450s notebook:
      
      Before:
      
        # perf stat -e '{cycles,unc_cbo_cache_lookup.read_i,instructions}' sleep 1
      
        Performance counter stats for 'sleep 1':
      
           <not counted>      cycles
         <not supported>      unc_cbo_cache_lookup.read_i
                 818,206      instructions
      
             1.003170887 seconds time elapsed
      
        Some events weren't counted. Try disabling the NMI watchdog:
      	echo 0 > /proc/sys/kernel/nmi_watchdog
      	perf stat ...
      	echo 1 > /proc/sys/kernel/nmi_watchdog
      
      After:
      
        # perf stat -e '{cycles,unc_cbo_cache_lookup.read_i,instructions}' sleep 1
      
        Performance counter stats for 'sleep 1':
      
           <not counted>      cycles
         <not supported>      unc_cbo_cache_lookup.read_i
           <not counted>      instructions
      
             1.001380511 seconds time elapsed
      
        Some events weren't counted. Try disabling the NMI watchdog:
      	echo 0 > /proc/sys/kernel/nmi_watchdog
      	perf stat ...
      	echo 1 > /proc/sys/kernel/nmi_watchdog
        #
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
      Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Fixes:  82bf311e ("perf stat: Use group read for event groups")
      Link: http://lkml.kernel.org/r/1524594014-79243-3-git-send-email-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      121f325f
  2. 23 4月, 2018 2 次提交
  3. 19 4月, 2018 2 次提交
  4. 08 3月, 2018 2 次提交
    • J
      perf report: Fix the output for stdio events list · 8ef278bb
      Jiri Olsa 提交于
      Changing the output header for reporting forced groups via --groups
      option on non grouped events, like:
      
        $ perf record -e 'cycles,instructions'
        $ perf report --stdio --group
      
      Before:
      
        # Samples: 24  of event 'anon group { cycles:u, instructions:u }'
      
      After:
      
        # Samples: 24  of events 'cycles:u, instructions:u'
      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: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Fixes: ad52b8cb ("perf report: Add support to display group output for non group events")
      Link: http://lkml.kernel.org/r/20180307155020.32613-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8ef278bb
    • A
      perf pmu: Display pmu name when printing unmerged events in stat · 8c5421c0
      Agustin Vega-Frias 提交于
      To simplify creation of events accross multiple instances of the same
      type of PMU stat supports two methods for creating multiple events from
      a single event specification:
      
      1. A prefix or glob can be used in the PMU name.
      2. Aliases, which are listed immediately after the Kernel PMU events
         by perf list, are used.
      
      When the --no-merge option is passed and these events are displayed
      individually the PMU name is lost and it's not possible to see which
      count corresponds to which pmu:
      
          $ perf stat -a -e l3cache/read-miss/ --no-merge ls > /dev/null
      
           Performance counter stats for 'system wide':
      
                          67      l3cache/read-miss/
                          67      l3cache/read-miss/
                          63      l3cache/read-miss/
                          60      l3cache/read-miss/
      
                 0.001675706 seconds time elapsed
      
          $ perf stat -a -e l3cache_read_miss --no-merge ls > /dev/null
      
           Performance counter stats for 'system wide':
      
                          12      l3cache_read_miss
                          17      l3cache_read_miss
                          10      l3cache_read_miss
                           8      l3cache_read_miss
      
                 0.001661305 seconds time elapsed
      
      This change adds the original pmu name to the event. For dynamic pmu
      events the pmu name is restored in the event name:
      
          $ perf stat -a -e l3cache/read-miss/ --no-merge ls > /dev/null
      
           Performance counter stats for 'system wide':
      
                          63      l3cache_0_3/read-miss/
                          74      l3cache_0_1/read-miss/
                          64      l3cache_0_2/read-miss/
                          74      l3cache_0_0/read-miss/
      
                 0.001675706 seconds time elapsed
      
      For alias events the name is added after the event name:
      
          $ perf stat -a -e l3cache_read_miss --no-merge ls > /dev/null
      
           Performance counter stats for 'system wide':
      
                          10      l3cache_read_miss [l3cache_0_3]
                          12      l3cache_read_miss [l3cache_0_1]
                          10      l3cache_read_miss [l3cache_0_2]
                          17      l3cache_read_miss [l3cache_0_0]
      
                 0.001661305 seconds time elapsed
      Signed-off-by: NAgustin Vega-Frias <agustinv@codeaurora.org>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Timur Tabi <timur@codeaurora.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Change-Id: I8056b9eda74bda33e95065056167ad96e97cb1fb
      Link: http://lkml.kernel.org/r/1520345084-42646-3-git-send-email-agustinv@codeaurora.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8c5421c0
  5. 07 3月, 2018 1 次提交
  6. 27 2月, 2018 1 次提交
    • J
      perf stat: Ignore error thread when enabling system-wide --per-thread · ab6c79b8
      Jin Yao 提交于
      If we execute 'perf stat --per-thread' with non-root account (even set
      kernel.perf_event_paranoid = -1 yet), it reports the error:
      
        jinyao@skl:~$ perf stat --per-thread
        Error:
        You may not have permission to collect system-wide stats.
      
        Consider tweaking /proc/sys/kernel/perf_event_paranoid,
        which controls use of the performance events system by
        unprivileged users (without CAP_SYS_ADMIN).
      
        The current value is 2:
      
          -1: Allow use of (almost) all events by all users
              Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK
        >= 0: Disallow ftrace function tracepoint by users without CAP_SYS_ADMIN
              Disallow raw tracepoint access by users without CAP_SYS_ADMIN
        >= 1: Disallow CPU event access by users without CAP_SYS_ADMIN
        >= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN
      
        To make this setting permanent, edit /etc/sysctl.conf too, e.g.:
      
                kernel.perf_event_paranoid = -1
      
      Perhaps the ptrace rule doesn't allow to trace some processes. But anyway
      the global --per-thread mode had better ignore such errors and continue
      working on other threads.
      
      This patch will record the index of error thread in perf_evsel__open()
      and remove this thread before retrying.
      
      For example (run with non-root, kernel.perf_event_paranoid isn't set):
      
        jinyao@skl:~$ perf stat --per-thread
        ^C
         Performance counter stats for 'system wide':
      
               vmstat-3458    6.171984   cpu-clock:u (msec) #  0.000 CPUs utilized
                 perf-3670    0.515599   cpu-clock:u (msec) #  0.000 CPUs utilized
               vmstat-3458   1,163,643   cycles:u           #  0.189 GHz
                 perf-3670      40,881   cycles:u           #  0.079 GHz
               vmstat-3458   1,410,238   instructions:u     #  1.21  insn per cycle
                 perf-3670       3,536   instructions:u     #  0.09  insn per cycle
               vmstat-3458     288,937   branches:u         # 46.814 M/sec
                 perf-3670         936   branches:u         #  1.815 M/sec
               vmstat-3458      15,195   branch-misses:u    #  5.26% of all branches
                 perf-3670          76   branch-misses:u    #  8.12% of all branches
      
              12.651675247 seconds time elapsed
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1516117388-10120-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ab6c79b8
  7. 15 2月, 2018 1 次提交
  8. 05 2月, 2018 2 次提交
    • J
      perf record: Fix period option handling · f290aa1f
      Jiri Olsa 提交于
      Stephan reported we don't unset PERIOD sample type when --no-period is
      specified. Adding the unset check and reset PERIOD if --no-period is
      specified.
      
      Committer notes:
      
      Check the sample_type, it shouldn't have PERF_SAMPLE_PERIOD there when
      --no-period is used.
      
      Before:
      
        # perf record --no-period sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.018 MB perf.data (7 samples) ]
        # perf evlist -v
        cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
        #
      
      After:
      
      [root@jouet ~]# perf record --no-period sleep 1
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.019 MB perf.data (17 samples) ]
      [root@jouet ~]# perf evlist -v
      cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
      [root@jouet ~]#
      Reported-by: NStephane Eranian <eranian@google.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NStephane Eranian <eranian@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180201083812.11359-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f290aa1f
    • J
      perf evsel: Fix period/freq terms setup · 49c0ae80
      Jiri Olsa 提交于
      Stephane reported that we don't set properly PERIOD sample type for
      events with period term defined.
      
      Before:
        $ perf record -e cpu/cpu-cycles,period=1000/u ls
        $ perf evlist -v
        cpu/cpu-cycles,period=1000/u: ... sample_type: IP|TID|TIME|PERIOD, ...
      
      After:
        $ perf record -e cpu/cpu-cycles,period=1000/u ls
        $ perf evlist -v
        cpu/cpu-cycles,period=1000/u: ... sample_type: IP|TID|TIME, ...
      
      Setting PERIOD sample type based on period term setup.
      
      Committer note:
      
      When we use -c or a period=N term in the event definition, then we don't
      need to ask the kernel, for this event, via perf_event_attr.sample_type
      |= PERF_SAMPLE_PERIOD, to put the event period in each sample for this
      event, as we know it already, it is in perf_event_attr.sample_period.
      Reported-by: NStephane Eranian <eranian@google.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NStephane Eranian <eranian@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180201083812.11359-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      49c0ae80
  9. 18 1月, 2018 2 次提交
  10. 17 1月, 2018 2 次提交
    • A
      perf callchains: Ask for PERF_RECORD_MMAP for data mmaps for DWARF unwinding · 0d3dcc0e
      Arnaldo Carvalho de Melo 提交于
      When we use a global DWARF setting as in:
      
      	perf record --call-graph dwarf
      
      According to 5c0cf224 ("perf record: Store data mmaps for dwarf unwind") we need
      to set up some extra perf_event_attr bits.
      
      But when we instead do a per event dwarf setting:
      
      	perf record -e cycles/call-graph=dwarf/
      
      This was not being done, make them equivalent.
      
      This didn't produce any output changes in my tests while fixing up loose
      ends in the per-event settings, I found it just by comparing the
      perf_event_attr fields trying to find an explanation for those problems.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hendrick Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Noel Grandin <noelgrandin@gmail.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-6476r53h2o38skbs9qa4ust4@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0d3dcc0e
    • A
      perf callchain: Fix attr.sample_max_stack setting · 249d98e5
      Arnaldo Carvalho de Melo 提交于
      When setting the "dwarf" unwinder for a specific event and not
      specifying the max-stack, the attr.sample_max_stack ended up using an
      uninitialized callchain_param.max_stack, fix it by using designated
      initializers for that callchain_param variable, zeroing all non
      explicitely initialized struct members.
      
      Here is what happened:
      
        # perf trace -vv --no-syscalls --max-stack 4 -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
        callchain: type DWARF
        callchain: stack dump size 8192
        perf_event_attr:
          type                             2
          size                             112
          config                           0x730
          { sample_period, sample_freq }   1
          sample_type                      IP|TID|TIME|ADDR|CALLCHAIN|CPU|PERIOD|RAW|REGS_USER|STACK_USER|DATA_SRC
          exclude_callchain_user           1
          { wakeup_events, wakeup_watermark } 1
          sample_regs_user                 0xff0fff
          sample_stack_user                8192
          sample_max_stack                 50656
        sys_perf_event_open failed, error -75
        Value too large for defined data type
        # perf trace -vv --no-syscalls --max-stack 4 -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
        callchain: type DWARF
        callchain: stack dump size 8192
        perf_event_attr:
          type                             2
          size                             112
          config                           0x730
          sample_type                      IP|TID|TIME|ADDR|CALLCHAIN|CPU|PERIOD|RAW|REGS_USER|STACK_USER|DATA_SRC
          exclude_callchain_user           1
          sample_regs_user                 0xff0fff
          sample_stack_user                8192
          sample_max_stack                 30448
        sys_perf_event_open failed, error -75
        Value too large for defined data type
        #
      
      Now the attr.sample_max_stack is set to zero and the above works as
      expected:
      
        # perf trace --no-syscalls --max-stack 4 -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
        PING ::1(::1) 56 data bytes
        64 bytes from ::1: icmp_seq=1 ttl=64 time=0.072 ms
      
        --- ::1 ping statistics ---
        1 packets transmitted, 1 received, 0% packet loss, time 0ms
        rtt min/avg/max/mdev = 0.072/0.072/0.072/0.000 ms
             0.000 probe_libc:inet_pton:(7feb7a998350))
                                               __inet_pton (inlined)
                                               gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)
                                               __GI_getaddrinfo (inlined)
                                               [0xffffaa39b6108f3f] (/usr/bin/ping)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hendrick Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-is9tramondqa9jlxxsgcm9iz@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      249d98e5
  11. 13 1月, 2018 1 次提交
  12. 11 1月, 2018 1 次提交
  13. 08 1月, 2018 2 次提交
  14. 27 12月, 2017 4 次提交
    • M
      perf evsel: Enable ignore_missing_thread for pid option · ca800068
      Mengting Zhang 提交于
      While monitoring a multithread process with pid option, perf sometimes
      may return sys_perf_event_open failure with 3(No such process) if any of
      the process's threads die before we open the event. However, we want
      perf continue monitoring the remaining threads and do not exit with
      error.
      
      Here, the patch enables perf_evsel::ignore_missing_thread for -p option
      to ignore complete failure if any of threads die before we open the event.
      But it may still return sys_perf_event_open failure with 22(Invalid) if we
      monitors several event groups.
      
              sys_perf_event_open: pid 28960  cpu 40  group_fd 118202  flags 0x8
              sys_perf_event_open: pid 28961  cpu 40  group_fd 118203  flags 0x8
              WARNING: Ignored open failure for pid 28962
              sys_perf_event_open: pid 28962  cpu 40  group_fd [118203]  flags 0x8
              sys_perf_event_open failed, error -22
      
      That is because when we ignore a missing thread, we change the thread_idx
      without dealing with its fds, FD(evsel, cpu, thread). Then get_group_fd()
      may return a wrong group_fd for the next thread and sys_perf_event_open()
      return with 22.
      
              sys_perf_event_open(){
                 ...
                 if (group_fd != -1)
                     perf_fget_light()//to get corresponding group_leader by group_fd
                 ...
                 if (group_leader)
                    if (group_leader->ctx->task != ctx->task)//should on the same task
                         goto err_context
                 ...
              }
      
      This patch also fixes this bug by introducing perf_evsel__remove_fd() and
      update_fds to allow removing fds for the missing thread.
      
      Changes since v1:
      - Change group_fd__remove() into a more genetic way without changing code logic
      - Remove redundant condition
      
      Changes since v2:
      - Use a proper function name and add some comment.
      - Multiline comment style fixes.
      
      Committer testing:
      
      Before this patch the recently added 'perf stat --per-thread' for system
      wide counting would race while enumerating all threads using /proc:
      
        [root@jouet ~]# perf stat --per-thread
        failed to parse CPUs map: No such file or directory
      
         Usage: perf stat [<options>] [<command>]
      
            -C, --cpu <cpu>       list of cpus to monitor in system-wide
            -a, --all-cpus        system-wide collection from all CPUs
        [root@jouet ~]# perf stat --per-thread
        failed to parse CPUs map: No such file or directory
      
         Usage: perf stat [<options>] [<command>]
      
            -C, --cpu <cpu>       list of cpus to monitor in system-wide
            -a, --all-cpus        system-wide collection from all CPUs
        [root@jouet ~]#
      
      When, say, the kernel was being built, so lots of shortlived threads,
      after this patch this doesn't happen.
      Signed-off-by: NMengting Zhang <zhangmengting@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Cheng Jian <cj.chengjian@huawei.com>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1513148513-6974-1-git-send-email-zhangmengting@huawei.com
      [ Remove one use 'evlist' alias variable ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ca800068
    • J
      perf evsel: Fix swap for samples with raw data · f9d8adb3
      Jiri Olsa 提交于
      When we detect a different endianity we swap event before processing.
      It's tricky for samples because we have no idea what's inside. We treat
      it as an array of u64s, swap them and later on we swap back parts which
      are different.
      
      We mangle this way also the tracepoint raw data, which ends up in report
      showing wrong data:
      
        1.95%  comm=Q^B pid=29285 prio=16777216 target_cpu=000
        1.67%  comm=l^B pid=0 prio=16777216 target_cpu=000
      
      Luckily the traceevent library handles the endianity by itself (thank
      you Steven!), so we can pass the RAW data directly in the other
      endianity.
      
        2.51%  comm=beah-rhts-task pid=1175 prio=120 target_cpu=002
        2.23%  comm=kworker/0:0 pid=11566 prio=120 target_cpu=000
      
      The fix is basically to swap back the raw data if different endianity is
      detected.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20171129184346.3656-1-jolsa@kernel.org
      [ Add util/memswap.c to python-ext-sources to link missing mem_bswap_64() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f9d8adb3
    • A
      perf annotate: Use perf_env when obtaining the arch name · 3285deba
      Arnaldo Carvalho de Melo 提交于
      Paving the way to reuse these routines in other areas, like when
      generating errno tables.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-rh1qv051vb8gfdcswskrn53h@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3285deba
    • A
      perf annotate: Get the cpuid from evsel->evlist->env in symbol__annotate() · 5449f13c
      Arnaldo Carvalho de Melo 提交于
      To reduce its function signature, since we get this from 'evsel' which
      is already one of its arguments.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-070eap7t6uicg9c3w086xy2z@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5449f13c
  15. 29 11月, 2017 2 次提交
  16. 17 11月, 2017 6 次提交
  17. 25 9月, 2017 1 次提交
    • A
      perf evsel: Fix attr.exclude_kernel setting for default cycles:p · f1e52f14
      Arnaldo Carvalho de Melo 提交于
      Yet another fix for probing the max attr.precise_ip setting: it is not
      enough settting attr.exclude_kernel for !root users, as they _can_
      profile the kernel if the kernel.perf_event_paranoid sysctl is set to
      -1, so check that as well.
      
      Testing it:
      
      As non root:
      
        $ sysctl kernel.perf_event_paranoid
        kernel.perf_event_paranoid = 2
        $ perf record sleep 1
        $ perf evlist -v
        cycles:uppp: ..., exclude_kernel: 1, ... precise_ip: 3, ...
      
      Now as non-root, but with kernel.perf_event_paranoid set set to the
      most permissive value, -1:
      
        $ sysctl kernel.perf_event_paranoid
        kernel.perf_event_paranoid = -1
        $ perf record sleep 1
        $ perf evlist -v
        cycles:ppp: ..., exclude_kernel: 0, ... precise_ip: 3, ...
        $
      
      I.e. non-root, default kernel.perf_event_paranoid: :uppp modifier = not allowed to sample the kernel,
           non-root, most permissible kernel.perf_event_paranoid: :ppp = allowed to sample the kernel.
      
      In both cases, use the highest available precision: attr.precise_ip = 3.
      Reported-and-Tested-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: d37a3697 ("perf evsel: Fix attr.exclude_kernel setting for default cycles:p")
      Link: http://lkml.kernel.org/n/tip-nj2qkf75xsd6pw6hhjzfqqdx@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f1e52f14
  18. 13 9月, 2017 1 次提交
  19. 02 9月, 2017 1 次提交
  20. 28 8月, 2017 1 次提交
  21. 23 8月, 2017 1 次提交
  22. 22 8月, 2017 1 次提交
    • A
      perf evsel: Fix buffer overflow while freeing events · 475fb533
      Andi Kleen 提交于
      Fix buffer overflow for:
      
        % perf stat -e msr/tsc/,cstate_core/c7-residency/ true
      
      that causes glibc free list corruption. For some reason it doesn't
      trigger in valgrind, but it is visible in AS:
      
        =================================================================
        ==32681==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000003f5c at pc 0x0000005671ef bp 0x7ffdaaac9ac0 sp 0x7ffdaaac9ab0
        READ of size 4 at 0x603000003f5c thread T0
          #0 0x5671ee in perf_evsel__close_fd util/evsel.c:1196
          #1 0x56c57a in perf_evsel__close util/evsel.c:1717
          #2 0x55ed5f in perf_evlist__close util/evlist.c:1631
          #3 0x4647e1 in __run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:749
          #4 0x4648e3 in run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:767
          #5 0x46e1bc in cmd_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:2785
          #6 0x52f83d in run_builtin /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:296
          #7 0x52fd49 in handle_internal_command /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:348
          #8 0x5300de in run_argv /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:392
          #9 0x5308f3 in main /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:530
          #10 0x7f0672d13400 in __libc_start_main (/lib64/libc.so.6+0x20400)
          #11 0x428419 in _start (/home/ak/hle/obj-perf/perf+0x428419)
      
        0x603000003f5c is located 0 bytes to the right of 28-byte region [0x603000003f40,0x603000003f5c)
        allocated by thread T0 here:
          #0 0x7f0675139020 in calloc (/lib64/libasan.so.3+0xc7020)
          #1 0x648a2d in zalloc util/util.h:23
          #2 0x648a88 in xyarray__new util/xyarray.c:9
          #3 0x566419 in perf_evsel__alloc_fd util/evsel.c:1039
          #4 0x56b427 in perf_evsel__open util/evsel.c:1529
          #5 0x56c620 in perf_evsel__open_per_thread util/evsel.c:1730
          #6 0x461dea in create_perf_stat_counter /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:263
          #7 0x4637d7 in __run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:600
          #8 0x4648e3 in run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:767
          #9 0x46e1bc in cmd_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:2785
          #10 0x52f83d in run_builtin /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:296
          #11 0x52fd49 in handle_internal_command /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:348
          #12 0x5300de in run_argv /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:392
          #13 0x5308f3 in main /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:530
          #14 0x7f0672d13400 in __libc_start_main (/lib64/libc.so.6+0x20400)
      
      The event is allocated with cpus == 1, but freed with cpus == real number
      When the evsel close function walks the file descriptors it exceeds the
      fd xyarray boundaries and reads random memory.
      
      v2:
      
      Now that xyarrays save their original dimensions we can use these to
      iterate the two dimensional fd arrays. Fix some users (close, ioctl) in
      evsel.c to use these fields directly. This allows simplifying the code
      and dropping quite a few function arguments. Adjust all callers by
      removing the unneeded arguments.
      
      The actual perf event reading still uses the original values from the
      evsel list.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/20170811232634.30465-2-andi@firstfloor.org
      [ Fix up xy_max_[xy]() -> xyarray__max_[xy]() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      475fb533
  23. 27 7月, 2017 2 次提交
    • J
      perf stat: Use group read for event groups · 82bf311e
      Jiri Olsa 提交于
      Make perf stat use  group read if there  are groups defined. The group
      read will get the values for all member of groups within a single
      syscall instead of calling read syscall for every event.
      
      We can see considerable less amount of kernel cycles spent on single
      group read, than reading each event separately, like for following perf
      stat command:
      
        # perf stat -e {cycles,instructions} -I 10 -a sleep 1
      
      Monitored with "perf stat -r 5 -e '{cycles:u,cycles:k}'"
      
      Before:
      
              24,325,676      cycles:u
             297,040,775      cycles:k
      
             1.038554134 seconds time elapsed
      
      After:
              25,034,418      cycles:u
             158,256,395      cycles:k
      
             1.036864497 seconds time elapsed
      
      The perf_evsel__open fallback changes contributed by Andi Kleen.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170726120206.9099-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      82bf311e
    • J
      perf evsel: Add read_counter() · f7794d52
      Jiri Olsa 提交于
      Add perf_evsel__read_counter() to read single or group counter. After
      calling this function the counter's evsel::counts struct is filled with
      values for the counter and member of its group if there are any.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170726120206.9099-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f7794d52