1
0
Fork 0
Commit Graph

6369 Commits (6428c59a97de7c3d88fc4e66317daea5e5008758)

Author SHA1 Message Date
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
Steven Rostedt (Red Hat) 82ac952be6 tools lib traceevent: Add way to find sub buffer boundary
For debugging purposes, it may be helpful for the kbuffer library to flag
when crossing a sub buffer.

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.650983637@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:22:09 -03:00
Steven Rostedt (Red Hat) c5e691928b tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING
When a event PADDING is hit (a deleted event that is still in the ring
buffer), translate_data() sets the length of the padding and also updates
the data pointer which is passed back to the caller.

This is unneeded because the caller also updates the data pointer with
the passed back length. translate_data() should not update the pointer,
only set the length.

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>
Cc: stable@vger.kernel.org # 3.12+
Link: http://lkml.kernel.org/r/20150324135923.461431960@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:22:04 -03:00
Steven Rostedt 5dbcfd930e tools lib traceevent: Make plugin options either string or boolean
When a plugin option is defined, by default it is a boolean (true or false).

If the option is something else, then it needs to set its "value" field to
a default string other than NULL (can be just "").

If the value is not set then the option is considered boolean, and the
updating of the option value will be handled accordingly.

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.308372986@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:20:09 -03:00
Steven Rostedt (Red Hat) 2771984c7f tools lib traceevent: Add pevent_data_pid_from_comm()
There is a pevent_data_comm_from_pid() that returns the cmdline stored for
a given pid in order for users to map pids to comms, but there's no method
to convert a comm back to a pid. This is useful for filters that specify
a comm instead of a PID (it's faster than searching each individual event).

Add a way to retrieve a comm from a pid. Since there can be more than one
pid associated to a comm, it returns a data structure that lets the user
iterate over all the saved comms for a given pid.

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.001103479@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:19:06 -03:00
Steven Rostedt (Red Hat) 5542629696 tools lib traceevent: Handle %z in bprint format
The %z printf specifier was not handled making trace_printk()s in the
kernel that used this break on output.

Reported-by: Shawn Bohrer <shawn.bohrer@gmail.com>
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>
Cc: Shawn Bohrer <shawn.bohrer@gmail.com>
Link: http://lkml.kernel.org/r/20150324135922.844361717@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:15:12 -03:00
Steven Rostedt (Red Hat) 99ad1417db tools lib traceevent: Copy trace_clock and free it
The pevent->trace_clock should not be a direct pointer to what was
given. It should be copied and freed.

Note, valgrind pointed this out when a caller passed in a pointer that
needed to be freed and it never was. Ideally, pevent should copy it
(which this change does), and free the copy. It's up to the caller to
free the clock string passed in.

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/20150324135922.695906738@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:11:19 -03:00
Josef Bacik deab6f55a2 tools lib traceevent: Handle NULL comm name
It is possible that a pid has no associated comm attached to it, although it
can still be passed to pevent_register_comm().

But if comm is NULL, it will cause strdup() to segfault. To prevent this
from happening, if comm is NULL use the default "<...>" name for the
pid.

Signed-off-by: Josef Bacik <jbacik@fb.com>
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/20150324135922.549965495@goodmis.org
Link: http://lkml.kernel.org/p/1403799732-30308-1-git-send-email-jbacik@fb.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:10:26 -03:00
Arnaldo Carvalho de Melo 18425f13a0 perf symbols: Save DSO loading errno to better report errors
Before, when some problem happened while trying to load the kernel
symtab, 'perf top' would show:

      ┌─Warning:───────────────────────────┐
      │The vmlinux file can't be used.     │
      │Kernel samples will not be resolved.│
      │                                    │
      │                                    │
      │Press any key...                    │
      └────────────────────────────────────┘

Now, it reports:

  # perf top --vmlinux /dev/null

      ┌─Warning:───────────────────────────────────────────┐
      │The /tmp/passwd file can't be used: Invalid ELF file│
      │Kernel samples will not be resolved.                │
      │                                                    │
      │                                                    │
      │Press any key...                                    │
      └────────────────────────────────────────────────────┘

This is possible because we now register the reason for not being able
to load the symtab in the dso->load_errno member, and provide a
dso__strerror_load() routine to format this error into a strerror like
string with a short reason for the error while loading.

That can be just forwarding the dso__strerror_load() call to
strerror_r(), or, for a separate errno range providing a custom message.

Reported-by: Ingo Molnar <mingo@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-u5rb5uq63xqhkfb8uv2lxd5u@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:08:43 -03:00
Arnaldo Carvalho de Melo 17e44dc46f perf target: Simplify handling of strerror_r return
To deal with forwarding the strerror_r (GNU) return we need to check if
the returned value is the buffer we passed or maybe some constant
(unknown error), simplify that action by using scnprintf, that will do
all the buflen size checks, trimming if needed.

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/n/tip-d0ik6i5gjew56j0qphql28ou@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:08:30 -03:00
Vinson Lee e1e455f4f4 perf tools: Work around lack of sched_getcpu in glibc < 2.6.
This patch fixes this build error with glibc < 2.6.

  CC       util/cloexec.o
cc1: warnings being treated as errors
util/cloexec.c: In function ‘perf_flag_probe’:
util/cloexec.c:24: error: implicit declaration of function
‘sched_getcpu’
util/cloexec.c:24: error: nested extern declaration of ‘sched_getcpu’
make: *** [util/cloexec.o] Error 1

Signed-off-by: Vinson Lee <vlee@twitter.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Yann Droneaud <ydroneaud@opteya.com>
Cc: stable@vger.kernel.org # 3.18+
Link: http://lkml.kernel.org/r/1427137761-16119-1-git-send-email-vlee@twopensource.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:08:07 -03:00
Namhyung Kim 77cfe38876 perf kmem: Print big numbers using thousands' group
Like perf stat, this makes easy to read the numbers on stat like below:

  # perf kmem stat

  SUMMARY
  =======
  Total bytes requested: 9,770,900
  Total bytes allocated: 9,782,712
  Total bytes wasted on internal fragmentation: 11,812
  Internal fragmentation: 0.120744%
  Cross CPU allocations: 74/152,819

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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>
Link: http://lkml.kernel.org/r/1427092244-22764-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:07:06 -03:00
Javi Merino 929a6bb71a tools lib traceevent: Factor out allocating and processing args
The sequence of allocating the print_arg field, calling process_arg()
and verifying that the next event delimiter is repeated twice in
process_hex() and will also be used for process_int_array().

Factor it out to a function to avoid writing the same code again and
again.

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/1426875176-30244-2-git-send-email-javi.merino@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:07:05 -03:00
Masami Hiramatsu e6d7c91c8c perf probe: Fix to get ummapped symbol address on kernel
Fix to get correctly unmapped symbol address on kernel.  This allows us
to probe on syscall symbols which are aliases of SyS_ functions with
using debuginfo.

Without this fix:
  ----
  # ./perf probe -a sys_write
  Failed to find debug information for address 3b0100
  Probe point 'sys_write' not found.
    Error: Failed to add events.
  ----
The address 0x3b0100 is a mapped address, and not usable
in debuginfo.

With this fix:
  ----
  # ./perf probe -a sys_write
  Added new event:
    probe:sys_write      (on sys_write)

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

          perf record -e probe:sys_write -aR sleep 1
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150322114022.32639.19096.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:07:04 -03:00
Yunlong Song 228f14f2cb perf tools: Remove (null) value of "Sort order" for perf mem report
When '--sort' is not set, 'perf mem report" will print a null pointer as
the output value of sort order, so fix it.

Example:

Before this patch:

 $ perf mem report
 # To display the perf.data header info, please use --header/--header-only options.
 #
 # Samples: 18  of event 'cpu/mem-loads/pp'
 # Total weight : 188
 # Sort order   : (null)
 #
 ...

After this patch:

 $ perf mem report
 # To display the perf.data header info, please use --header/--header-only options.
 #
 # Samples: 18  of event 'cpu/mem-loads/pp'
 # Total weight : 188
 # Sort order   : local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked
 #
 ...

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
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/1427082605-12881-1-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-24 12:06:55 -03:00
Jiri Olsa 2c7da8c590 perf annotate: Allow annotation for decompressed kernel modules
Decompressing kernel module file for objdump command if needed.
Annotation commands now display annotation for compressed kernel
modules.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-x4jcytk2d5qjmnjvb0w75q3f@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-23 12:49:27 -03:00
Jiri Olsa bc84f46486 perf tools: Try to lookup kernel module map before creating one
Currently we assume machine__new_module is called only once for each
module so we create its map&dso unconditionally.

However it's possible that it's called multiple times for same module.
Like for perf record:

  1) via machine__create_module during machine init
  2) via kernel MMAP event processing

