Commit graph

6428 commits

Author SHA1 Message Date
Peter Zijlstra
2c5e8c52c6 perf tools: Merge all perf_event_attr print functions
Currently there's 3 (that I found) different and incomplete
implementations of printing perf_event_attr.

This is quite silly. Merge the lot.

While this patch does not retain the exact form all printing that I
found is debug output and thus it should not be critical.

Also, I cannot find a single print_event_desc() caller.

Pre:

 $ perf record -vv -e cycles -- sleep 1
 ------------------------------------------------------------
 perf_event_attr:
  type                0
  size                104
  config              0
  sample_period       4000
  sample_freq         4000
  sample_type         0x107
  read_format         0
  disabled            1    inherit             1
  pinned              0    exclusive           0
  exclude_user        0    exclude_kernel      0
  exclude_hv          0    exclude_idle        0
  mmap                1    comm                1
  mmap2               1    comm_exec           1
  freq                1    inherit_stat        0
  enable_on_exec      1    task                1
  watermark           0    precise_ip          0
  mmap_data           0    sample_id_all       1
  exclude_host        0    exclude_guest       1
  excl.callchain_kern 0    excl.callchain_user 0
  wakeup_events       0
  wakeup_watermark    0
  bp_type             0
  bp_addr             0
  config1             0
  bp_len              0
  config2             0
  branch_sample_type  0
  sample_regs_user    0
  sample_stack_user   0
  sample_regs_intr    0
 ------------------------------------------------------------

 $ perf evlist  -vv
 cycles: sample_freq=4000, size: 104, sample_type: IP|TID|TIME|PERIOD,
 disabled: 1, inherit: 1, mmap: 1, mmap2: 1, comm: 1, comm_exec: 1,
 freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1

 Post:

 $ ./perf record -vv -e cycles -- sleep 1
 ------------------------------------------------------------
 perf_event_attr:
  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
  sample_id_all                    1
  exclude_guest                    1
  mmap2                            1
  comm_exec                        1
------------------------------------------------------------

 $ ./perf evlist  -vv
 cycles: 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, sample_id_all: 1, exclude_guest: 1,
 mmap2: 1, comm_exec: 1

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20150407091150.644238729@infradead.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 10:06:28 -03:00
Peter Zijlstra
814c8c38e1 perf record: Add clockid parameter
Teach perf-record about the new perf_event_attr::{use_clockid, clockid}
fields. Add a simple parameter to set the clock (if any) to be used for
the events to be recorded into the data file.