Trying to lookup kernel module map before creating one.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-kx76xfqpnrpho5hdaapbqm09@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-23 12:46:51 -03:00
Jiri Olsa 907fb509f0 perf tools: Remove is_kmodule_extension function
Because it's no longer needed.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-bb84vlg76t78q8y8fdeed2qn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-23 12:40:15 -03:00
Jiri Olsa e746b3ea0d perf tools: Remove compressed argument from is_kernel_module
We no longer need the 'compressed' argument, because all
current users use 'NULL' for it.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-d72q2s7ggbmy2yzhumux4zzw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-23 12:39:30 -03:00
Jiri Olsa 8dee9ff110 perf tools: Use kmod_path__parse in is_kernel_module
Replacing the current parsing code with kmod_path__parse function call.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-r9mpbbgkp39wp1cdmv13ddq0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-23 12:38:37 -03:00
Jiri Olsa 914f85c4a2 perf tools: Use kmod_path__parse in decompress_kmodule
Replacing the file name parsing with kmod_path__parse.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-zpyyitlte7lwe2ywi51rj4n5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-23 12:37:17 -03:00
Jiri Olsa bb58a8a459 perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir
Replacing the file name parsing with kmod_path__parse
and moving the dso update into new separate function.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-q0ed76ajcyoaofotntrg5sla@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-23 11:43:25 -03:00
Jiri Olsa ca33380adf perf tools: Use kmod_path__parse for machine__new_dso
Using kmod_path__parse to get the module name and update the dso short
name within machine__new_dso function.

This way it's done only first time when dso is created, unlike the
current way when we update it all the time we process memory map of the
kernel module.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-8gjmt1ggf5ls1xkk7qi2ko4k@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:58:07 -03:00
Jiri Olsa da17ea33e5 perf tools: Add machine__module_dso function
Separate the dso object addition and update when adding new kernel
module.

Currently we update dso's symtab_type any time we find it in the list,
because we can't distinguish between new and found dso from
__dsos__findnew function.

Adding machine__module_dso that separates finding and adding new dso
objects, so there's no superfluous update of dso.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-uvqgs5tyq4wssnq6fm43hgvk@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:55:48 -03:00
Jiri Olsa 701d8d7f86 perf tools: Add dsos__addnew function
Separate the creation of new dso object and its addition to the dsos
list. It will be used in following patch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-8j43jod97fdt5dwdsushwwae@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:42 -03:00
Jiri Olsa 3c8a67f50a perf tools: Add kmod_path__parse function
Provides united way of parsing kernel module path
into several components.

The new kmod_path__parse function and few defines:

  int __kmod_path__parse(struct kmod_path *m, const char *path,
                         bool alloc_name, bool alloc_ext);

  #define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false, false)
  #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
  #define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, true)

parse kernel module @path and updates @m argument like:

  @comp - true if @path contains supported compression suffix,
          false otherwise
  @kmod - true if @path contains '.ko' suffix in right position,
          false otherwise
  @name - if (@alloc_name && @kmod) is true, it contains strdup-ed base name
          of the kernel module without suffixes, otherwise strudup-ed
          base name of @path
  @ext  - if (@alloc_ext && @comp) is true, it contains strdup-ed string
          the compression suffix