Since we store the entire perf_event_attr in the EVENT_DESC section we
also already store the used clockid in the data file.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yunlong Song <yunlong.song@huawei.com>
Link: http://lkml.kernel.org/r/20150407154851.GR23123@twins.programming.kicks-ass.net
[ Conditionally define CLOCK_BOOTTIME, at least rhel6 doesn't have it - dsahern
  Ditto for CLOCK_MONOTONIC_RAW, sles11sp2 doesn't have it - yunlong.song ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 10:04:55 -03:00
Yunlong Song
ff5f3bbd40 perf sched replay: Use replay_repeat to calculate the runavg of cpu usage instead of the default value 10
Since sched->replay_repeat is set to 10 as default, the sched->run_avg,
sched->runavg_cpu_usage, and sched->runavg_parent_cpu_usage all use
10 to calculate their value.

However, the replay_repeat can be changed to other value by using -r
option, so the calculation above should use replay_repeat to achieve
more accurate results instead of the default value 10.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-10-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:27 -03:00
Yunlong Song
f0dd330fdf perf sched replay: Support using -f to override perf.data file ownership
Enable to use perf.data when it is not owned by current user or root.

Example:

 $ ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 5321918 Mar 25 15:14 perf.data
 $ sudo id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 $ sudo perf sched replay -f
 run measurement overhead: 98 nsecs
 sleep measurement overhead: 52909 nsecs
 the run test took 1000015 nsecs
 the sleep test took 1054253 nsecs
 File perf.data not owned by current user or root (use -f to override)

As shown above, the -f option does not work at all.

After this patch:

 $ sudo perf sched replay -f
 run measurement overhead: 221 nsecs
 sleep measurement overhead: 40514 nsecs
 the run test took 1000003 nsecs
 the sleep test took 1056098 nsecs
 nr_run_events:        10
 nr_sleep_events:      1562
 nr_wakeup_events:     5
 task      0 (                  :1:         1), nr_events: 1
 task      1 (                  :2:         2), nr_events: 1
 task      2 (                  :3:         3), nr_events: 1
 ...
 ...
 task   1549 (             :163132:    163132), nr_events: 1
 task   1550 (             :163540:    163540), nr_events: 1
 task   1551 (           <unknown>:         0), nr_events: 10
 ------------------------------------------------------------
 #1  : 50.198, ravg: 50.20, cpu: 2335.18 / 2335.18
 #2  : 219.099, ravg: 67.09, cpu: 2835.11 / 2385.17
 #3  : 238.626, ravg: 84.24, cpu: 3278.26 / 2474.48
 #4  : 200.364, ravg: 95.85, cpu: 2977.41 / 2524.77
 #5  : 176.882, ravg: 103.96, cpu: 2801.35 / 2552.43
 #6  : 191.093, ravg: 112.67, cpu: 2813.70 / 2578.56
 #7  : 189.448, ravg: 120.35, cpu: 2809.21 / 2601.62
 #8  : 200.637, ravg: 128.38, cpu: 2849.91 / 2626.45
 #9  : 248.338, ravg: 140.37, cpu: 4380.61 / 2801.87
 #10 : 511.139, ravg: 177.45, cpu: 3077.73 / 2829.45

As shown above, the -f option really works now.

Besides for replay, -f option can also work for latency and map.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-9-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:26 -03:00
Yunlong Song
939cda521a perf sched replay: Fix the EMFILE error caused by the limitation of the maximum open files
The soft maximum number of open files for a calling process is 1024,
which is defined as INR_OPEN_CUR in include/uapi/linux/fs.h, and the
hard maximum number of open files for a calling process is 4096, which
is defined as INR_OPEN_MAX in include/uapi/linux/fs.h.

Both INR_OPEN_CUR and INR_OPEN_MAX are used to limit the value of
RLIMIT_NOFILE in include/asm-generic/resource.h.

And the soft maximum number finally decides the limitation of the
maximum files which are allowed to be opened.

That is to say a process can use at most 1024 file descriptors for its
o pened files, or an EMFILE error will happen.

This error can be fixed by increasing the soft maximum number, under the
constraint that the soft maximum number can not exceed the hard maximum
number, or both soft and hard maximum number should be increased
simultaneously with privilege.

For perf sched replay, it uses sys_perf_event_open to create the file
descriptor for each of the tasks in order to handle information of perf
events.

That is to say each task needs a unique file descriptor. In x86_64,
there may be over 1024 or 4096 tasks correspoinding to the record in
perf.data, which causes that no enough file descriptors can be used.

As a result, EMFILE error happens and stops the replay process. To solve
this problem, we adaptively increase the soft and hard maximum number of
open files with a '-f' option.

Example:

Test environment: x86_64 with 160 cores

 $ cat /proc/sys/kernel/pid_max
 163840
 $ cat /proc/sys/fs/file-max
 6815744
 $ ulimit -Sn
 1024
 $ ulimit -Hn
 4096

Before this patch:

 $ perf sched replay
 ...
 task   1549 (             :163132:    163132), nr_events: 1
 task   1550 (             :163540:    163540), nr_events: 1
 task   1551 (           <unknown>:         0), nr_events: 10
 Error: sys_perf_event_open() syscall returned with -1 (Too many open
 files)

After this patch:

 $ perf sched replay
 ...
 task   1549 (             :163132:    163132), nr_events: 1
 task   1550 (             :163540:    163540), nr_events: 1
 task   1551 (           <unknown>:         0), nr_events: 10
 Error: sys_perf_event_open() syscall returned with -1 (Too many open
 files)
 Have a try with -f option

 $ perf sched replay -f
 ...
 task   1549 (             :163132:    163132), nr_events: 1
 task   1550 (             :163540:    163540), nr_events: 1
 task   1551 (           <unknown>:         0), nr_events: 10
 ------------------------------------------------------------
 #1  : 54.401, ravg: 54.40, cpu: 3285.21 / 3285.21
 #2  : 199.548, ravg: 68.92, cpu: 4999.65 / 3456.66
 #3  : 170.483, ravg: 79.07, cpu: 1349.94 / 3245.99
 #4  : 192.034, ravg: 90.37, cpu: 1322.88 / 3053.67
 #5  : 182.929, ravg: 99.62, cpu: 1406.51 / 2888.96
 #6  : 152.974, ravg: 104.96, cpu: 1167.54 / 2716.82
 #7  : 155.579, ravg: 110.02, cpu: 2992.53 / 2744.39
 #8  : 130.557, ravg: 112.08, cpu: 1126.43 / 2582.59
 #9  : 138.520, ravg: 114.72, cpu: 1253.22 / 2449.65
 #10 : 134.328, ravg: 116.68, cpu: 1587.95 / 2363.48

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-8-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:26 -03:00
Yunlong Song
1aff59be53 perf sched replay: Handle the dead halt of sem_wait when create_tasks() fails for any task
Since there is sem_wait for each task in the wait_for_tasks(), e.g.
sem_wait(&task->work_done_sem).

The sem_wait can continue only when work_done_sem is greater than 0, or
it will be blocked.

For perf sched replay, one task may sem_post the work_done_sem of
another task, which causes the work_done_sem of that task processed in a
reasonable sequence, e.g. sem_post, sem_wait, sem_wait, sem_post...

This sequence simulates the sched process of the running tasks at the
time when perf sched record runs.

As a result, all the tasks are required and their threads must be
successfully created.

If any one (task A) of the tasks fails to create its thread, then
another task (task B), whose work_done_sem needs sem_post from that
failed task A, may likely block itself due to seg_wait.

And this is a dead halt, since task B's thread_func cannot continue at
all.

To solve this problem, perf sched replay should exit once any task fails
to create its thread.

Example:

Test environment: x86_64 with 160 cores

Before this patch:

 $ perf sched replay
 ...
 Error: sys_perf_event_open() syscall returned with -1 (Too many open
 files)
 ------------------------------------------------------------    <- dead halt

After this patch:

 $ perf sched replay
 ...
 task   1551 (           <unknown>:         0), nr_events: 10
 Error: sys_perf_event_open() syscall returned with -1 (Too many open
 files)
 $

As shown above, perf sched replay finishes the process after printing an
error message and does not block itself.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-7-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:25 -03:00
Yunlong Song
08097abc11 perf sched replay: Fix the segmentation fault problem caused by pr_err in threads
The pr_err in self_open_counters() prints error message to stderr.
Unlike stdout, stderr uses memory buffer on the stack of each calling
process.

The pr_err in self_open_counters() works in a thread called thread_func
created in function create_tasks, which concurrently creates
sched->nr_tasks threads.

If the error happens and pr_err prints the error message in each of
these threads, the stack size of the perf process (default is 8192
kbytes) will quickly run out and the segmentation fault will happen
then.

To solve this problem, pr_err with self_open_counters() should be moved
from newly created threads to the old main thread of the perf process.
Then the pr_err can work in a stable situation without the strange
segmentation fault problem.

Example:

Test environment: x86_64 with 160 cores

Before this patch:

 $ perf sched replay
 ...
 task   1549 (             :163132:    163132), nr_events: 1
 task   1550 (             :163540:    163540), nr_events: 1
 task   1551 (           <unknown>:         0), nr_events: 10
 Segmentation fault

After this patch:

 $ perf sched replay
 ...
 task   1549 (             :163132:    163132), nr_events: 1
 task   1550 (             :163540:    163540), nr_events: 1
 task   1551 (           <unknown>:         0), nr_events: 10
 ...

As shown above, the result continues without any segmentation fault.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-6-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:24 -03:00
Yunlong Song
3a423a5c36 perf sched replay: Realloc the memory of pid_to_task stepwise to adapt to the different pid_max configurations
Although the memory of pid_to_task can be allocated via calloc according
to the value of /proc/sys/kernel/pid_max, it cannot handle the case when
pid_max is changed after 'perf sched record' has created its perf.data.

If the new pid_max configured in 'perf sched replay' is smaller than the
old pid_max configured in 'perf sched record', then it will cause the
assertion failure problem.

To solve this problem, we realloc the memory of pid_to_task stepwise
once the passed-in pid parameter in register_pid is larger than the
current pid_max.

Example:

Test environment: x86_64 with 160 cores

 $ cat /proc/sys/kernel/pid_max
 163840
 $ perf sched record ls
 $ echo 5000 > /proc/sys/kernel/pid_max
 $ cat /proc/sys/kernel/pid_max
 5000

Before this patch:

 $ perf sched replay
 run measurement overhead: 221 nsecs
 sleep measurement overhead: 55356 nsecs
 the run test took 1000011 nsecs
 the sleep test took 1060940 nsecs
 perf: builtin-sched.c:337: register_pid: Assertion `!(pid >= (unsigned
 long)pid_max)' failed.
 Aborted

After this patch:

 $ perf sched replay
 run measurement overhead: 221 nsecs
 sleep measurement overhead: 55611 nsecs
 the run test took 1000026 nsecs
 the sleep test took 1060486 nsecs
 nr_run_events:        10
 nr_sleep_events:      1562
 nr_wakeup_events:     5
 task      0 (                  :1:         1), nr_events: 1
 task      1 (                  :2:         2), nr_events: 1
 task      2 (                  :3:         3), nr_events: 1
 task      3 (                  :5:         5), nr_events: 1
 ...

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-5-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:23 -03:00
Yunlong Song
cb06ac256a perf sched replay: Alloc the memory of pid_to_task dynamically to adapt to the unexpected change of pid_max
The current memory allocation of struct task_desc *pid_to_task[MAX_PID]
is in a permanent and preset way, and it has two problems:

Problem 1: If the pid_max, which is the max number of pids in the
system, is much smaller than MAX_PID (1024*1000), then it causes a waste
of stack memory. This may happen in the case where the number of cpu
cores is much smaller than 1000.

Problem 2: If the pid_max is changed from the default value to a value
larger than MAX_PID, then it will cause assertion failure problem. The
maximum value of pid_max can be set to pid_max_max (see pidmap_init
defined in kernel/pid.c), which equals to PID_MAX_LIMIT. In x86_64,
PID_MAX_LIMIT is 4*1024*1024 (defined in include/linux/threads.h). This
value is much larger than MAX_PID, and will take up 32768 Kbytes
(4*1024*1024*8/1024) for memory allocation of pid_to_task, which is much
larger than the default 8192 Kbytes of the stack size of calling
process.

Due to these two problems, we use calloc to allocate the memory of
pid_to_task dynamically.

Example:

Test environment: x86_64 with 160 cores

 $ cat /proc/sys/kernel/pid_max
 163840
 $ echo 1025000 > /proc/sys/kernel/pid_max
 $ cat /proc/sys/kernel/pid_max
 1025000

Run some applications until the pid of some process is greater than
the value of MAX_PID (1024*1000).

Before this patch:

 $ perf sched replay
 run measurement overhead: 221 nsecs
 sleep measurement overhead: 55480 nsecs
 the run test took 1000008 nsecs
 the sleep test took 1063151 nsecs
 perf: builtin-sched.c:330: register_pid: Assertion `!(pid >= 1024000)'
 failed.
 Aborted

After this patch:

 $ perf sched replay
 run measurement overhead: 221 nsecs
 sleep measurement overhead: 55435 nsecs
 the run test took 1000004 nsecs
 the sleep test took 1059312 nsecs
 nr_run_events:        10
 nr_sleep_events:      1562
 nr_wakeup_events:     5
 task      0 (                  :1:         1), nr_events: 1
 task      1 (                  :2:         2), nr_events: 1
 task      2 (                  :3:         3), nr_events: 1
 task      3 (                  :5:         5), nr_events: 1
 ...

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-4-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:22 -03:00
Yunlong Song
a35e27d0e5 perf sched replay: Increase the MAX_PID value to fix assertion failure problem
Current MAX_PID is only 65536, which will cause assertion failure problem
when CPU cores are more than 64 in x86_64.

This is because the pid_max value in x86_64 is at least
PIDS_PER_CPU_DEFAULT * num_possible_cpus() (see function pidmap_init
defined in kernel/pid.c), where PIDS_PER_CPU_DEFAULT is 1024 (defined in
include/linux/threads.h).

Thus for MAX_PID = 65536, the correspoinding CPU cores are
65536/1024=64.  This is obviously not enough at all for x86_64, and will
cause an assertion failure problem due to BUG_ON(pid >= MAX_PID) in the
codes.

We increase MAX_PID value from 65536 to 1024*1000, which can be used in
x86_64 with 1000 cores.

This number is finally decided according to the limitation of stack size
of calling process.

Use 'ulimit -a', the result shows the stack size of any process is 8192
Kbytes, which is defined in include/uapi/linux/resource.h (#define
_STK_LIM (8*1024*1024)).

Thus we choose a large enough value for MAX_PID, and make it satisfy to
the limitation of the stack size, i.e., making the perf process take up
a memory space just smaller than 8192 Kbytes.

We have calculated and tested that 1024*1000 is OK for MAX_PID.

This means perf sched replay can now be used with at most 1000 cores in
x86_64 without any assertion failure problem.

Example:

Test environment: x86_64 with 160 cores

 $ cat /proc/sys/kernel/pid_max
 163840

Before this patch:

 $ perf sched replay
 run measurement overhead: 240 nsecs
 sleep measurement overhead: 55379 nsecs
 the run test took 1000004 nsecs
 the sleep test took 1059424 nsecs
 perf: builtin-sched.c:330: register_pid: Assertion `!(pid >= 65536)'
 failed.
 Aborted

After this patch:

 $ perf sched replay
 run measurement overhead: 221 nsecs
 sleep measurement overhead: 55397 nsecs
 the run test took 999920 nsecs
 the sleep test took 1053313 nsecs
 nr_run_events:        10
 nr_sleep_events:      1562
 nr_wakeup_events:     5
 task      0 (                  :1:         1), nr_events: 1
 task      1 (                  :2:         2), nr_events: 1
 task      2 (                  :3:         3), nr_events: 1
 task      3 (                  :5:         5), nr_events: 1
 ...

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-3-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:21 -03:00
Yunlong Song
0755bc4dc7 perf sched replay: Use struct task_desc instead of struct task_task for correct meaning
There is no struct task_task at all, thus it is a typo error in the old
commits, now fix it to what it should be in order to avoid unnecessary
misunderstanding.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427809596-29559-2-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:19 -03:00
Jiri Olsa
28939e1a1f perf kmem: Respect -i option
Currently the perf kmem does not respect -i option.

Initializing the file.path properly after options get parsed.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/1428298576-9785-2-git-send-email-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:14 -03:00
Namhyung Kim
3201f0dc42 tools lib traceevent: Honor operator priority
Currently it ignores operator priority and just sets processed args as a
right operand.  But it could result in priority inversion in case that
the right operand is also a operator arg and its priority is lower.

For example, following print format is from new kmem events.

  "page=%p", REC->pfn != -1UL ? (((struct page *)(0xffffea0000000000UL)) + (REC->pfn)) : ((void *)0)

But this was treated as below:

  REC->pfn != ((null - 1UL) ? ((struct page *)0xffffea0000000000UL + REC->pfn) : (void *) 0)

In this case, the right arg was '?' operator which has lower priority.
But it just sets the whole arg so making the output confusing - page was
always 0 or 1 since that's the result of logical operation.

With this patch, it can handle it properly like following:

  ((REC->pfn != (null - 1UL)) ? ((struct page *)0xffffea0000000000UL + REC->pfn) : (void *) 0)

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/1428298576-9785-10-git-send-email-namhyung@kernel.org
[ Replaced 'swap' with 'rotate' in a comment as requested by Steve and agreed by Namhyung ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:09 -03:00
Wang Nan
ba92732e98 perf kmaps: Check kmaps to make code more robust
This patch add checks in places where map__kmap is used to get kmaps
from struct kmap.

Error messages are added at map__kmap to warn invalid accessing of kmap
(for the case of !map->dso->kernel, kmap(map) does not exists at all).

Also, introduces map__kmaps() to warn uninitialized kmaps.

Reviewed-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: pi3orama@163.com
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1428394966-131044-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:07:03 -03:00
He Kuang
8ea92ceb74 perf evlist: Fix inverted logic in perf_mmap__empty
perf_evlist__mmap_consume() uses perf_mmap__empty() to judge whether
perf_mmap is empty and can be released. But the result is inverted so
fix it.

Signed-off-by: He Kuang <hekuang@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1428399071-7141-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-08 09:06:58 -03:00
Yunlong Song
bd05954bfa perf data: Support using -f to override perf.data file ownership for 'convert'
Enable perf data convert to use perf.data when it is not owned by
current user or root.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 28260 Apr  2 17:35 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf data convert --to-ctf=./ctf-data/
 File perf.data not owned by current user or root (use -f to override)
 # perf data convert --to-ctf=./ctf-data/ -f
   Error: unknown switch `f'

  usage: perf data convert [<options>]

     -v, --verbose         be more verbose
     -i, --input <file>    input file name
         --to-ctf ...      Convert to CTF format

After this patch:

 # perf data convert --to-ctf=./ctf-data/
 File perf.data not owned by current user or root (use -f to override)
 # perf data convert --to-ctf=./ctf-data/ -f
 # ls ctf-data/
 metadata  perf_stream_0

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-11-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:52 -03:00
Yunlong Song
e366a6d894 perf trace: Support using -f to override perf.data file ownership
Enable perf trace to use perf.data when it is not owned by current user
or root.

Example:

 # perf trace record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 4153101 Apr  2 15:28 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf trace -i perf.data
 File perf.data not owned by current user or root (use -f to override)
 # perf trace -i perf.data -f
   Error: unknown switch `f'

  usage: perf trace [<options>] [<command>]
     or: perf trace [<options>] -- <command> [<options>]
     or: perf trace record [<options>] [<command>]
     or: perf trace record [<options>] -- <command> [<options>]

         --event <event>   event selector. use 'perf list' to list
 						  available events
         --comm            show the thread COMM next to its id
         --tool_stats      show tool stats
     -e, --expr <expr>     list of events to trace
     -o, --output <file>   output file name
     -i, --input <file>    Analyze events in file
     -p, --pid <pid>       trace events on existing process id
     -t, --tid <tid>       trace events on existing thread id
         --filter-pids <float>
  ...

As shown above, the -f option does not work at all.

After this patch:

 # perf trace -i perf.data
 File perf.data not owned by current user or root (use -f to override)
 # perf trace -i perf.data -f
 0.056 ( 0.002 ms): ls/47325 brk(                                 ...
 0.108 ( 0.018 ms): ls/47325 mmap(len: 4096, prot: READ|WRITE,    ...
 0.145 ( 0.013 ms): ls/47325 access(filename: 0x7f31259a0eb0,     ...
 0.172 ( 0.008 ms): ls/47325 open(filename: 0x7fffeb9a0d00,       ...
 0.180 ( 0.004 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,       ...
 0.185 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00,       ...
 0.189 ( 0.003 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,       ...
 0.195 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00,       ...
 0.199 ( 0.002 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,       ...
 0.205 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00,       ...
 0.211 ( 0.004 ms): ls/47325 stat(filename: 0x7fffeb9a0d00,       ...
 0.220 ( 0.007 ms): ls/47325 open(filename: 0x7f312599e8ff,       ...
 ...
 ...

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-10-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:51 -03:00
Yunlong Song
44f7e432e3 perf timechart: Support using -f to override perf.data file ownership
Enable perf timechart to use perf.data when it is not owned by current
user or root.

Example:

 # perf timechart record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 5471744 Apr  2 15:15 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf timechart
 File perf.data not owned by current user or root (use -f to override)
 # perf timechart -f
   Error: unknown switch `f'

  usage: perf timechart [<options>] {record}

     -i, --input <file>    input file name
     -o, --output <file>   output file name
     -w, --width <n>       page width
         --highlight <duration or task name>
                           highlight tasks. Pass duration in ns or process name.
     -P, --power-only      output power data only
     -T, --tasks-only      output processes data only
     -p, --process <process>
                           process selector. Pass a pid or process name.
         --symfs <directory>
                           Look for files with symbols relative to this directory
     -n, --proc-num <n>    min. number of tasks to print
     -t, --topology        sort CPUs according to topology
         --io-skip-eagain  skip EAGAIN errors
         --io-min-time <time>
                           all IO faster than min-time will visually appear longer
         --io-merge-dist <time>
                           merge events that are merge-dist us apart

As shown above, the -f option does not work at all.

After this patch:

 # perf timechart
 File perf.data not owned by current user or root (use -f to override)
 # perf timechart -f
 Written 0.0 seconds of trace to output.svg.
 # cat output.svg
 <?xml version="1.0" standalone="no"?>
 <!DOCTYPE svg SYSTEM "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <svg width="1000" height="10110" version="1.1" xmlns="http://www.w3.org/2000/svg">
 <defs>
   <style type="text/css">
     <![CDATA[
       rect          { stroke-width: 1; }
 ...
 ...

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-9-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:50 -03:00
Yunlong Song
06af0f2c91 perf script: Support using -f to override perf.data file ownership
Enable perf script to use perf.data when it is not owned by current user
or root. Change the short option name of --fields to -F to avoid confusion
with --force.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 28360 Apr  2 14:53 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf script
 File perf.data not owned by current user or root (use -f to override)
 # perf script -f
   Error: switch `f' requires a value

  usage: perf script [<options>]
     or: perf script [<options>] record <script> [<record-options>] <command>
     or: perf script [<options>] report <script> [script-args]
     or: perf script [<options>] <script> [<record-options>] <command>
     or: perf script [<options>] <top-script> [script-args]

     -f, --fields <str>    comma separated output fields prepend with
     'type:'. Valid types: hw,sw,trace,raw. Fields:
     comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr,symoff,period

As shown above, the -f option does not work at all. And -f is already
taken up by --fields, which makes --force confused, so change the short
option name of --fields to -F like what other perf commands do (e.g.
perf report -F) and use -f as the short option name of --force.

After this patch:

 # perf script
 File perf.data not owned by current user or root (use -f to override)
 # perf script -f
 :41298 41298 2590086.564226:          1 cycles:  ffffffff8103efc6
 native_write_msr_safe ([kernel.kallsyms])
 :41298 41298 2590086.564244:          1 cycles:  ffffffff8103efc6
 native_write_msr_safe ([kernel.kallsyms])
 :41298 41298 2590086.564249:          7 cycles:  ffffffff8103efc6
 native_write_msr_safe ([kernel.kallsyms])
 :41298 41298 2590086.564255:        176 cycles:  ffffffff8103efc6
 native_write_msr_safe ([kernel.kallsyms])
     ls 41298 2590086.567346:       4059 cycles:  ffffffff8105a592
     raise_softirq ([kernel.kallsyms])
     ls 41298 2590086.567353:       3717 cycles:  ffffffff8105a592
     raise_softirq ([kernel.kallsyms])
     ls 41298 2590086.567358:      63058 cycles:  ffffffff8105a592
     raise_softirq ([kernel.kallsyms])
     ls 41298 2590086.567448:    1706255 cycles:            406ae0
     [unknown] (/usr/bin/ls)

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-8-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:50 -03:00
Yunlong Song
62a1a63a77 perf mem: Support using -f to override perf.data file ownership
Enable perf mem to use perf.data when it is not owned by current user or
root.

Example:

 # perf mem -t load record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 16392 Apr  2 14:34 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf mem -D report
 File perf.data not owned by current user or root (use -f to override)
 # perf mem -D -f report
   Error: unknown switch `f'

  usage: perf mem [<options>] {record|report}

     -t, --type <type>     memory operations(load,store) Default load,store
     -D, --dump-raw-samples
                           dump raw samples in ASCII
     -U, --hide-unresolved
                           Only display entries resolved to a symbol
     -i, --input <file>    input file name
     -C, --cpu <cpu>       list of cpus to profile
     -x, --field-separator <separator>
                           separator for columns, no spaces will be added
                           between columns '.' is reserved.

As shown above, the -f option does not work at all.

After this patch:

 # perf mem -D report
 File perf.data not owned by current user or root (use -f to override)
 # perf mem -D -f report
 # PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL
 39095 39095 0xffffffff81127e40 0x016ffff887f45148338 8 0x68100142
 /proc/kcore:perf_event_aux
 39095 39095 0xffffffff8100a3fe 0xffff89007f8cb7d0 6 0x68100142
 /proc/kcore:native_sched_clock
 39095 39095 0xffffffff81309139 0xffff88bf44c9ded8 6 0x68100142
 /proc/kcore:acpi_map_lookup
 39095 39095 0xffffffff810f8c4c 0xffff89007f8ccd88 6 0x68100142
 /proc/kcore:rcu_nmi_exit
 39095 39095 0xffffffff81136346 0xffff88fea995dd50 6 0x68100142
 /proc/kcore:unlock_page
 39095 39095 0xffffffff812a64a2 0xffff88fea995dcc8 6 0x68100142
 /proc/kcore:half_md4_transform
 39095 39095 0x7f0cf877c7e9 0x25dfb94 6 0x68100142
 /lib64/libc-2.19.so:__readdir64
 39095 39095 0x7f0cf87575a3 0x7f0cf9163731 6 0x68100142
 /lib64/libc-2.19.so:__strcoll_l
 39095 39095 0xffffffff8116910e 0xffffea01c1bfbd50 23 0x68100242
 /proc/kcore:page_remove_rmap

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-7-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:49 -03:00
Yunlong Song
c4ac732a03 perf lock: Support using -f to override perf.data file ownership
Enable perf lock to use perf.data when it is not owned by current user
or root.

Example:

 # perf lock record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 4880686 Apr  2 14:14 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf lock report
 File perf.data not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf lock report -f
   Error: unknown switch `f'

  usage: perf lock report [<options>]

     -k, --key <acquired>  key for sorting (acquired / contended /
     avg_wait / wait_total / wait_max / wait_min)

As shown above, the -f option does not work at all.

After this patch:

 # perf lock report
 File perf.data not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf lock report -f
                Name   acquired  contended   avg wait (ns) total wait (ns) ...

 &ldata->output_l...        128          0               0               0 ...
          &ctx->lock        114          0               0               0 ...
         &p->pi_lock        112          0               0               0 ...
 &(&pool->lock)->...        112          0               0               0 ...
 &(&dentry->d_loc...         70          0               0               0 ...
 &(&newf->file_lo...         62          0               0               0 ...
 &(&fs->lock)->rl...         43          0               0               0 ...
 ...

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-6-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:48 -03:00
Yunlong Song
8cc5ec1f75 perf kvm: Support using -f to override perf.data.guest file ownership
Enable perf kvm to use perf.data.guest when it is not owned by current
user or root.

Example:

 # perf kvm stat record ls
 # chown Yunlong.Song:Yunlong.Song perf.data.guest
 # ls -al perf.data.guest
 -rw------- 1 Yunlong.Song Yunlong.Song 4128937 Apr  2 11:05 perf.data.guest
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf kvm stat report
 File perf.data.guest not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf kvm stat report -f
   Error: unknown switch `f'

  usage: perf kvm stat report [<options>]

         --event <report event>
                           event for reporting: vmexit, mmio (x86 only),
                           ioport (x86 only)
         --vcpu <n>        vcpu id to report
     -k, --key <sort-key>  key for sorting: sample(sort by samples
 						   number) time (sort by avg time)
     -p, --pid <pid>       analyze events only for given process id(s)

As shown above, the -f option does not work at all.

After this patch:

 # perf kvm stat report
 File perf.data.guest not owned by current user or root (use -f to override)
 Initializing perf session failed
 # perf kvm stat report -f
 Analyze events for all VMs, all VCPUs:

   VM-EXIT    Samples  Samples%     Time%    Min Time    Max Time   Avg time

 Total Samples:0, Total events handled time:0.00us.

As shown above, the -f option really works now. Since we have not
launched any KVM related process, the result shows 0 sample here.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-5-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:47 -03:00
Yunlong Song
d1eeb77c18 perf kmem: Support using -f to override perf.data file ownership
Enable perf kmem to use perf.data when it is not owned by current user
or root.

Example:

 # perf kmem record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 5315665 Apr  2 10:54 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf kmem stat
 File perf.data not owned by current user or root (use -f to override)
 # perf kmem stat -f
   Error: unknown switch `f'

  usage: perf kmem [<options>] {record|stat}

     -i, --input <file>    input file name
     -v, --verbose         be more verbose (show symbol address, etc)
         --caller          show per-callsite statistics
         --alloc           show per-allocation statistics
     -s, --sort <key[,key2...]>
                           sort by keys: ptr, call_site, bytes, hit,
                           pingpong, frag
     -l, --line <num>      show n lines
         --raw-ip          show raw ip instead of symbol

As shown above, the -f option does not work at all.

After this patch:

 # perf kmem stat
 File perf.data not owned by current user or root (use -f to override)
 # perf kmem stat -f
 SUMMARY
 =======
 Total bytes requested: 437599
 Total bytes allocated: 615472
 Total bytes wasted on internal fragmentation: 177873
 Internal fragmentation: 28.900259%
 Cross CPU allocations: 6/1192

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-4-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:46 -03:00
Yunlong Song
ccaa474c8a perf inject: Support using -f to override perf.data file ownership
Enable perf inject to use perf.data when it is not owned by current user
or root.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 28260 Apr  2 10:37 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf inject -v -b -i perf.data -o perf.data.new
 File perf.data not owned by current user or root (use -f to override)
 # perf inject -v -b -i perf.data -o perf.data.new -f
   Error: unknown switch `f'

  usage: perf inject [<options>]

     -b, --build-ids       Inject build-ids into the output stream
     -i, --input <file>    input file name
     -o, --output <file>   output file name
     -s, --sched-stat      Merge sched-stat and sched-switch for getting
     events where and how long tasks slept
     -v, --verbose         be more verbose (show build ids, etc)
         --kallsyms <file>
                           kallsyms pathname

As shown above, the -f option does not work at all.

After this patch:

 # perf inject -v -b -i perf.data -o perf.data.new
 File perf.data not owned by current user or root (use -f to override)
 # perf inject -v -b -i perf.data -o perf.data.new -f
 build id event received for [kernel.kallsyms]:
 f6dcb66d8b98f1c0d9eb87bf043444b69f91d30c
 symsrc__init: cannot get elf header.
 Looking at the vmlinux_path (7 entries long)
 Using /proc/kcore for kernel object code
 Using /proc/kallsyms for symbols

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-3-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:45 -03:00
Yunlong Song
9e3b6ec173 perf evlist: Support using -f to override perf.data file ownership
Enable perf evlist to use perf.data when it is not owned by current user
or root.

Example:

 # perf record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 28260 Apr  2 10:18 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf evlist
 File perf.data not owned by current user or root (use -f to override)
 # perf evlist -f
   Error: unknown switch `f'

  usage: perf evlist [<options>]

     -i, --input <file>    Input file name
     -F, --freq            Show the sample frequency
     -v, --verbose         Show all event attr details
     -g, --group           Show event group information

As shown above, the -f option does not work at all.

After this patch:

 # perf evlist
 File perf.data not owned by current user or root (use -f to override)
 # perf evlist -f
 cycles

As shown above, the -f option really works now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-2-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:45 -03:00
Masami Hiramatsu
c72738355b perf probe: Fix to track down unnamed union/structure members
Fix 'perf probe' to track down unnamed union/structure members.

perf probe did not track down the tree of unnamed union/structure
members, since it just failed to find given "name" in a parent
structure/union.  To solve this issue, I've introduced 2 changes.

- Fix die_find_member() to track down the type-DIE if it is
  unnamed, and if it contains the specified member, returns the
  unnamed member.
  (note that we don't return found member, since unnamed member
   has the offset in the parent structure)
- Fix convert_variable_fields() to track down the unnamed union/
  structure (one-by-one).

With this patch, perf probe can access unnamed fields:
  -----
  #./perf probe -nfx ./perf lock__delete ops 'locked_ops=ops->locked.ops'
  Added new event:
    probe_perf:lock__delete (on lock__delete in /home/mhiramat/ksrc/linux-3/tools/perf/perf with ops locked_ops=ops->locked.ops)

  You can now use it in all perf tools, such as:

          perf record -e probe_perf:lock__delete -aR sleep 1
  -----

Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Report-Link: https://lkml.org/lkml/2015/3/5/431
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150402073312.14482.37942.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:44 -03:00
Arnaldo Carvalho de Melo
b83e868d0a perf db-export: No need to have ->thread twice in struct export_sample
As it comes from address_location->thread, that is already stored as
export_sample->al, where the thread can be obtained.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20150402141542.GA9630@kernel.org
Link: http://lkml.kernel.org/n/tip-bzotbl4epoztw0jd6sm2stpf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:43 -03:00
Arnaldo Carvalho de Melo
7327259d7e perf db-export: No need to pass thread twice to db_export__sample
As it is available via another parameter, address_location->thread.

Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: lkml.kernel.org/r/551D08F8.3040706@intel.com
Link: http://lkml.kernel.org/n/tip-6dbn0tcm9hyv92g7h3zj2dbt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:42 -03:00
Arnaldo Carvalho de Melo
f9d5d549d2 perf scripting: No need to pass thread twice to the scripting callbacks
It is already in the addr_location, so remove the redundant 'thread'
parameter from the callback signatures.

Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1427906210-10519-3-git-send-email-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:41 -03:00
Arnaldo Carvalho de Melo
79628f2cfe perf script: No need to lookup thread twice
We get the thread when we call perf_event__preprocess_sample(), no need
to do it before that.

Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1427906210-10519-2-git-send-email-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-02 13:18:21 -03:00
Ingo Molnar
223aa646d5 Merge branch 'perf/timer' into perf/core
This WIP branch is now ready to be merged.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-04-02 13:22:35 +02:00
Arnaldo Carvalho de Melo
9870d78095 perf ordered_samples: Remove references to perf_{evlist,tool} and machines
As these can be obtained from the ordered_events pointer, via
container_of, reducing the cross section of ordered_samples.

These were added to ordered_samples in:

 commit b7b61cbebd
 Author: Arnaldo Carvalho de Melo <acme@redhat.com>
 Date:   Tue Mar 3 11:58:45 2015 -0300

    perf ordered_events: Shorten function signatures

    By keeping pointers to machines, evlist and tool in ordered_events.

But that was more a transitional patch while moving stuff out from
perf_session.c to ordered_events.c and possibly not even needed by then,
as we could use the container_of() method and instead of having the
nr_unordered_samples stats in events_stats, we can have it in
ordered_samples.

Based-on-a-patch-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-4lk0t9js82g0tfc0x1onpkjt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-31 17:52:32 -03:00
Arnaldo Carvalho de Melo
aae59fab97 perf session: Always initialize ordered_events
Even when it is not used to actually reorder events, some of its fields
are used, like session->ordered_events->tool, to shorten function
signatures where tool, for instance, was being passed, as the tool is
needed for the ordered_events code, we need it there and might as well
use it for other perf_session needs.

This fixes a problem where 'perf script' had some condition that made
session->ordered_events not to be initialized even with its
script->tool ordered_events related flags asking for it to be, which
looks like another bug and needs to be investigated further.

Always initializing session->ordered_events at least leaves the current
assumptions in place, so do it now.

Reported-by: David Ahern <dsahern@gmail.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Tested-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-b1xxk0rwkz2a0gip1uufmjqg@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-31 17:52:31 -03:00
David Ahern
ca6c41c59b perf tools: Fix ppid for synthesized fork events
363b785f38 added synthesized fork events and set a thread's parent id to
itself. Since we are already processing /proc/<pid>/status the ppid can
be determined properly. Make it so.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Mario <jmario@redhat.com>
Link: http://lkml.kernel.org/r/1427747758-18510-2-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-31 17:52:30 -03:00
David Ahern
5aa0b030e8 perf tools: Refactor comm/tgid lookup
Rather than parsing /proc/pid/status file one line at a time, read it
into a buffer in one shot and search for all strings in one pass.

tgid conversion also simplified -- removing the isspace walk. As noted
by Arnaldo those are not needed for atoi == strtol calls.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Mario <jmario@redhat.com>
Link: http://lkml.kernel.org/r/1427747758-18510-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-31 17:52:30 -03:00
David Hildenbrand
73dbcd6537 perf callchain: Fix kernel symbol resolution by remembering the cpumode
Commit 2e77784bb7 ("perf callchain: Move cpumode resolve code to
add_callchain_ip") promised "No change in behavior.".

As this commit breaks callchains on s390x (symbols not getting resolved,
observed when profiling the kernel), this statement is wrong. The cpumode
must be kept when iterating over all ips, otherwise the default
(PERF_RECORD_MISC_USER) will be used by error.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1427703060-59883-1-git-send-email-dahi@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-31 17:52:17 -03:00
Jiri Olsa
6ab2b762be perf build: Disable libbabeltrace check by default
Disabling libbabeltrace check by default and replacing the
NO_LIBBABELTRACE make variable with LIBBABELTRACE.

Users wanting the libbabeltrace feature need to build via:

  $ make LIBBABELTRACE=1

The reason for this is that the libababeltrace interface we use (version
1.3) hasn't been packaged/released yet, thus the failing feature check
only slows down build and confuses other (non CTF) developers.

Requested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jeremie Galarneau <jgalar@efficios.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150328103030.GA8431@krava.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-30 10:24:27 -03:00
Ingo Molnar
b381e63b48 Merge branch 'perf/core' into perf/timer, before applying new changes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-03-27 10:10:47 +01:00
Ingo Molnar
072e5a1cfa Merge branch 'perf/urgent' into perf/core, to pick up fixes and to refresh the tree
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-03-27 09:46:03 +01:00
Linus Torvalds
0e536e2516 kselftest fixes for: 4.0-rc6
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVFB/MAAoJEAsCRMQNDUMcBpoP/2i2r+zA/WjKoC7TTxrtQSkA
 MjAdNL0sQQK+7WUJi5tWdnUZAWLq6fK5TtHidVP231u249hNnj8Ai7rMq6J5T+z9
 1nCzHiGtVT7tgkh/MEOjEVMzD27kFYUnJ27oz5Q7CqioQItAmh78RK0THEWBVEs1
 QR0ZoRrfMTCCCihdAd9Jjo2zfPdrvYTE/AjBU9tkUFM/jQ1Zm+u4ru6mOQQkTj4n
 n6kIdTkhZqmZCmEMP/SzyrHvMq81snhyrjD/2zuoijnht8tfYP+y+QB9jgHId2p3
 CF0koKfgILaolnPCYc7G1raI2Vw7sqIAzmHRyoGg9qB/BZoCEjXXrbEtmgsIVhNO
 lBAS6nJrVoXgCX2TjD1s1X/mQvHZyr9WkVxyUzOn/VHLc9DsjEckE0KlxypS2eNK
 eeGI7/4nOfopWJ/RUIKuyBdgA8m2cy7uv6aFI3sCTDbnoKCM4L2s3ze2qp0BrCCo
 1nXviNCCYShZkVEyvlaJMF/Yop7cS70xykSGER9lycfX6l1jY+sQnhFnT0M6FjjD
 SUI0YF9vcmwrrESVY5vt3G0Y9/hW8juhvqYgnIzR68tql2aj6v3Hu35TxcIHyj9H
 wXKYLsClABBk6+XrGI1YbHxAaCbmXShuatkjtcNgO0mhgkvSBDnywQlMlzsXkpmo
 6MttGashNqGATq/SxxrM
 =OzL1
 -----END PGP SIGNATURE-----

Merge tag 'linux-kselftest-4.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest fix from Shuah Khan.

* tag 'linux-kselftest-4.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests: Fix build failures when invoked from kselftest target
2015-03-26 14:43:42 -07:00
Steven Rostedt
7c27f78a29 tools lib traceevent: Zero should not be considered "not found" in eval_flag()
Guilherme Cox found that:

 There is, however, a potential bug if there is an item with code zero
 that is not the first one in the symbol list, since eval_flag(..)
 returns 0 when it doesn't find anything.

That is, if you have the following enums:

enum {
  FOO_START = 0,
  FOO_GO    = 1,
  FOO_END   = 2
}

and then have:

  __print_symbolic(foo, FOO_GO, "go", FOO_START, "start",
		        FOO_END, "end")

If none of the enums are known to pevent, then eval_flag() will return
zero, and it will match it to the first item in the list, which would be
FOO_GO, which is not zero.

Luckily, in most cases, the first element would be zero, and the parsing
would match out of sheer luck.

Reported-by: Guilherme Cox <cox@computer.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20150324145813.0bfe95ba@gandalf.local.home
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-26 10:52:29 -03:00
Arnaldo Carvalho de Melo
6ebad5c101 perf trace: Fix syscall enter formatting bug
commit e596663ebb
 Author: Arnaldo Carvalho de Melo <acme@redhat.com>
 Date:   Fri Feb 13 13:22:21 2015 -0300

    perf trace: Handle multiple threads better wrt syscalls being intermixed

Introduced a bug where it considered the number of bytes output directly
to the output file when formatting the syscall entry buffer that is
stored to be finally printed at syscall exit, ending up leaving garbage
at the start of syscalls that appeared while another syscall was being
processed, in another thread. Fix it.

Example of garbage in the output before this patch:

 4280.102 (  0.000 ms): lsmd/763  ... [continued]: select()) = 0 Timeout
 4280.107 (275.250 ms): tuned/852 select(tvp: 0x7f41f7ffde50        ) ...
 4280.109 (  0.002 ms): lsmd/763 Xl��                                ) = -10
 4639.197 (  0.000 ms): systemd-journa/542  ... [continued]: epoll_wait()) = 1
 4639.202 (359.088 ms): lsmd/763 select(n: 6, inp: 0x7ffff21daad0, tvp: 0x7ffff21daac0) ...
 4639.207 (  0.005 ms): systemd-journa/542 Hn��                      ) = 106
 4639.221 (  0.002 ms): systemd-journa/542 uname(name: 0x7ffdbaed8e00) = 0
 4639.271 (  0.008 ms): systemd-journa/542 ftruncate(fd: 11</run/log/journal/60cd52417cf440a4a80107518bbd3c20/system.journal>, length: 50331648) = 0

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-9ckfe8mvsedgkg6y80gz1ul8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-26 10:52:29 -03:00
David Ahern
6428c59a97 perf tools: Set JOBS based on CPU or processor
Number of JOBS to use is set automatically to the number of processors found
in /proc/cpuinfo. SPARC uses 'CPU' lines rather than 'processor'. Update the
check in perf's Makefile to work for SPARC.

Signed-off-by: David Ahern <david.ahern@oracle.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1427213455-127249-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-26 10:52:28 -03:00
David Ahern
4d255766d2 perf: Bump max number of cpus to 1024
SPARC based systems currently support up to 1024 cpus (e.g. T5-8).
Allow perf to work on those systems.

Signed-off-by: David Ahern <david.ahern@oracle.com>
Link: http://lkml.kernel.org/r/1427213438-127216-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-26 10:52:28 -03:00
Arnaldo Carvalho de Melo
23d4aad48e perf evlist: Return the first evsel with an invalid filter in apply_filters()
Use of a bad filter currently generates the message:
 Error: failed to set filter with 22 (Invalid argument)

Add the event name to make it clear to which event the filter
failed to apply:
  Error: Failed to set filter "foo" on event sched:sg_lb_stats: 22: Invalid argument

To test it use something like:

 # perf record -e sched:sched_switch -e sched:*fork --filter parent_pid==1 -e sched:*wait* --filter bla usleep 1
  Error: failed to set filter "bla" on event sched:sched_stat_iowait with 22 (Invalid argument)
 #

Based-on-a-patch-by: David Ahern <dsahern@gmail.com>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-d7gq2fjvaecozp9o2i0siifu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-26 10:52:28 -03:00
David Ahern
e94eedab3a perf timechart: Fix SIBGUS error on sparc64
perf timechart -T on sparc64 is terminating due to SIGBUS. Backtrace:

Program received signal SIGBUS, Bus error.
0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28, name=0x289b28 "prev_state")
    at util/evsel.c:1918
1918	util/evsel.c: No such file or directory.
	in util/evsel.c
Missing separate debuginfos, use: debuginfo-install audit-libs-2.3.7-1.0.1.el6.sparc64 bzip2-libs-1.0.5-7.el6_0.sparc64 elfutils-libelf-0.155-2.0.3.el6.sparc64 elfutils-libs-0.155-2.0.3.el6.sparc64 glibc-2.12-1.132.0.8.el6_5.sparc64 numactl-2.0.7-8.el6.sparc64 python-libs-2.6.6-52.0.2.el6.sparc64 slang-2.2.1-1.el6.sparc64 xz-libs-4.999.9-0.3.beta.20091007git.el6.sparc64 zlib-1.2.3-29.el6.sparc64
(gdb) bt
0  0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28,
    name=0x289b28 "prev_state") at util/evsel.c:1918
1  0x0000000000123b94 in process_sample_sched_switch (tchart=0x7feffffe040, evsel=0x4ca850, sample=0x7feffffda28,
    backtrace=0xc39010 "") at builtin-timechart.c:627
2  0x0000000000122828 in process_sample_event (tool=0x7feffffe040, event=<value optimized out>, sample=0x7feffffda28,
    evsel=0x4ca850, machine=0x4c9c88) at builtin-timechart.c:569

Another extended load on unaligned pointer. As before fix by copying to
a temporary variable using memcpy.

Signed-off-by: David Ahern <david.ahern@oracle.com>
Link: http://lkml.kernel.org/r/1427228049-51893-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-26 10:52:28 -03:00
David Ahern
e03eaa400c perf tools: Add pid/tid filtering to report and script commands
The 'record' and 'top' tools already allow a user to specify a CSV of
pids and/or tids of tasks to collect data.

Add those options to the 'report' and 'script' analysis commands to only
consider samples related to the given pids/tids.

This is also inline with the existing comm option.

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1427212361-7066-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 13:02:46 -03:00
David Ahern
6b1f342354 perf diff: Add kallsyms option
Required for off-box analysis to convert kernel addresses.

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1427212317-7018-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 13:01:54 -03:00
Javi Merino
b839e1e846 tools lib traceevent: Add support for __print_array()
Since 6ea22486ba ("tracing: Add array printing helper") trace can
generate traces with variable element size arrays.  Add support to
parse them.

Signed-off-by: Javi Merino <javi.merino@arm.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1427195239-15730-1-git-send-email-javi.merino@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:46:39 -03:00
Steven Rostedt (Red Hat)
e1644aae45 tools lib traceevent: Free filter tokens in process_filter()
valgrind showed that the filter token wasn't being freed properly in
process_filter().

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20150324135923.817723903@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:23:03 -03:00