It returns 0 if there's no strdup error, -ENOMEM otherwise.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-9t6eqg8j610r94l743hkntiv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:41 -03:00
Jiri Olsa 80a32e5b49 perf tools: Add lzma decompression support for kernel module
In short, Fedora compresses kernel modules now (since version 21) with
lzma compression.

Adding lzma decompress support into the dso.c:compressions array
introduced by Namhyung earlier.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-2glp65kdtbrk0gblmirsjsnt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:40 -03:00
Jiri Olsa 6c6f0f6164 tools build: Add feature check for lzma library
Will be used to decompress 'xz' objects. The check detects
the liblzma.so devel library normally delivered by xz package.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
2015-03-21 14:53:39 -03:00
David Ahern 00ae1127a0 tools lib traceevent: Add destructor for format_field
Move the calls that frees the resources allocated for a struct format_field to
a separate routine.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1426790181-19118-1-git-send-email-dsahern@gmail.com
[ Split this part from a larger patch, added pevent_ prefix as requested by Steven ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:38 -03:00
Arnaldo Carvalho de Melo 70e9727888 perf hists browser: Indicate which callchain entries are annotated
Now that we can annotate entries in a callchain, show which ones have an
associated symbol and samples, by adding a right arrow just before the
symbol name when in verbose mode.

To toggle verbose mode press 'V'.

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: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-d2rf1p3h5gdp7hdl2gf2bozl@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:37 -03:00
Arnaldo Carvalho de Melo f208bd8df0 perf trace: Handle legacy syscalls tracepoints
Currently the code skips the first field with the expectation that it is 'nr'.
But older kernels do not have the 'nr' field:

    field:int nr;   offset:8;   size:4; signed:1;

Change perf-trace to drop the field if it exists after parsing the format file.

This fixes the off-by-one problem with older kernels (e.g., RHEL6). e.g,
perf-trace shows this for write:

  1.515 ( 0.006 ms): dd/4245 write(buf: 2</dev/pts/0>, count: 140733837536224       ) = 26

where 2 is really the fd, the huge number is really the buf address, etc.  With
this patch you get the more appropriate:

  1.813 ( 0.003 ms): dd/6330 write(fd: 2</dev/pts/0>, buf: 0x7fff22fc81f0, count: 25) = 25

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-gvpdave4u2yq2jnzbcdznpvf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:36 -03:00
Jiri Olsa e6c76d6203 perf build: Move feature checks code under tools/build
Moving feature checks code under tools/build directory.

Changing also $feature_dir to point to new feature directory location
and perf Makefiles to include Makefile.feature from new location.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-3lamtb30dhf4wo99y1n8kxg0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:35 -03:00
Jiri Olsa 970e87b338 perf build: Make features checks directory configurable
Putting feature checks directory into $feature_dir, so it's easy to
configure when we move it to bools/build later.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-sq2nsds6uk93372iyxcqcf6q@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:34 -03:00
Jiri Olsa 0afc5cad38 perf build: Separate feature make support into config/Makefile.feature
Move feature related code into separate makefile. The new
Makefile.feature is included from config/Makefile. It will be moved
later into tools/build.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-kj76wphg05x83n6d5ff85ybx@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:33 -03:00
Jiri Olsa 58d4f00ff1 perf build: Fix feature_check name clash
We have 2 feature_check functions, which conflict with each other.
Fixing it by renaming the latter to feature_display_check.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-wmyccro6qeffseforipu5kcl@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:32 -03:00
David Ahern 13f22a2d4a perf trace: Fix summary_only option
The intent of the -s/--summary-only option is to just show a summary of
the system calls and statistics without any of the individual events.
Commit e596663ebb broke that by showing the interrupted lines:

perf trace -i perf.data -s
...
     0.741 ( 0.000 ms): sleep/31316 fstat(fd: 4, statbuf: 0x7ffc75ceb830                                  ) ...
     0.744 ( 0.000 ms): sleep/31316 mmap(len: 100244, prot: READ, flags: PRIVATE, fd: 4                   ) ...
     0.747 ( 0.000 ms): perf/31315 write(fd: 3, buf: 0x7d4bb0, count: 8                                  ) ...
...

Fix by checking for the summary only option.

Signed-off-by: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/1426789383-19023-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:31 -03:00
He Kuang 0560a0c4a1 perf probe: Fix failure to add multiple probes without debuginfo
Perf tries to find probe function addresses from map when debuginfo
could not be found.

To the first added function, the value of ref_reloc_sym was set in
maps__set_kallsyms_ref_reloc_sym() and can be obtained from
host_machine->kmaps->maps. After that, new maps are added to
host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
do not have a valid ref_reloc_sym.

When adding a second function, get_target_map() may get a map without
valid ref_reloc_sym, and raise the error "Relocated base symbol is not
found".

Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.

This problem can be reproduced as following:

  $ perf probe --add='sys_write' --add='sys_open'
  Relocated base symbol is not found!
    Error: Failed to add events.

After this patch:

  $ perf probe --add='sys_write' --add='sys_open'
  Added new event:
    probe:sys_write      (on sys_write)

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

      perf record -e probe:sys_write -aR sleep 1

  Added new event:
    probe:sys_open       (on sys_open)

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

      perf record -e probe:sys_open -aR sleep 1

Signed-off-by: He Kuang <hekuang@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1426816616-2394-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-21 14:53:21 -03:00
Yunlong Song 1c30f546f3 perf build: Add config/feature-checks/*.output to the .gitignore file
They are all auto-generated files during the perf building.

Before this patch:

 $ git status
 Untracked files:
   (use "git add <file>..." to include in what will be committed)

	config/feature-checks/test-all.make.output
	config/feature-checks/test-backtrace.make.output
	config/feature-checks/test-bionic.make.output
	config/feature-checks/test-dwarf.make.output
	config/feature-checks/test-fortify-source.make.output
	config/feature-checks/test-glibc.make.output
	config/feature-checks/test-gtk2-infobar.make.output
	config/feature-checks/test-gtk2.make.output
	config/feature-checks/test-libaudit.make.output
	config/feature-checks/test-libbabeltrace.make.output
	config/feature-checks/test-libbfd.make.output
	config/feature-checks/test-libdw-dwarf-unwind.make.output
	config/feature-checks/test-libelf-getphdrnum.make.output
	config/feature-checks/test-libelf-mmap.make.output
	config/feature-checks/test-libelf.make.output
	config/feature-checks/test-libnuma.make.output
	config/feature-checks/test-libperl.make.output
	config/feature-checks/test-libpython-version.make.output
	config/feature-checks/test-libpython.make.output
	config/feature-checks/test-libslang.make.output
	config/feature-checks/test-libunwind.make.output
	config/feature-checks/test-pthread-attr-setaffinity-np.make.output
	config/feature-checks/test-stackprotector-all.make.output
	config/feature-checks/test-sync-compare-and-swap.make.output
	config/feature-checks/test-timerfd.make.output
	config/feature-checks/test-zlib.make.output

After this patch:

 $ git status
 nothing to commit, working directory clean

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
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/1426821638-11227-3-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-20 17:49:52 -03:00
Yunlong Song 43f3e14f0c perf build: Use FEATURE-DUMP instead of PERF-FEATURES in the .gitignore file
Since commit 4ae61202b3 ("perf build: Rename PERF-FEATURES into
FEATURE-DUMP") renames PERF-FEATURES into FEATURE-DUMP, the .gitignore
file should also do this thing for consistency.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
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/1426821638-11227-2-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-20 17:49:51 -03:00
Wang Nan 8b8ca6e15e perf tools: Don't allow empty argument for field-separator
Both 'perf diff' and 'perf mem' have 'field-separator' option, which
causes segfault if passed with empty string. This patch uses previously
introduced 'OPT_STRING_NOEMPTY' option macro to prevent fault.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: pi3orama@163.com
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1426820272-23302-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-20 17:49:51 -03:00
Milos Vyletel 0635b0f714 perf tools: Fix race in build_id_cache__add_s()
int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
                          const char *name, bool is_kallsyms, bool is_vdso)
{
...
        if (access(filename, F_OK)) {
               ^--------------------------------------------------------- [1]
                if (is_kallsyms) {
                         if (copyfile("/proc/kallsyms", filename))
                                goto out_free;
                } else if (link(realname, filename) && copyfile(name, filename))
                             ^-----------------------------^------------- [2]
                                                            \------------ [3]
                        goto out_free;
        }
...

When multiple instances of perf record get to [1] at more or less same time and
run access() one or more may get failure because the file does not exist yet
(since the first instance did not have chance to link it yet).

At this point the race moves to link() at [2] where first thread to get
there links file and goes on but second one gets -EEXIST so it runs
copyfile [3] which truncates the file.

reproducer:

rm -rf /root/.debug
for cpu in $(awk '/processor/ {print $3}' /proc/cpuinfo); do
	perf record -a -v -T -F 1000 -C $cpu \
		-o perf-${cpu}.data sleep 5 2> /dev/null &
done
wait

and simply search for empty files by:

find /lib/modules/`uname -r`/kernel/* -size 0

Signed-off-by: Milos Vyletel <milos@redhat.com>
Acked-by: 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: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1426847846-11112-1-git-send-email-milos@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-20 17:49:50 -03:00
Wang Nan 0c8c20779c perf report: Don't allow empty argument for '-t'.
Without this patch, perf report cause segfault if pass "" as '-t':

  $ perf report -t ""

   # To display the perf.data header info, please use --header/--header-only options.
   #
   # Samples: 37  of event 'syscalls:sys_enter_write'
   # Event count (approx.): 37
   #
   # Children    SelfCommand   Shared Object         Symbol
   Segmentation fault

Since -t is used to add field-separator for generate table, -t "" is
actually meanless. This patch defines a new OPT_STRING_NOEMPTY() option
generator to ensure user never pass empty string to that option.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: pi3orama@163.com
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1426251114-198991-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-19 13:53:28 -03:00
Wang Nan 303cb89a6d perf callchain: Separate eh/debug frame offset cache.
Commit f1f13af99a ("perf callchain: Cache eh/debug frame offset for
dwarf unwind") introduces a cache for .debug_frame and .eh_frame_hdr.
Unfortunately, it makes them share a same cache (dso->frame_offset).
Which causes unwind failure on ARM:

   $ perf test unwind
  Test dwarf unwind: FAILED!

The reason is that, if a dso has '.debug_frame' but doesn't have
'.eh_frame_hdr' (like ARM), dso->frame_offset will be filled by offset
of '.debug_frame' during the first time calling of find_proc_info() ->
read_unwind_spec_debug_frame(), and be regarded to '.eh_frame_hdr' when
the second time calling of find_proc_info() ->
read_unwind_spec_eh_frame(), since '.eh_frame_hdr' is checked prior to
'.debug_frame'.

This patch solves the problem by creating two cache fields for
'.eh_frame_hdr' and '.debug_frame'.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/55028BA0.1030701@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-03-19 13:53:27 -03:00