[tip:perf/core] perf sched timehist: Add pid and tid options

2017-09-22 Thread tip-bot for David Ahern
Commit-ID:  0f59d7a352c11712de0f226b46cb82775b4fcece
Gitweb: http://git.kernel.org/tip/0f59d7a352c11712de0f226b46cb82775b4fcece
Author: David Ahern 
AuthorDate: Fri, 1 Sep 2017 10:49:12 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 13 Sep 2017 09:49:12 -0300

perf sched timehist: Add pid and tid options

Add options to only show event for specific pid(s) and tid(s).

Signed-off-by: David Ahern 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1504288152-19690-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-sched.txt | 8 
 tools/perf/builtin-sched.c  | 4 
 2 files changed, 12 insertions(+)

diff --git a/tools/perf/Documentation/perf-sched.txt 
b/tools/perf/Documentation/perf-sched.txt
index a092a24..55b6733 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -106,6 +106,14 @@ OPTIONS for 'perf sched timehist'
 --max-stack::
Maximum number of functions to display in backtrace, default 5.
 
+-p=::
+--pid=::
+   Only show events for given process ID (comma separated list).
+
+-t=::
+--tid=::
+   Only show events for given thread ID (comma separated list).
+
 -s::
 --summary::
 Show only a summary of scheduling by thread with min, max, and average
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 322b4de..b7e8812 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -3363,6 +3363,10 @@ int cmd_sched(int argc, const char **argv)
OPT_STRING(0, "time", &sched.time_str, "str",
   "Time span for analysis (start,stop)"),
OPT_BOOLEAN(0, "state", &sched.show_state, "Show task state when 
sched-out"),
+   OPT_STRING('p', "pid", &symbol_conf.pid_list_str, "pid[,pid...]",
+  "analyze events only for given process id(s)"),
+   OPT_STRING('t', "tid", &symbol_conf.tid_list_str, "tid[,tid...]",
+  "analyze events only for given thread id(s)"),
OPT_PARENT(sched_options)
};
 


[tip:perf/core] perf sched timehist: Improve error message when analyzing wrong file

2016-12-07 Thread tip-bot for David Ahern
Commit-ID:  f45bf8d3939d8f32f06ec12e56d2b8651c5437b4
Gitweb: http://git.kernel.org/tip/f45bf8d3939d8f32f06ec12e56d2b8651c5437b4
Author: David Ahern 
AuthorDate: Tue, 29 Nov 2016 13:39:48 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 7 Dec 2016 12:00:32 -0300

perf sched timehist: Improve error message when analyzing wrong file

Arnaldo reported an unhelpful error message when running perf sched
timehist on a file that did not contain sched tracepoints:

[root@jouet ~]# perf sched timehist
No trace sample to read. Did you call 'perf record -R'?

[root@jouet ~]# perf evlist -v
cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: 
IP|TID|TIME|CALLCHAIN|CPU|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, 
freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, 
comm_exec: 1

Change the has_traces check to look for the sched_switch event. Analysis
for perf sched timehist requires at least this event.

Now when analyzing a file without sched tracepoints you get:

root@f21-vbox:/tmp$ perf sched timehist
No sched_switch events found. Have you run 'perf sched record'?

Signed-off-by: David Ahern 
Reported-and-Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1480451988-43673-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 870d94c..84c39f1 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2629,8 +2629,12 @@ static int perf_sched__timehist(struct perf_sched *sched)
if (perf_session__set_tracepoints_handlers(session, handlers))
goto out;
 
-   if (!perf_session__has_traces(session, "record -R"))
+   /* sched_switch event at a minimum needs to exist */
+   if (!perf_evlist__find_tracepoint_by_name(session->evlist,
+ "sched:sched_switch")) {
+   pr_err("No sched_switch events found. Have you run 'perf sched 
record'?\n");
goto out;
+   }
 
if (sched->show_migrations &&
perf_session__set_tracepoints_handlers(session, migrate_handlers))


[tip:perf/core] perf kmem: Add option to specify time window of interest

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  2a865bd844315c88bf922761e4fd3374d046
Gitweb: http://git.kernel.org/tip/2a865bd844315c88bf922761e4fd3374d046
Author: David Ahern 
AuthorDate: Tue, 29 Nov 2016 10:15:45 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 1 Dec 2016 13:03:02 -0300

perf kmem: Add option to specify time window of interest

Add option to allow user to control analysis window. e.g., collect data
for time window and analyze a segment of interest within that window.

Committer notes:

Testing it:

  # perf kmem record usleep 1
  [ perf record: Woken up 0 times to write data ]
  [ perf record: Captured and wrote 1.540 MB perf.data (2049 samples) ]
  # perf evlist
  kmem:kmalloc
  kmem:kmalloc_node
  kmem:kfree
  kmem:kmem_cache_alloc
  kmem:kmem_cache_alloc_node
  kmem:kmem_cache_free
  # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
  #
  # # Use 'perf script' to get a first approach, select a chunk for then using
  # # with 'perf kmem stat --time'
  #
  # perf script | tail -15
usleep 9889 [0] 20119.782088:  kmem:kmem_cache_free: 
(selinux_file_free_security+0x27) call_site=b936aa07 
ptr=0x888a1df49fc0
  perf 9888 [3] 20119.782088:  kmem:kmem_cache_free: 
(jbd2_journal_stop+0x1a1) call_site=b9334581 ptr=0x888bdf1a39c0
  perf 9888 [3] 20119.782089: kmem:kmem_cache_alloc: 
(jbd2__journal_start+0x72) call_site=b9333b42 ptr=0x888bdf1a39c0 
bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
  perf 9888 [3] 20119.782090:  kmem:kmem_cache_free: 
(jbd2_journal_stop+0x1a1) call_site=b9334581 ptr=0x888bdf1a39c0
  perf 9888 [3] 20119.782090: kmem:kmem_cache_alloc: 
(jbd2__journal_start+0x72) call_site=b9333b42 ptr=0x888bdf1a39c0 
bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
usleep 9889 [0] 20119.782091: kmem:kmem_cache_alloc: 
(__sigqueue_alloc+0x4a) call_site=b90ad33a ptr=0x8889f071f6e0 
bytes_req=160 bytes_alloc=160 gfp_flags=GFP_ATOMIC|__GFP_NOTRACK
  perf 9888 [3] 20119.782091:  kmem:kmem_cache_free: 
(jbd2_journal_stop+0x1a1) call_site=b9334581 ptr=0x888bdf1a39c0
  perf 9888 [3] 20119.782093:  kmem:kmem_cache_free: 
(__sigqueue_free.part.17+0x33) call_site=b90ad3f3 ptr=0x8889f071f6e0
  perf 9888 [3] 20119.782098: kmem:kmem_cache_alloc: 
(jbd2__journal_start+0x72) call_site=b9333b42 ptr=0x888bdf1a39c0 
bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
  perf 9888 [3] 20119.782098:  kmem:kmem_cache_free: 
(jbd2_journal_stop+0x1a1) call_site=b9334581 ptr=0x888bdf1a39c0
  perf 9888 [3] 20119.782099: kmem:kmem_cache_alloc: 
(jbd2__journal_start+0x72) call_site=b9333b42 ptr=0x888bdf1a39c0 
bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
  perf 9888 [3] 20119.782100: kmem:kmem_cache_alloc: 
(alloc_buffer_head+0x21) call_site=b9287cc1 ptr=0x8889b12722d8 
bytes_req=104 bytes_alloc=104 gfp_flags=GFP_NOFS|__GFP_ZERO
  perf 9888 [3] 20119.782101:  kmem:kmem_cache_free: 
(jbd2_journal_stop+0x1a1) call_site=b9334581 ptr=0x888bdf1a39c0
  perf 9888 [3] 20119.782102: kmem:kmem_cache_alloc: 
(jbd2__journal_start+0x72) call_site=b9333b42 ptr=0x888bdf1a39c0 
bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
  perf 9888 [3] 20119.782103:  kmem:kmem_cache_free: 
(jbd2_journal_stop+0x1a1) call_site=b9334581 ptr=0x888bdf1a39c0
  #
  # # stats for the whole perf.data file, i.e. no interval specified
  #
  # perf kmem stat

  SUMMARY (SLAB allocator)
  
  Total bytes requested: 172,628
  Total bytes allocated: 173,088
  Total bytes freed: 161,280
  Net total bytes allocated: 11,808
  Total bytes wasted on internal fragmentation: 460
  Internal fragmentation: 0.265761%
  Cross CPU allocations: 0/851
  #
  # # stats for an end open interval, after a certain time:
  #
  # perf kmem stat --time 20119.782088,

  SUMMARY (SLAB allocator)
  
  Total bytes requested: 552
  Total bytes allocated: 552
  Total bytes freed: 448
  Net total bytes allocated: 104
  Total bytes wasted on internal fragmentation: 0
  Internal fragmentation: 0.00%
  Cross CPU allocations: 0/8
  #

Signed-off-by: David Ahern 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1480439746-42695-6-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-kmem.txt |  7 +++
 tools/perf/builtin-kmem.c  | 24 
 2 files changed, 31 insertions(+)

diff --git a/tools/perf/Documentation/perf-kmem.txt 
b/tools/perf/Documentation/perf-kmem.txt
index ff0f433..479fc32 100644
--- a/tools/perf/Documentation/perf-kmem.txt
+++ b/tools/perf/Documentation/perf-kmem.txt
@@ -61,6 +61,13 @@ OPTIONS
default, but this option shows live (currently 

[tip:perf/core] perf tools: Move parse_nsec_time to time-utils.c

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  c284d669a20d408b70ce0dc9b2d995971f5fe0c7
Gitweb: http://git.kernel.org/tip/c284d669a20d408b70ce0dc9b2d995971f5fe0c7
Author: David Ahern 
AuthorDate: Tue, 29 Nov 2016 10:15:42 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 1 Dec 2016 13:02:39 -0300

perf tools: Move parse_nsec_time to time-utils.c

Code move only; no functional change intended.

Committer notes:

Fix the build on Ubuntu 16.04 x86-64 cross-compiling to S/390, with this
set of auto-detected features:

  ... dwarf: [ on  ]
  ...dwarf_getlocations: [ on  ]
  ... glibc: [ on  ]
  ...  gtk2: [ OFF ]
  ...  libaudit: [ OFF ]
  ...libbfd: [ OFF ]
  ...libelf: [ on  ]
  ...   libnuma: [ OFF ]
  ...numa_num_possible_cpus: [ OFF ]
  ...   libperl: [ OFF ]
  ... libpython: [ OFF ]
  ...  libslang: [ OFF ]
  ... libcrypto: [ OFF ]
  ... libunwind: [ OFF ]
  ...libdw-dwarf-unwind: [ on  ]
  ...  zlib: [ on  ]
  ...  lzma: [ OFF ]
  ... get_cpuid: [ OFF ]
  ...   bpf: [ on  ]

Where it was failing with:

CC   /tmp/build/perf/util/time-utils.o
  util/time-utils.c: In function 'parse_nsec_time':
  util/time-utils.c:17:13: error: implicit declaration of function 'strtoul' 
[-Werror=implicit-function-declaration]
time_sec = strtoul(str, &end, 10);
   ^
  util/time-utils.c:17:2: error: nested extern declaration of 'strtoul' 
[-Werror=nested-externs]
time_sec = strtoul(str, &end, 10);
^
  util/time-utils.c: In function 'perf_time__parse_str':
  util/time-utils.c:93:2: error: implicit declaration of function 'free' 
[-Werror=implicit-function-declaration]
free(str);
^
  util/time-utils.c:93:2: error: incompatible implicit declaration of built-in 
function 'free' [-Werror]
  util/time-utils.c:93:2: note: include '' or provide a declaration 
of 'free'

Do as suggested and add a '#include ' to get the free() and strtoul()
declarations and fix the build.

Signed-off-by: David Ahern 
Acked-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1480439746-42695-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/time-utils.c | 36 +++-
 tools/perf/util/time-utils.h |  2 ++
 tools/perf/util/util.c   | 33 -
 tools/perf/util/util.h   |  2 --
 4 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
index 0443b2a..d1b21c7 100644
--- a/tools/perf/util/time-utils.c
+++ b/tools/perf/util/time-utils.c
@@ -1,5 +1,7 @@
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -7,7 +9,39 @@
 #include "perf.h"
 #include "debug.h"
 #include "time-utils.h"
-#include "util.h"
+
+int parse_nsec_time(const char *str, u64 *ptime)
+{
+   u64 time_sec, time_nsec;
+   char *end;
+
+   time_sec = strtoul(str, &end, 10);
+   if (*end != '.' && *end != '\0')
+   return -1;
+
+   if (*end == '.') {
+   int i;
+   char nsec_buf[10];
+
+   if (strlen(++end) > 9)
+   return -1;
+
+   strncpy(nsec_buf, end, 9);
+   nsec_buf[9] = '\0';
+
+   /* make it nsec precision */
+   for (i = strlen(nsec_buf); i < 9; i++)
+   nsec_buf[i] = '0';
+
+   time_nsec = strtoul(nsec_buf, &end, 10);
+   if (*end != '\0')
+   return -1;
+   } else
+   time_nsec = 0;
+
+   *ptime = time_sec * NSEC_PER_SEC + time_nsec;
+   return 0;
+}
 
 static int parse_timestr_sec_nsec(struct perf_time_interval *ptime,
  char *start_str, char *end_str)
diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h
index 8f3e0e3..c1f197c 100644
--- a/tools/perf/util/time-utils.h
+++ b/tools/perf/util/time-utils.h
@@ -5,6 +5,8 @@ struct perf_time_interval {
u64 start, end;
 };
 
+int parse_nsec_time(const char *str, u64 *ptime);
+
 int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr);
 
 bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp);
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 67ac765..9ddd988 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -400,39 +400,6 @@ void sighandler_dump_stack(int sig)
raise(sig);
 }
 
-int parse_nsec_time(const char *str, u64 *ptime)
-{
-   u64 time_sec, time_nsec;
-   char *end;
-
-   time_sec = strtoul(str, &end, 10);
-   if (*end != '.' 

[tip:perf/core] perf report: Add option to specify time window of interest

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  46690a8051e4b5901a49080443a17a270e0bd8a2
Gitweb: http://git.kernel.org/tip/46690a8051e4b5901a49080443a17a270e0bd8a2
Author: David Ahern 
AuthorDate: Tue, 29 Nov 2016 10:15:46 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 1 Dec 2016 13:03:10 -0300

perf report: Add option to specify time window of interest

Add option to allow user to control analysis window. e.g., collect data
for time window and analyze a segment of interest within that window.

Committer notes:

Testing it:

Using the perf.data file captured via 'perf kmem record':

  # perf report --header-only
  # 
  # captured on: Tue Nov 29 16:01:53 2016
  # hostname : jouet
  # os release : 4.8.8-300.fc25.x86_64
  # perf version : 4.9.rc6.g5a6aca
  # arch : x86_64
  # nrcpus online : 4
  # nrcpus avail : 4
  # cpudesc : Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
  # cpuid : GenuineIntel,6,61,4
  # total memory : 20254660 kB
  # cmdline : /home/acme/bin/perf kmem record usleep 1
  # event : name = kmem:kmalloc, , id = { 931980, 931981, 931982, 931983 }, 
type = 2, size = 112, config = 0x1b9, { sample_period, sample_freq } = 1, 
sample_typ
  # event : name = kmem:kmalloc_node, , id = { 931984, 931985, 931986, 931987 
}, type = 2, size = 112, config = 0x1b7, { sample_period, sample_freq } = 1, 
sampl
  # event : name = kmem:kfree, , id = { 931988, 931989, 931990, 931991 }, type 
= 2, size = 112, config = 0x1b5, { sample_period, sample_freq } = 1, sample_type
  # event : name = kmem:kmem_cache_alloc, , id = { 931992, 931993, 931994, 
931995 }, type = 2, size = 112, config = 0x1b8, { sample_period, sample_freq } 
= 1, s
  # event : name = kmem:kmem_cache_alloc_node, , id = { 931996, 931997, 931998, 
931999 }, type = 2, size = 112, config = 0x1b6, { sample_period, sample_freq } =
  # event : name = kmem:kmem_cache_free, , id = { 932000, 932001, 932002, 
932003 }, type = 2, size = 112, config = 0x1b4, { sample_period, sample_freq } 
= 1, sa
  # HEADER_CPU_TOPOLOGY info available, use -I to display
  # HEADER_NUMA_TOPOLOGY info available, use -I to display
  # pmu mappings: cpu = 4, intel_pt = 7, intel_bts = 6, uncore_arb = 13, 
cstate_pkg = 15, breakpoint = 5, uncore_cbox_1 = 12, power = 9, software = 1, 
uncore_im
  # HEADER_CACHE info available, use -I to display
  # missing features: HEADER_BRANCH_STACK HEADER_GROUP_DESC HEADER_AUXTRACE 
HEADER_STAT
  # 
  #
  # # Looking at just the histogram entries for the first event:
  #
  # perf report  | head -33
  # To display the perf.data header info, please use --header/--header-only 
options.
  #
  #
  # Total Lost Samples: 0
  #
  # Samples: 40  of event 'kmem:kmalloc'
  # Event count (approx.): 40
  #
  # Overhead  Trace output
  #   
...
  #
37.50%  call_site=b91ad3c7 ptr=0x88895fc05000 bytes_req=4096 
bytes_alloc=4096 gfp_flags=GFP_KERNEL
10.00%  call_site=b9258416 ptr=0x888a1dc61f00 bytes_req=240 
bytes_alloc=256 gfp_flags=GFP_KERNEL|__GFP_ZERO
 7.50%  call_site=b9258416 ptr=0x888a2640ac00 bytes_req=240 
bytes_alloc=256 gfp_flags=GFP_KERNEL|__GFP_ZERO
 2.50%  call_site=b92759ba ptr=0x888a26776000 bytes_req=4096 
bytes_alloc=4096 gfp_flags=GFP_KERNEL
 2.50%  call_site=b9276864 ptr=0x8886f6b82600 bytes_req=136 
bytes_alloc=192 gfp_flags=GFP_KERNEL|__GFP_ZERO
 2.50%  call_site=b9276903 ptr=0x888aefcf0460 bytes_req=32 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b92ad0ce ptr=0x888756c98a00 bytes_req=392 
bytes_alloc=512 gfp_flags=GFP_KERNEL
 2.50%  call_site=b92ad0ce ptr=0x888756c9ba00 bytes_req=504 
bytes_alloc=512 gfp_flags=GFP_KERNEL
 2.50%  call_site=b92ad301 ptr=0x888a31747600 bytes_req=128 
bytes_alloc=128 gfp_flags=GFP_KERNEL
 2.50%  call_site=b92ad511 ptr=0x888a9d26a2a0 bytes_req=28 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x88873e8c11a0 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x88873e8c12c0 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x88873e8c1540 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x88873e8c15a0 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x88873e8c15e0 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x88873e8c16e0 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x88873e8c1c20 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b936a7fb ptr=0x888a9d26a2a0 bytes_req=24 
bytes_alloc=32 gfp_flags=GFP_KERNEL
 2.50%  call_site=b9373e66 ptr=0x8889f1931240 bytes_req=64

[tip:perf/core] perf tools: Add time-based utility functions

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  fdf9dc4b34f5f40919370c4601eccfd0db726aa5
Gitweb: http://git.kernel.org/tip/fdf9dc4b34f5f40919370c4601eccfd0db726aa5
Author: David Ahern 
AuthorDate: Tue, 29 Nov 2016 10:15:41 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 1 Dec 2016 13:02:32 -0300

perf tools: Add time-based utility functions

Add function to parse a user time string of the form ,
where start and stop are time in sec.nsec format. Both start and stop
times are optional.

Add function to determine if a sample time is within a given time
time window of interest.

Signed-off-by: David Ahern 
Acked-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1480439746-42695-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/Build|  1 +
 tools/perf/util/time-utils.c | 85 
 tools/perf/util/time-utils.h | 12 +++
 3 files changed, 98 insertions(+)

diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index b2a47aa..bdad82a 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -87,6 +87,7 @@ libperf-y += help-unknown-cmd.o
 libperf-y += mem-events.o
 libperf-y += vsprintf.o
 libperf-y += drv_configs.o
+libperf-y += time-utils.o
 
 libperf-$(CONFIG_LIBBPF) += bpf-loader.o
 libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
new file mode 100644
index 000..0443b2a
--- /dev/null
+++ b/tools/perf/util/time-utils.c
@@ -0,0 +1,85 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "perf.h"
+#include "debug.h"
+#include "time-utils.h"
+#include "util.h"
+
+static int parse_timestr_sec_nsec(struct perf_time_interval *ptime,
+ char *start_str, char *end_str)
+{
+   if (start_str && (*start_str != '\0') &&
+   (parse_nsec_time(start_str, &ptime->start) != 0)) {
+   return -1;
+   }
+
+   if (end_str && (*end_str != '\0') &&
+   (parse_nsec_time(end_str, &ptime->end) != 0)) {
+   return -1;
+   }
+
+   return 0;
+}
+
+int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr)
+{
+   char *start_str, *end_str;
+   char *d, *str;
+   int rc = 0;
+
+   if (ostr == NULL || *ostr == '\0')
+   return 0;
+
+   /* copy original string because we need to modify it */
+   str = strdup(ostr);
+   if (str == NULL)
+   return -ENOMEM;
+
+   ptime->start = 0;
+   ptime->end = 0;
+
+   /* str has the format: ,
+* variations: ,
+* ,
+* ,
+*/
+   start_str = str;
+   d = strchr(start_str, ',');
+   if (d) {
+   *d = '\0';
+   ++d;
+   }
+   end_str = d;
+
+   rc = parse_timestr_sec_nsec(ptime, start_str, end_str);
+
+   free(str);
+
+   /* make sure end time is after start time if it was given */
+   if (rc == 0 && ptime->end && ptime->end < ptime->start)
+   return -EINVAL;
+
+   pr_debug("start time %" PRIu64 ", ", ptime->start);
+   pr_debug("end time %" PRIu64 "\n", ptime->end);
+
+   return rc;
+}
+
+bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp)
+{
+   /* if time is not set don't drop sample */
+   if (timestamp == 0)
+   return false;
+
+   /* otherwise compare sample time to time window */
+   if ((ptime->start && timestamp < ptime->start) ||
+   (ptime->end && timestamp > ptime->end)) {
+   return true;
+   }
+
+   return false;
+}
diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h
new file mode 100644
index 000..8f3e0e3
--- /dev/null
+++ b/tools/perf/util/time-utils.h
@@ -0,0 +1,12 @@
+#ifndef _TIME_UTILS_H_
+#define _TIME_UTILS_H_
+
+struct perf_time_interval {
+   u64 start, end;
+};
+
+int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr);
+
+bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp);
+
+#endif


[tip:perf/core] perf script: Add option to specify time window of interest

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  a91f4c473fa1655a2a5f1ceba46f76a95eef35bb
Gitweb: http://git.kernel.org/tip/a91f4c473fa1655a2a5f1ceba46f76a95eef35bb
Author: David Ahern 
AuthorDate: Tue, 29 Nov 2016 10:15:43 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 1 Dec 2016 13:02:45 -0300

perf script: Add option to specify time window of interest

Add option to allow user to control analysis window. e.g., collect data
for some amount of time and analyze a segment of interest within that
window.

Committer notes:

Testing it:

  # perf evlist -v
  cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: 
IP|TID|TIME|CALLCHAIN|CPU|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, 
freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, 
comm_exec: 1
  #
  # perf script --hide-call-graph | head -15
swapper0 [0] 9693.370039:  1 cycles:ppp: b90072ad 
x86_pmu_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [0] 9693.370044:  1 cycles:ppp: b900ca1b 
intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [0] 9693.370046:  7 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [0] 9693.370048:126 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [0] 9693.370049:   2701 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [0] 9693.370051:  58823 cycles:ppp: b90cd2e0 idle_cpu 
(.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370059:  1 cycles:ppp: b91a713a 
ctx_resched (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370062:  1 cycles:ppp: b900ca1b 
intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370064: 13 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370065:250 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370067:   5269 cycles:ppp: b902fe79 
sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370069: 114602 cycles:ppp: b90c1c5a 
atomic_notifier_call_chain (.../4.8.8-300.fc25.x86_64/vmlinux)
   perf 5124 [2] 9693.370076:  1 cycles:ppp: b91a76c1 
__perf_event_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
   perf 5124 [2] 9693.370091:  1 cycles:ppp: b900ca1b 
intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
   perf 5124 [2] 9693.370095:  3 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
  #
  # perf script --hide-call-graph --time ,9693.370048
swapper0 [0] 9693.370039:  1 cycles:ppp: b90072ad 
x86_pmu_enable (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [0] 9693.370044:  1 cycles:ppp: b900ca1b 
intel_pmu_handle_irq (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [0] 9693.370046:  7 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
  # perf script --hide-call-graph --time 9693.370064,9693.370076
swapper0 [1] 9693.370064: 13 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370065:250 cycles:ppp: b902fd93 
native_sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370067:   5269 cycles:ppp: b902fe79 
sched_clock (.../4.8.8-300.fc25.x86_64/vmlinux)
swapper0 [1] 9693.370069: 114602 cycles:ppp: b90c1c5a 
atomic_notifier_call_chain (.../4.8.8-300.fc25.x86_64/vmlinux)
  #

Signed-off-by: David Ahern 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1480439746-42695-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-script.txt |  7 +++
 tools/perf/builtin-script.c  | 15 ++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-script.txt 
b/tools/perf/Documentation/perf-script.txt
index 0f6ee09..5dc5c6a 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -292,6 +292,13 @@ include::itrace.txt[]
 --force::
Don't do ownership validation.
 
+--time::
+   Only analyze samples within given time window: ,. Times
+   have the format seconds.microseconds. If start is not given (i.e., time
+   string is ',x.y') then analysis starts at the beginning of the file. If
+   stop time is not given (i.e, time string is 'x.y,') then analysis goes
+   to end of file.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-script-perl[1],
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 066b4bf..2f3ff69 100644
--- a/tools/perf/

[tip:perf/core] perf sched timehist: Add option to specify time window of interest

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  853b74071110bed344bad1ca9d8de27731b1c574
Gitweb: http://git.kernel.org/tip/853b74071110bed344bad1ca9d8de27731b1c574
Author: David Ahern 
AuthorDate: Tue, 29 Nov 2016 10:15:44 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 1 Dec 2016 13:02:52 -0300

perf sched timehist: Add option to specify time window of interest

Add option to allow user to control analysis window. e.g., collect data
for time window and analyze a segment of interest within that window.

Committer notes:

Testing it:

  # perf sched record -a usleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 1.593 MB perf.data (25 samples) ]
  #
  # perf sched timehist | head -18
  Samples do not have callchains.
  timecpu   task name   wait time  sch delay  run time
[tid/pid]  (msec) (msec)(msec)
  - --  --- -  -  
   19818.635579 [0002]0.000  0.000 0.000
   19818.635613 []  perf[9116]  0.000  0.000 0.000
   19818.635676 []0.000  0.000 0.063
   19818.635678 []  rcuos/2[29] 0.000  0.002 0.001
   19818.635696 [0002]  perf[9117]  0.000  0.004 0.116
   19818.635702 []0.001  0.000 0.024
   19818.635709 [0002]  migration/2[25] 0.000  0.003 0.012
   19818.636263 []  usleep[9117]0.005  0.000 0.560
   19818.636316 []0.560  0.000 0.053
   19818.636358 [0002]0.129  0.000 0.649
   19818.636358 []  usleep[9117]0.053  0.002 0.042
  #

  # perf sched timehist --time 19818.635696,
  Samples do not have callchains.
   timecpu  task name   wait time  sch delay  run time
[tid/pid]  (msec) (msec)(msec)
  - --  ---    - -
   19818.635696 [0002]  perf[9117]  0.000  0.120 0.000
   19818.635702 []0.019  0.000 0.006
   19818.635709 [0002]  migration/2[25] 0.000  0.003 0.012
   19818.636263 []  usleep[9117]0.005  0.000 0.560
   19818.636316 []0.560  0.000 0.053
   19818.636358 [0002]0.129  0.000 0.649
   19818.636358 []  usleep[9117]0.053  0.002 0.042
  #
  # perf sched timehist --time 19818.635696,19818.635709
  Samples do not have callchains.
   timecpu  task name   wait time  sch delay  run time
[tid/pid]  (msec) (msec)(msec)
  - --  --- -  - -
   19818.635696 [0002]  perf[9117]  0.000  0.120 0.000
   19818.635702 []0.019  0.000 0.006
   19818.635709 [0002]  migration/2[25] 0.000  0.003 0.012
   19818.635709 []  usleep[9117]0.005  0.000 0.006
  #

Signed-off-by: David Ahern 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1480439746-42695-5-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-sched.txt |  8 ++
 tools/perf/builtin-sched.c  | 51 +
 2 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-sched.txt 
b/tools/perf/Documentation/perf-sched.txt
index 121c60d..7775b1e 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -132,6 +132,14 @@ OPTIONS for 'perf sched timehist'
 --migrations::
Show migration events.
 
+--time::
+   Only analyze samples within given time window: ,. Times
+   have the format seconds.microseconds. If start is not given (i.e., time
+   string is ',x.y') then analysis starts at the beginning of the file. If
+   stop time is not given (i.e, time string is 'x.y,') then analysis goes
+   to end of file.
+
+
 SEE ALSO
 
 linkperf:perf-record[1]
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 4f9e7cb..870d94c 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -15,6 +15,7 @@
 #include "util/color.h"
 #include "util/stat.h"
 #include "util/callchain.h"
+#include "util/time-utils.h"
 
 #include 
 #include "util/trace-event.h"
@@ -205,6 +206,8 @@ struct perf_sched {
boolshow_wakeups;
boolshow_migrations;
u64 skipped_samples;
+   const char  *time_str;
+   struct perf_time_interval ptime;
 };
 
 /* per thread run time data */
@@ -1837,13 +1840,14 @@ static void timehist_header(struct perf_sched *sched)
 static void timehist_print_sample(struct perf_sched *sched,
  

[tip:perf/core] perf kmem stat: Track memory freed

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  aa58e9afb613fab74f33292705bb43beb0f1828d
Gitweb: http://git.kernel.org/tip/aa58e9afb613fab74f33292705bb43beb0f1828d
Author: David Ahern 
AuthorDate: Fri, 25 Nov 2016 14:42:13 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 29 Nov 2016 12:50:32 -0300

perf kmem stat: Track memory freed

Track freed memory as well as allocations and show the net in the
summary.

Committer notes:

Testing it:

  # perf kmem record usleep 1
  [ perf record: Woken up 0 times to write data ]
  [ perf record: Captured and wrote 1.626 MB perf.data (4208 samples) ]
  [root@jouet ~]# perf kmem stat --slab

  SUMMARY (SLAB allocator)
  
  Total bytes requested: 234,011
  Total bytes allocated: 234,504
  Total bytes freed: 213,328 <--
  Net total bytes allocated: 21,176
  Total bytes wasted on internal fragmentation: 493
  Internal fragmentation: 0.210231%
  Cross CPU allocations: 4/1,963
  #

Signed-off-by: David Ahern 
Tested-by: Arnaldo Carvalho de Melo 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1480110133-37039-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kmem.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index d426dcb..7fd6f1e 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -49,6 +49,7 @@ struct alloc_stat {
u64 ptr;
u64 bytes_req;
u64 bytes_alloc;
+   u64 last_alloc;
u32 hit;
u32 pingpong;
 
@@ -62,7 +63,7 @@ static struct rb_root root_alloc_sorted;
 static struct rb_root root_caller_stat;
 static struct rb_root root_caller_sorted;
 
-static unsigned long total_requested, total_allocated;
+static unsigned long total_requested, total_allocated, total_freed;
 static unsigned long nr_allocs, nr_cross_allocs;
 
 static int insert_alloc_stat(unsigned long call_site, unsigned long ptr,
@@ -105,6 +106,8 @@ static int insert_alloc_stat(unsigned long call_site, 
unsigned long ptr,
}
data->call_site = call_site;
data->alloc_cpu = cpu;
+   data->last_alloc = bytes_alloc;
+
return 0;
 }
 
@@ -223,6 +226,8 @@ static int perf_evsel__process_free_event(struct perf_evsel 
*evsel,
if (!s_alloc)
return 0;
 
+   total_freed += s_alloc->last_alloc;
+
if ((short)sample->cpu != s_alloc->alloc_cpu) {
s_alloc->pingpong++;
 
@@ -1128,6 +1133,11 @@ static void print_slab_summary(void)
printf("\n\n");
printf("Total bytes requested: %'lu\n", total_requested);
printf("Total bytes allocated: %'lu\n", total_allocated);
+   printf("Total bytes freed: %'lu\n", total_freed);
+   if (total_allocated > total_freed) {
+   printf("Net total bytes allocated: %'lu\n",
+   total_allocated - total_freed);
+   }
printf("Total bytes wasted on internal fragmentation: %'lu\n",
   total_allocated - total_requested);
printf("Internal fragmentation: %f%%\n",


[tip:perf/core] perf script: Add option to stop printing callchain

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  64eff7d9c4469b7e24fb7e5416a67ee5959c3f76
Gitweb: http://git.kernel.org/tip/64eff7d9c4469b7e24fb7e5416a67ee5959c3f76
Author: David Ahern 
AuthorDate: Fri, 25 Nov 2016 13:00:21 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 29 Nov 2016 13:06:19 -0300

perf script: Add option to stop printing callchain

Allow user to specify list of symbols which cause the dump of callchains
to stop at that symbol.

Committer notes:

Testing it:

  # perf record -ag usleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 1.177 MB perf.data (33 samples) ]
  #
  # # Without it:
  #
  # perf script
  swapper   0 [000]  9693.370039:  1 cycles:ppp:
  2072ad x86_pmu_enable 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a29d7 perf_pmu_enable.part.90 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a713a ctx_resched 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a76c1 __perf_event_enable 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a0390 event_function 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a1cff remote_function 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  326978 flush_smp_call_function_queue 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  327413 generic_smp_call_function_single_interrupt 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  249b37 smp_call_function_single_interrupt 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  a04b2c call_function_single_interrupt 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  889427 cpuidle_enter 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  2e534a call_cpuidle 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  2e5730 cpu_startup_entry 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  9f5167 rest_init 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
 137ffeb start_kernel ([kernel.vmlinux].init.text)
 137f2ca x86_64_start_reservations ([kernel.vmlinux].init.text)
 137f419 x86_64_start_kernel ([kernel.vmlinux].init.text)

  swapper   0 [000]  9693.370044:  1 cycles:ppp:
  20ca1b intel_pmu_handle_irq 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  205b0c perf_event_nmi_handler 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  22a14a nmi_handle 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  22a6b3 default_do_nmi 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  22a83c do_nmi 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  a03fb1 end_repeat_nmi 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a29d7 perf_pmu_enable.part.90 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a713a ctx_resched 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a76c1 __perf_event_enable 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a0390 event_function 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a1cff remote_function 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  326978 flush_smp_call_function_queue 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  327413 generic_smp_call_function_single_interrupt 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  249b37 smp_call_function_single_interrupt 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  a04b2c call_function_single_interrupt 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  889427 cpuidle_enter 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  2e534a call_cpuidle 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  2e5730 cpu_startup_entry 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  9f5167 rest_init 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
 137ffeb start_kernel ([kernel.vmlinux].init.text)
 137f2ca x86_64_start_reservations ([kernel.vmlinux].init.text)
  #
  # # Using it to see just what are the calls from the 'remote_function' 
function:
  #
  # perf script --stop-bt remote_function
  swapper   0 [000]  9693.370039:  1 cycles:ppp:
  2072ad x86_pmu_enable 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
  3a29d7 perf_pmu_enable.part.90 
(/usr/lib/debug/lib/modules/4.8.8-300.fc25.x8

[tip:perf/core] perf trace: Update tid/pid filtering option to leverage symbol_conf

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  aa07df6eb5061eed3f5d0820dc646d7f6ddface2
Gitweb: http://git.kernel.org/tip/aa07df6eb5061eed3f5d0820dc646d7f6ddface2
Author: David Ahern 
AuthorDate: Fri, 25 Nov 2016 09:29:52 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 25 Nov 2016 16:04:22 -0300

perf trace: Update tid/pid filtering option to leverage symbol_conf

Leverage pid/tid filtering done by symbol_conf hooks.

Signed-off-by: David Ahern 
Tested-by: Arnaldo Carvalho de Melo 
Link: 
http://lkml.kernel.org/r/1480091392-35645-1-git-send-email-...@cumulusnetworks.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 49 +-
 1 file changed, 9 insertions(+), 40 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 5f45166..206bf72 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -74,8 +74,6 @@ struct trace {
size_t  nr;
int *entries;
}   ev_qualifier_ids;
-   struct intlist  *tid_list;
-   struct intlist  *pid_list;
struct {
size_t  nr;
pid_t   *entries;
@@ -1890,18 +1888,6 @@ out_put:
return err;
 }
 
-static bool skip_sample(struct trace *trace, struct perf_sample *sample)
-{
-   if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) ||
-   (trace->tid_list && intlist__find(trace->tid_list, sample->tid)))
-   return false;
-
-   if (trace->pid_list || trace->tid_list)
-   return true;
-
-   return false;
-}
-
 static void trace__set_base_time(struct trace *trace,
 struct perf_evsel *evsel,
 struct perf_sample *sample)
@@ -1926,11 +1912,13 @@ static int trace__process_sample(struct perf_tool *tool,
 struct machine *machine __maybe_unused)
 {
struct trace *trace = container_of(tool, struct trace, tool);
+   struct thread *thread;
int err = 0;
 
tracepoint_handler handler = evsel->handler;
 
-   if (skip_sample(trace, sample))
+   thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
+   if (thread && thread__is_filtered(thread))
return 0;
 
trace__set_base_time(trace, evsel, sample);
@@ -1943,27 +1931,6 @@ static int trace__process_sample(struct perf_tool *tool,
return err;
 }
 
-static int parse_target_str(struct trace *trace)
-{
-   if (trace->opts.target.pid) {
-   trace->pid_list = intlist__new(trace->opts.target.pid);
-   if (trace->pid_list == NULL) {
-   pr_err("Error parsing process id string\n");
-   return -EINVAL;
-   }
-   }
-
-   if (trace->opts.target.tid) {
-   trace->tid_list = intlist__new(trace->opts.target.tid);
-   if (trace->tid_list == NULL) {
-   pr_err("Error parsing thread id string\n");
-   return -EINVAL;
-   }
-   }
-
-   return 0;
-}
-
 static int trace__record(struct trace *trace, int argc, const char **argv)
 {
unsigned int rec_argc, i, j;
@@ -2460,6 +2427,12 @@ static int trace__replay(struct trace *trace)
if (session == NULL)
return -1;
 
+   if (trace->opts.target.pid)
+   symbol_conf.pid_list_str = strdup(trace->opts.target.pid);
+
+   if (trace->opts.target.tid)
+   symbol_conf.tid_list_str = strdup(trace->opts.target.tid);
+
if (symbol__init(&session->header.env) < 0)
goto out;
 
@@ -2503,10 +2476,6 @@ static int trace__replay(struct trace *trace)
evsel->handler = trace__pgfault;
}
 
-   err = parse_target_str(trace);
-   if (err != 0)
-   goto out;
-
setup_pager();
 
err = perf_session__process_events(session);


[tip:perf/core] perf sched timehist: Handle cpu migration events

2016-12-02 Thread tip-bot for David Ahern
Commit-ID:  350f54fab2afd7f819e64fbeecdf980086fa59f2
Gitweb: http://git.kernel.org/tip/350f54fab2afd7f819e64fbeecdf980086fa59f2
Author: David Ahern 
AuthorDate: Fri, 25 Nov 2016 09:28:41 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 25 Nov 2016 16:00:22 -0300

perf sched timehist: Handle cpu migration events

Add handlers for sched:sched_migrate_task event. Total number of
migrations is added to summary display and -M/--migrations can be used
to show migration events.

Signed-off-by: David Ahern 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1480091321-35591-1-git-send-email-...@cumulusnetworks.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-sched.txt |  4 ++
 tools/perf/builtin-sched.c  | 97 -
 2 files changed, 99 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-sched.txt 
b/tools/perf/Documentation/perf-sched.txt
index fb9e52d..121c60d 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -128,6 +128,10 @@ OPTIONS for 'perf sched timehist'
 --wakeups::
Show wakeup events.
 
+-M::
+--migrations::
+   Show migration events.
+
 SEE ALSO
 
 linkperf:perf-record[1]
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index a49a032..4f9e7cb 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -203,6 +203,7 @@ struct perf_sched {
unsigned intmax_stack;
boolshow_cpu_visual;
boolshow_wakeups;
+   boolshow_migrations;
u64 skipped_samples;
 };
 
@@ -216,6 +217,8 @@ struct thread_runtime {
 
struct stats run_stats;
u64 total_run_time;
+
+   u64 migrations;
 };
 
 /* per event run time data */
@@ -2197,6 +2200,87 @@ static int timehist_sched_wakeup_event(struct perf_tool 
*tool,
return 0;
 }
 
+static void timehist_print_migration_event(struct perf_sched *sched,
+   struct perf_evsel *evsel,
+   struct perf_sample *sample,
+   struct machine *machine,
+   struct thread *migrated)
+{
+   struct thread *thread;
+   char tstr[64];
+   u32 max_cpus = sched->max_cpu + 1;
+   u32 ocpu, dcpu;
+
+   if (sched->summary_only)
+   return;
+
+   max_cpus = sched->max_cpu + 1;
+   ocpu = perf_evsel__intval(evsel, sample, "orig_cpu");
+   dcpu = perf_evsel__intval(evsel, sample, "dest_cpu");
+
+   thread = machine__findnew_thread(machine, sample->pid, sample->tid);
+   if (thread == NULL)
+   return;
+
+   if (timehist_skip_sample(sched, thread) &&
+   timehist_skip_sample(sched, migrated)) {
+   return;
+   }
+
+   timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr));
+   printf("%15s [%04d] ", tstr, sample->cpu);
+
+   if (sched->show_cpu_visual) {
+   u32 i;
+   char c;
+
+   printf("  ");
+   for (i = 0; i < max_cpus; ++i) {
+   c = (i == sample->cpu) ? 'm' : ' ';
+   printf("%c", c);
+   }
+   printf("  ");
+   }
+
+   printf(" %-*s ", comm_width, timehist_get_commstr(thread));
+
+   /* dt spacer */
+   printf("  %9s  %9s  %9s ", "", "", "");
+
+   printf("migrated: %s", timehist_get_commstr(migrated));
+   printf(" cpu %d => %d", ocpu, dcpu);
+
+   printf("\n");
+}
+
+static int timehist_migrate_task_event(struct perf_tool *tool,
+  union perf_event *event __maybe_unused,
+  struct perf_evsel *evsel,
+  struct perf_sample *sample,
+  struct machine *machine)
+{
+   struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
+   struct thread *thread;
+   struct thread_runtime *tr = NULL;
+   /* want pid of migrated task not pid in sample */
+   const u32 pid = perf_evsel__intval(evsel, sample, "pid");
+
+   thread = machine__findnew_thread(machine, 0, pid);
+   if (thread == NULL)
+   return -1;
+
+   tr = thread__get_runtime(thread);
+   if (tr == NULL)
+   return -1;
+
+   tr->migrations++;
+
+   /* show migrations if requested */
+   timehist_print_migration_event(sched, evsel, sample, machine, thread);
+
+   return 0;
+}
+
 static int timehist_sched_change_event(struct perf_tool *tool,
   union perf_event *event,
   struct perf_evsel *evsel,
@@ -2295,6 +2379,7 @@ static void print_thread_runtime(struct thread *t,
print_sched_time(r->run_stats.max,

[tip:perf/core] perf sched timehist: Add -V/--cpu-visual option

2016-11-23 Thread tip-bot for David Ahern
Commit-ID:  a407b0678bc1c39d70af5fdbe6421c164b69a8c0
Gitweb: http://git.kernel.org/tip/a407b0678bc1c39d70af5fdbe6421c164b69a8c0
Author: David Ahern 
AuthorDate: Wed, 16 Nov 2016 15:06:33 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 23 Nov 2016 10:44:09 -0300

perf sched timehist: Add -V/--cpu-visual option

The -V option provides a visual aid for sched switches by cpu:

  $ perf sched timehist -V
 timecpu  0123456789abc  task name  b/n time  sch 
delay   run time
 [tid/pid](msec) 
(msec) (msec)
  --- --  -    -  
-  -
  ...
   2412598.429696 [0009]   i 0.000  
0.000  0.000
   2412598.429767 [0002]sperf[7219]0.000  
0.000  0.000
   2412598.429783 [0009]   s perf[7220]0.000  
0.006  0.087
   2412598.429794 [0010]i0.000  
0.000  0.000
   2412598.429795 [0009]   s migration/9[53]   0.000  
0.003  0.011
   2412598.430370 [0010]ssleep[7220]   0.011  
0.000  0.576
   2412598.432584 [0003] i   0.000  
0.000  0.000
  ...

Committer notes:

'i' marks idle time, 's' are scheduler events.

Signed-off-by: David Ahern 
Signed-off-by: Namhyung Kim 
Acked-by: Ingo Molnar 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Andi Kleen 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/20161116060634.28477-8-namhy...@kernel.org
[ Add documentation based on above commit message ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-sched.txt |  5 
 tools/perf/builtin-sched.c  | 44 +++--
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-sched.txt 
b/tools/perf/Documentation/perf-sched.txt
index 8345208..fb9e52d 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -119,6 +119,11 @@ OPTIONS for 'perf sched timehist'
 --symfs=::
 Look for files with symbols relative to this directory.
 
+-V::
+--cpu-visual::
+   Show visual aid for sched switches by CPU: 'i' marks idle time,
+   's' are scheduler events.
+
 -w::
 --wakeups::
Show wakeup events.
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 1f87316..829468d 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -201,6 +201,7 @@ struct perf_sched {
boolsummary_only;
boolshow_callchain;
unsigned intmax_stack;
+   boolshow_cpu_visual;
boolshow_wakeups;
u64 skipped_samples;
 };
@@ -1783,10 +1784,23 @@ static char *timehist_get_commstr(struct thread *thread)
return str;
 }
 
-static void timehist_header(void)
+static void timehist_header(struct perf_sched *sched)
 {
+   u32 ncpus = sched->max_cpu + 1;
+   u32 i, j;
+
printf("%15s %6s ", "time", "cpu");
 
+   if (sched->show_cpu_visual) {
+   printf(" ");
+   for (i = 0, j = 0; i < ncpus; ++i) {
+   printf("%x", j++);
+   if (j > 15)
+   j = 0;
+   }
+   printf(" ");
+   }
+
printf(" %-20s  %9s  %9s  %9s",
"task name", "wait time", "sch delay", "run time");
 
@@ -1797,6 +1811,9 @@ static void timehist_header(void)
 */
printf("%15s %-6s ", "", "");
 
+   if (sched->show_cpu_visual)
+   printf(" %*s ", ncpus, "");
+
printf(" %-20s  %9s  %9s  %9s\n", "[tid/pid]", "(msec)", "(msec)", 
"(msec)");
 
/*
@@ -1804,6 +1821,9 @@ static void timehist_header(void)
 */
printf("%.15s %.6s ", graph_dotted_line, graph_dotted_line);
 
+   if (sched->show_cpu_visual)
+   printf(" %.*s ", ncpus, graph_dotted_line);
+
printf(" %.20s  %.9s  %.9s  %.9s",
graph_dotted_line, graph_dotted_line, graph_dotted_line,
graph_dotted_line);
@@ -1817,11 +1837,28 @@ static void timehist_print_sample(struct perf_sched 
*sched,
  struct thread *thread)
 {
struct thread_runtime *tr = thread__priv(thread);
+   u32 max_cpus = sched->max_cpu + 1;
char tstr[64];
 
timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr));
printf("%15s [%04d] ", tstr, sample->cpu);
 
+   if (sched->show_cpu_visual) {
+   u32 i;
+   char c;
+
+   printf(" ");
+   for (i = 0; i < max_cpus; ++i) {
+   /* flag idle times with 'i'; others are sched events */
+   

[tip:perf/core] perf sched timehist: Add call graph options

2016-11-23 Thread tip-bot for David Ahern
Commit-ID:  6c973c90852c3fa4b4e76a061ce89dcd373efccc
Gitweb: http://git.kernel.org/tip/6c973c90852c3fa4b4e76a061ce89dcd373efccc
Author: David Ahern 
AuthorDate: Wed, 16 Nov 2016 15:06:32 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 23 Nov 2016 10:44:09 -0300

perf sched timehist: Add call graph options

If callchains were recorded they are appended to the line with a default stack 
depth of 5:

  1.874569 [0011] gcc[31949]   0.014 0.000 1.148 
wait_for_completion_killable <- do_fork <- sys_vfork <- stub_vfork <- __vfork
  1.874591 [0010] gcc[31951]   0.000 0.000 0.024 __cond_resched <- 
_cond_resched <- wait_for_completion <- stop_one_cpu <- sched_exec
  1.874603 [0010] migration/10[59] 3.350 0.004 0.011 smpboot_thread_fn <- 
kthread <- ret_from_fork
  1.874604 [0011]1.148 0.000 0.035 cpu_startup_entry <- 
start_secondary
  1.874723 [0005]0.016 0.000 1.383 cpu_startup_entry <- 
start_secondary
  1.874746 [0005] gcc[31949]   0.153 0.078 0.022 do_wait sys_wait4 <- 
system_call_fastpath <- __GI___waitpid

 --no-call-graph can be used to not show the callchains. --max-stack is used
to control the number of frames shown (default of 5). -x/--excl options can
be used to collapse redundant callchains to get more relevant data on screen.

Signed-off-by: David Ahern 
Signed-off-by: Namhyung Kim 
Acked-by: Ingo Molnar 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Andi Kleen 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/20161116060634.28477-7-namhy...@kernel.org
[ Add documentation based on above commit message ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-sched.txt |  7 +++
 tools/perf/builtin-sched.c  | 88 ++---
 2 files changed, 89 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-sched.txt 
b/tools/perf/Documentation/perf-sched.txt
index 9a77bc7..8345208 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -99,6 +99,13 @@ OPTIONS for 'perf sched timehist'
 --kallsyms=::
 kallsyms pathname
 
+-g::
+--no-call-graph::
+   Do not display call chains if present.
+
+--max-stack::
+   Maximum number of functions to display in backtrace, default 5.
+
 -s::
 --summary::
 Show only a summary of scheduling by thread with min, max, and average
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 8fb7bcc..1f87316 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -14,6 +14,7 @@
 #include "util/thread_map.h"
 #include "util/color.h"
 #include "util/stat.h"
+#include "util/callchain.h"
 
 #include 
 #include "util/trace-event.h"
@@ -198,6 +199,8 @@ struct perf_sched {
/* options for timehist command */
boolsummary;
boolsummary_only;
+   boolshow_callchain;
+   unsigned intmax_stack;
boolshow_wakeups;
u64 skipped_samples;
 };
@@ -1810,6 +1813,7 @@ static void timehist_header(void)
 
 static void timehist_print_sample(struct perf_sched *sched,
  struct perf_sample *sample,
+ struct addr_location *al,
  struct thread *thread)
 {
struct thread_runtime *tr = thread__priv(thread);
@@ -1827,6 +1831,18 @@ static void timehist_print_sample(struct perf_sched 
*sched,
if (sched->show_wakeups)
printf("  %-*s", comm_width, "");
 
+   if (thread->tid == 0)
+   goto out;
+
+   if (sched->show_callchain)
+   printf("  ");
+
+   sample__fprintf_sym(sample, al, 0,
+   EVSEL__PRINT_SYM | EVSEL__PRINT_ONELINE |
+   EVSEL__PRINT_CALLCHAIN_ARROW,
+   &callchain_cursor, stdout);
+
+out:
printf("\n");
 }
 
@@ -1878,9 +1894,14 @@ static void timehist_update_runtime_stats(struct 
thread_runtime *r,
r->total_run_time += r->dt_run;
 }
 
-static bool is_idle_sample(struct perf_sample *sample,
-  struct perf_evsel *evsel)
+static bool is_idle_sample(struct perf_sched *sched,
+  struct perf_sample *sample,
+  struct perf_evsel *evsel,
+  struct machine *machine)
 {
+   struct thread *thread;
+   struct callchain_cursor *cursor = &callchain_cursor;
+
/* pid 0 == swapper == idle task */
if (sample->pid == 0)
return true;
@@ -1889,6 +1910,25 @@ static bool is_idle_sample(struct perf_sample *sample,
if (perf_evsel__intval(evsel, sample, "prev_pid") == 0)
return true;
}
+
+   /* want main thread for process - has maps */
+   thread = machine__findnew_thread(machine, sample->pid, sample->pid);
+   if (thread 

[tip:perf/core] perf sched timehist: Add summary options

2016-11-23 Thread tip-bot for David Ahern
Commit-ID:  52df138caaa8daaaf4e0dc64428ef06f303a8dbf
Gitweb: http://git.kernel.org/tip/52df138caaa8daaaf4e0dc64428ef06f303a8dbf
Author: David Ahern 
AuthorDate: Wed, 16 Nov 2016 15:06:30 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 23 Nov 2016 10:44:08 -0300

perf sched timehist: Add summary options

The -s/--summary option is to show process runtime statistics.  And the
 -S/--with-summary option is to show the stats with the normal output.

  $ perf sched timehist -s

  Runtime summary
comm  parent   sched-in run-timemin-run 
avg-run max-run  stddev
(count)   (msec) (msec) 
 (msec)  (msec)   %
  
-
  ksoftirqd/0[3]   2  20.011  0.004 
  0.005   0.006   14.87
  rcu_preempt[7]   2 110.071  0.002 
  0.006   0.017   20.23
  watchdog/0[11]   2  10.002  0.002 
  0.002   0.0020.00
  watchdog/1[12]   2  10.004  0.004 
  0.004   0.0040.00
  ...

  Terminated tasks:
 sleep[7220]7219  30.770  0.087 
  0.256   0.576   62.28

  Idle stats:
  CPU  0 idle for   2352.006  msec
  CPU  1 idle for   2764.497  msec
  CPU  2 idle for   2998.229  msec
  CPU  3 idle for   2967.800  msec

  Total number of unique tasks: 52
  Total number of context switches: 2532
 Total run time (msec): 218.036

Signed-off-by: David Ahern 
Signed-off-by: Namhyung Kim 
Acked-by: Ingo Molnar 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Andi Kleen 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/20161116060634.28477-5-namhy...@kernel.org
[ Add documentation from last commit, so that docs comes with the cset that 
introduces the feature ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c | 166 +++--
 1 file changed, 160 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index c0ac0c9..1e7d81a 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -194,6 +194,11 @@ struct perf_sched {
bool force;
bool skip_merge;
struct perf_sched_map map;
+
+   /* options for timehist command */
+   boolsummary;
+   boolsummary_only;
+   u64 skipped_samples;
 };
 
 /* per thread run time data */
@@ -2010,12 +2015,15 @@ static struct thread *timehist_get_thread(struct 
perf_sample *sample,
return thread;
 }
 
-static bool timehist_skip_sample(struct thread *thread)
+static bool timehist_skip_sample(struct perf_sched *sched,
+struct thread *thread)
 {
bool rc = false;
 
-   if (thread__is_filtered(thread))
+   if (thread__is_filtered(thread)) {
rc = true;
+   sched->skipped_samples++;
+   }
 
return rc;
 }
@@ -2045,7 +2053,7 @@ static int timehist_sched_wakeup_event(struct perf_tool 
*tool __maybe_unused,
return 0;
 }
 
-static int timehist_sched_change_event(struct perf_tool *tool __maybe_unused,
+static int timehist_sched_change_event(struct perf_tool *tool,
   union perf_event *event,
   struct perf_evsel *evsel,
   struct perf_sample *sample,
@@ -2056,6 +2064,7 @@ static int timehist_sched_change_event(struct perf_tool 
*tool __maybe_unused,
struct thread_runtime *tr = NULL;
u64 tprev;
int rc = 0;
+   struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
 
if (machine__resolve(machine, &al, sample) < 0) {
pr_err("problem processing %d event. skipping it\n",
@@ -2070,7 +2079,7 @@ static int timehist_sched_change_event(struct perf_tool 
*tool __maybe_unused,
goto out;
}
 
-   if (timehist_skip_sample(thread))
+   if (timehist_skip_sample(sched, thread))
goto out;
 
tr = thread__get_runtime(thread);
@@ -2082,7 +2091,8 @@ static int timehist_sched_change_event(struct perf_tool 
*tool __maybe_unused,
tprev = perf_evsel__get_time(evsel, sample->cpu);
 
timehist_update_runtime_stats(tr, sample->time, tprev);
-   timehist_print_sample(sample, thread);
+   if (!sched->summary_only)
+   timehist_print_sample(sample, thread);
 
 out:
if (tr) {
@@ -2122,6 +2132,131 @@ static int process_lost(struct perf_tool *tool 
__maybe_unused,
 }
 
 
+static void print_thread_runtime(struct thread *t,
+struct thread_runtime *

[tip:perf/core] perf sched timehist: Add -w/--wakeups option

2016-11-23 Thread tip-bot for David Ahern
Commit-ID:  fc1469f1b20777929a47f6f8e55bca12c6f142ac
Gitweb: http://git.kernel.org/tip/fc1469f1b20777929a47f6f8e55bca12c6f142ac
Author: David Ahern 
AuthorDate: Wed, 16 Nov 2016 15:06:31 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 23 Nov 2016 10:44:08 -0300

perf sched timehist: Add -w/--wakeups option

The -w option is to show wakeup events with timehist.

  $ perf sched timehist -w
 timecpu  task name  b/n time  sch delay   run time
  [tid/pid](msec) (msec) (msec)
  --- --    -  -  -
   2412598.429689 [0002]  perf[7219]
 awakened: perf[7220]
   2412598.429696 [0009]  0.000  0.000  0.000
   2412598.429767 [0002]  perf[7219]0.000  0.000  0.000
   2412598.429780 [0009]  perf[7220]
 awakened: migration/9[53]
  ...

Signed-off-by: David Ahern 
Signed-off-by: Namhyung Kim 
Acked-by: Ingo Molnar 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Andi Kleen 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/20161116060634.28477-6-namhy...@kernel.org
[ Add documentation based on above commit message ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-sched.txt |  4 +++
 tools/perf/builtin-sched.c  | 58 ++---
 2 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-sched.txt 
b/tools/perf/Documentation/perf-sched.txt
index 72730da..9a77bc7 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -112,6 +112,10 @@ OPTIONS for 'perf sched timehist'
 --symfs=::
 Look for files with symbols relative to this directory.
 
+-w::
+--wakeups::
+   Show wakeup events.
+
 SEE ALSO
 
 linkperf:perf-record[1]
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 1e7d81a..8fb7bcc 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -198,6 +198,7 @@ struct perf_sched {
/* options for timehist command */
boolsummary;
boolsummary_only;
+   boolshow_wakeups;
u64 skipped_samples;
 };
 
@@ -1807,7 +1808,8 @@ static void timehist_header(void)
printf("\n");
 }
 
-static void timehist_print_sample(struct perf_sample *sample,
+static void timehist_print_sample(struct perf_sched *sched,
+ struct perf_sample *sample,
  struct thread *thread)
 {
struct thread_runtime *tr = thread__priv(thread);
@@ -1821,6 +1823,10 @@ static void timehist_print_sample(struct perf_sample 
*sample,
print_sched_time(tr->dt_wait, 6);
print_sched_time(tr->dt_delay, 6);
print_sched_time(tr->dt_run, 6);
+
+   if (sched->show_wakeups)
+   printf("  %-*s", comm_width, "");
+
printf("\n");
 }
 
@@ -2028,12 +2034,44 @@ static bool timehist_skip_sample(struct perf_sched 
*sched,
return rc;
 }
 
-static int timehist_sched_wakeup_event(struct perf_tool *tool __maybe_unused,
+static void timehist_print_wakeup_event(struct perf_sched *sched,
+   struct perf_sample *sample,
+   struct machine *machine,
+   struct thread *awakened)
+{
+   struct thread *thread;
+   char tstr[64];
+
+   thread = machine__findnew_thread(machine, sample->pid, sample->tid);
+   if (thread == NULL)
+   return;
+
+   /* show wakeup unless both awakee and awaker are filtered */
+   if (timehist_skip_sample(sched, thread) &&
+   timehist_skip_sample(sched, awakened)) {
+   return;
+   }
+
+   timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr));
+   printf("%15s [%04d] ", tstr, sample->cpu);
+
+   printf(" %-*s ", comm_width, timehist_get_commstr(thread));
+
+   /* dt spacer */
+   printf("  %9s  %9s  %9s ", "", "", "");
+
+   printf("awakened: %s", timehist_get_commstr(awakened));
+
+   printf("\n");
+}
+
+static int timehist_sched_wakeup_event(struct perf_tool *tool,
   union perf_event *event __maybe_unused,
   struct perf_evsel *evsel,
   struct perf_sample *sample,
   struct machine *machine)
 {
+   struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
struct thread *thread;
struct thread_runtime *tr = NULL;
/* want pid of awakened task not pid in sample */
@@ -2050,6 +2088,10 @@ static int timehist_sched_wakeup_event(struct perf_tool 
*tool __maybe_unused,
  

[tip:perf/core] perf sched timehist: Introduce timehist command

2016-11-23 Thread tip-bot for David Ahern
Commit-ID:  49394a2a24c78ce034fe0e732b1b54922c23fd92
Gitweb: http://git.kernel.org/tip/49394a2a24c78ce034fe0e732b1b54922c23fd92
Author: David Ahern 
AuthorDate: Wed, 16 Nov 2016 15:06:29 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 23 Nov 2016 10:44:07 -0300

perf sched timehist: Introduce timehist command

'perf sched timehist' provides an analysis of scheduling events.

Example usage:
perf sched record -- sleep 1
perf sched timehist

By default it shows the individual schedule events, including the wait
time (time between sched-out and next sched-in events for the task), the
task scheduling delay (time between wakeup and actually running) and run
time for the task:

timecpu  task name wait time  sch delay   run time
 [tid/pid](msec) (msec) (msec)
  -- --    -  -  -
79371.874569 [0011]  gcc[31949]0.014  0.000  1.148
79371.874591 [0010]  gcc[31951]0.000  0.000  0.024
79371.874603 [0010]  migration/10[59]  3.350  0.004  0.011
79371.874604 [0011]  1.148  0.000  0.035
79371.874723 [0005]  0.016  0.000  1.383
79371.874746 [0005]  gcc[31949]0.153  0.078  0.022
...

Times are in msec.usec.

Committer note:

Add above explanation as the 'perf sched timehist' entry for 'man
perf-sched'.

Signed-off-by: David Ahern 
Signed-off-by: Namhyung Kim 
Acked-by: Ingo Molnar 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Andi Kleen 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/20161116060634.28477-4-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-sched.txt |  50 ++-
 tools/perf/builtin-sched.c  | 594 +++-
 2 files changed, 637 insertions(+), 7 deletions(-)

diff --git a/tools/perf/Documentation/perf-sched.txt 
b/tools/perf/Documentation/perf-sched.txt
index 1cc08cc..72730da 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -8,11 +8,11 @@ perf-sched - Tool to trace/measure scheduler properties 
(latencies)
 SYNOPSIS
 
 [verse]
-'perf sched' {record|latency|map|replay|script}
+'perf sched' {record|latency|map|replay|script|timehist}
 
 DESCRIPTION
 ---
-There are five variants of perf sched:
+There are several variants of 'perf sched':
 
   'perf sched record ' to record the scheduling events
   of an arbitrary workload.
@@ -36,6 +36,30 @@ There are five variants of perf sched:
   are running on a CPU. A '*' denotes the CPU that had the event, and
   a dot signals an idle CPU.
 
+  'perf sched timehist' provides an analysis of scheduling events.
+
+Example usage:
+perf sched record -- sleep 1
+perf sched timehist
+
+   By default it shows the individual schedule events, including the wait
+   time (time between sched-out and next sched-in events for the task), the
+   task scheduling delay (time between wakeup and actually running) and run
+   time for the task:
+
+timecpu  task name wait time  sch delay   run 
time
+ [tid/pid](msec) (msec) 
(msec)
+  -- --    -  -  
-
+79371.874569 [0011]  gcc[31949]0.014  0.000  
1.148
+79371.874591 [0010]  gcc[31951]0.000  0.000  
0.024
+79371.874603 [0010]  migration/10[59]  3.350  0.004  
0.011
+79371.874604 [0011]  1.148  0.000  
0.035
+79371.874723 [0005]  0.016  0.000  
1.383
+79371.874746 [0005]  gcc[31949]0.153  0.078  
0.022
+...
+
+   Times are in msec.usec.
+
 OPTIONS
 ---
 -i::
@@ -66,6 +90,28 @@ OPTIONS for 'perf sched map'
 --color-pids::
Highlight the given pids.
 
+OPTIONS for 'perf sched timehist'
+-
+-k::
+--vmlinux=::
+vmlinux pathname
+
+--kallsyms=::
+kallsyms pathname
+
+-s::
+--summary::
+Show only a summary of scheduling by thread with min, max, and average
+run times (in sec) and relative stddev.
+
+-S::
+--with-summary::
+Show all scheduling events followed by a summary by thread with min,
+max, and average run times (in sec) and relative stddev.
+
+--symfs=::
+Look for files with symbols relative to this directory.
+
 SEE ALSO
 
 linkperf:perf-record[1]
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index fb34412..c0ac0c9 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -13,12 +13,14 @@
 #include "util/cloexec.h"
 #include "util/thread_map

[tip:perf/urgent] perf/core: Change log level for duration warning to KERN_INFO

2016-08-02 Thread tip-bot for David Ahern
Commit-ID:  0d87d7ec22a0879d3926faa4f4f4412a5dee1fba
Gitweb: http://git.kernel.org/tip/0d87d7ec22a0879d3926faa4f4f4412a5dee1fba
Author: David Ahern 
AuthorDate: Mon, 1 Aug 2016 13:49:29 -0700
Committer:  Ingo Molnar 
CommitDate: Tue, 2 Aug 2016 10:23:57 +0200

perf/core: Change log level for duration warning to KERN_INFO

When the perf interrupt handler exceeds a threshold warning messages
are displayed on console:

  [12739.31793] perf interrupt took too long (2504 > 2500), lowering 
kernel.perf_event_max_sample_rate to 5
  [71340.165065] perf interrupt took too long (5005 > 5000), lowering 
kernel.perf_event_max_sample_rate to 25000

Many customers and users are confused by the message wondering if
something is wrong or they need to take action to fix a problem.
Since a user can not do anything to fix the issue, the message is really
more informational than a warning. Adjust the log level accordingly.

Signed-off-by: David Ahern 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1470084569-438-1-git-send-email-...@cumulusnetworks.com
Signed-off-by: Ingo Molnar 
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 356a6c7..a19550d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -448,7 +448,7 @@ static u64 __report_allowed;
 
 static void perf_duration_warn(struct irq_work *w)
 {
-   printk_ratelimited(KERN_WARNING
+   printk_ratelimited(KERN_INFO
"perf: interrupt took too long (%lld > %lld), lowering "
"kernel.perf_event_max_sample_rate to %d\n",
__report_avg, __report_allowed,


[tip:perf/core] perf tools: Update MANIFEST per files removed from kernel

2015-06-12 Thread tip-bot for David Ahern
Commit-ID:  c8ad7063626406181a7ebab10cb31b4f741b13d4
Gitweb: http://git.kernel.org/tip/c8ad7063626406181a7ebab10cb31b4f741b13d4
Author: David Ahern 
AuthorDate: Fri, 5 Jun 2015 13:42:53 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 11 Jun 2015 22:54:23 -0300

perf tools: Update MANIFEST per files removed from kernel

Building perf out of kernel tree is currently broken because the
MANIFEST file refers to kernel files that have been removed. With this
patch make perf-targz-src-pkg succeeds as does building perf using the
generated tarfile.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1433526173-172332-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/MANIFEST | 4 
 1 file changed, 4 deletions(-)

diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index a0bdd61..fe50a1b 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -50,24 +50,20 @@ include/asm-generic/bitops/const_hweight.h
 include/asm-generic/bitops/fls64.h
 include/asm-generic/bitops/__fls.h
 include/asm-generic/bitops/fls.h
-include/linux/const.h
 include/linux/perf_event.h
 include/linux/rbtree.h
 include/linux/list.h
 include/linux/hash.h
 include/linux/stringify.h
-lib/find_next_bit.c
 lib/hweight.c
 lib/rbtree.c
 include/linux/swab.h
 arch/*/include/asm/unistd*.h
-arch/*/include/asm/perf_regs.h
 arch/*/include/uapi/asm/unistd*.h
 arch/*/include/uapi/asm/perf_regs.h
 arch/*/lib/memcpy*.S
 arch/*/lib/memset*.S
 include/linux/poison.h
-include/linux/magic.h
 include/linux/hw_breakpoint.h
 include/linux/rbtree_augmented.h
 include/uapi/linux/perf_event.h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf kmem: Fix compiles on RHEL6/OL6

2015-05-05 Thread tip-bot for David Ahern
Commit-ID:  6b1a27520f990700d0dd23976afd8992bf659698
Gitweb: http://git.kernel.org/tip/6b1a27520f990700d0dd23976afd8992bf659698
Author: David Ahern 
AuthorDate: Tue, 14 Apr 2015 13:49:33 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 29 Apr 2015 10:37:44 -0300

perf kmem: Fix compiles on RHEL6/OL6

0d68bc92c48 breaks compiles on RHEL6/OL6:
cc1: warnings being treated as errors
builtin-kmem.c: In function ‘search_page_alloc_stat’:
builtin-kmem.c:322: error: declaration of ‘stat’ shadows a global 
declaration
node = &parent->rb_left;
/usr/include/sys/stat.h:455: error: shadowed declaration is here
builtin-kmem.c: In function ‘perf_evsel__process_page_alloc_event’:
builtin-kmem.c:378: error: declaration of ‘stat’ shadows a global 
declaration
/usr/include/sys/stat.h:455: error: shadowed declaration is here
builtin-kmem.c: In function ‘perf_evsel__process_page_free_event’:
builtin-kmem.c:431: error: declaration of ‘stat’ shadows a global 
declaration
/usr/include/sys/stat.h:455: error: shadowed declaration is here

Rename local variable to pstat to avoid the name conflict.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1429033773-31383-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kmem.c | 54 +++
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 63ea013..4f0f384 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -319,7 +319,7 @@ static int page_stat_cmp(struct page_stat *a, struct 
page_stat *b)
return 0;
 }
 
-static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool 
create)
+static struct page_stat *search_page_alloc_stat(struct page_stat *pstat, bool 
create)
 {
struct rb_node **node = &page_alloc_tree.rb_node;
struct rb_node *parent = NULL;
@@ -331,7 +331,7 @@ static struct page_stat *search_page_alloc_stat(struct 
page_stat *stat, bool cre
parent = *node;
data = rb_entry(*node, struct page_stat, node);
 
-   cmp = page_stat_cmp(data, stat);
+   cmp = page_stat_cmp(data, pstat);
if (cmp < 0)
node = &parent->rb_left;
else if (cmp > 0)
@@ -345,10 +345,10 @@ static struct page_stat *search_page_alloc_stat(struct 
page_stat *stat, bool cre
 
data = zalloc(sizeof(*data));
if (data != NULL) {
-   data->page = stat->page;
-   data->order = stat->order;
-   data->gfp_flags = stat->gfp_flags;
-   data->migrate_type = stat->migrate_type;
+   data->page = pstat->page;
+   data->order = pstat->order;
+   data->gfp_flags = pstat->gfp_flags;
+   data->migrate_type = pstat->migrate_type;
 
rb_link_node(&data->node, parent, node);
rb_insert_color(&data->node, &page_alloc_tree);
@@ -375,7 +375,7 @@ static int perf_evsel__process_page_alloc_event(struct 
perf_evsel *evsel,
unsigned int migrate_type = perf_evsel__intval(evsel, sample,
   "migratetype");
u64 bytes = kmem_page_size << order;
-   struct page_stat *stat;
+   struct page_stat *pstat;
struct page_stat this = {
.order = order,
.gfp_flags = gfp_flags,
@@ -401,21 +401,21 @@ static int perf_evsel__process_page_alloc_event(struct 
perf_evsel *evsel,
 * This is to find the current page (with correct gfp flags and
 * migrate type) at free event.
 */
-   stat = search_page(page, true);
-   if (stat == NULL)
+   pstat = search_page(page, true);
+   if (pstat == NULL)
return -ENOMEM;
 
-   stat->order = order;
-   stat->gfp_flags = gfp_flags;
-   stat->migrate_type = migrate_type;
+   pstat->order = order;
+   pstat->gfp_flags = gfp_flags;
+   pstat->migrate_type = migrate_type;
 
this.page = page;
-   stat = search_page_alloc_stat(&this, true);
-   if (stat == NULL)
+   pstat = search_page_alloc_stat(&this, true);
+   if (pstat == NULL)
return -ENOMEM;
 
-   stat->nr_alloc++;
-   stat->alloc_bytes += bytes;
+   pstat->nr_alloc++;
+   pstat->alloc_bytes += bytes;
 
order_stats[order][migrate_type]++;
 
@@ -428,7 +428,7 @@ static int perf_evsel__process_page_free_event(struct 
perf_evsel *evsel,
u64 page;
unsigned int order = perf_evsel__intval(evsel, sample, "order");
u64 bytes = kmem_page_size << order;
-   struct page_stat *stat;
+   struct page_stat *pstat;
struct page_stat this = {
.order = order,
};
@@ -441,8 +441,8 @@ static int perf_evsel__process_page_fre

[tip:perf/urgent] perf kmem: Fix compiles on RHEL6/OL6

2015-05-01 Thread tip-bot for David Ahern
Commit-ID:  4ad1f4300e3bddf63109aa63cfb2d37e8585ecc7
Gitweb: http://git.kernel.org/tip/4ad1f4300e3bddf63109aa63cfb2d37e8585ecc7
Author: David Ahern 
AuthorDate: Tue, 14 Apr 2015 13:49:33 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 24 Apr 2015 12:44:47 -0300

perf kmem: Fix compiles on RHEL6/OL6

0d68bc92c48 breaks compiles on RHEL6/OL6:
cc1: warnings being treated as errors
builtin-kmem.c: In function ‘search_page_alloc_stat’:
builtin-kmem.c:322: error: declaration of ‘stat’ shadows a global 
declaration
node = &parent->rb_left;
/usr/include/sys/stat.h:455: error: shadowed declaration is here
builtin-kmem.c: In function ‘perf_evsel__process_page_alloc_event’:
builtin-kmem.c:378: error: declaration of ‘stat’ shadows a global 
declaration
/usr/include/sys/stat.h:455: error: shadowed declaration is here
builtin-kmem.c: In function ‘perf_evsel__process_page_free_event’:
builtin-kmem.c:431: error: declaration of ‘stat’ shadows a global 
declaration
/usr/include/sys/stat.h:455: error: shadowed declaration is here

Rename local variable to pstat to avoid the name conflict.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1429033773-31383-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kmem.c | 54 +++
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index a1915b4..1634186 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -319,7 +319,7 @@ static int page_stat_cmp(struct page_stat *a, struct 
page_stat *b)
return 0;
 }
 
-static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool 
create)
+static struct page_stat *search_page_alloc_stat(struct page_stat *pstat, bool 
create)
 {
struct rb_node **node = &page_alloc_tree.rb_node;
struct rb_node *parent = NULL;
@@ -331,7 +331,7 @@ static struct page_stat *search_page_alloc_stat(struct 
page_stat *stat, bool cre
parent = *node;
data = rb_entry(*node, struct page_stat, node);
 
-   cmp = page_stat_cmp(data, stat);
+   cmp = page_stat_cmp(data, pstat);
if (cmp < 0)
node = &parent->rb_left;
else if (cmp > 0)
@@ -345,10 +345,10 @@ static struct page_stat *search_page_alloc_stat(struct 
page_stat *stat, bool cre
 
data = zalloc(sizeof(*data));
if (data != NULL) {
-   data->page = stat->page;
-   data->order = stat->order;
-   data->gfp_flags = stat->gfp_flags;
-   data->migrate_type = stat->migrate_type;
+   data->page = pstat->page;
+   data->order = pstat->order;
+   data->gfp_flags = pstat->gfp_flags;
+   data->migrate_type = pstat->migrate_type;
 
rb_link_node(&data->node, parent, node);
rb_insert_color(&data->node, &page_alloc_tree);
@@ -375,7 +375,7 @@ static int perf_evsel__process_page_alloc_event(struct 
perf_evsel *evsel,
unsigned int migrate_type = perf_evsel__intval(evsel, sample,
   "migratetype");
u64 bytes = kmem_page_size << order;
-   struct page_stat *stat;
+   struct page_stat *pstat;
struct page_stat this = {
.order = order,
.gfp_flags = gfp_flags,
@@ -401,21 +401,21 @@ static int perf_evsel__process_page_alloc_event(struct 
perf_evsel *evsel,
 * This is to find the current page (with correct gfp flags and
 * migrate type) at free event.
 */
-   stat = search_page(page, true);
-   if (stat == NULL)
+   pstat = search_page(page, true);
+   if (pstat == NULL)
return -ENOMEM;
 
-   stat->order = order;
-   stat->gfp_flags = gfp_flags;
-   stat->migrate_type = migrate_type;
+   pstat->order = order;
+   pstat->gfp_flags = gfp_flags;
+   pstat->migrate_type = migrate_type;
 
this.page = page;
-   stat = search_page_alloc_stat(&this, true);
-   if (stat == NULL)
+   pstat = search_page_alloc_stat(&this, true);
+   if (pstat == NULL)
return -ENOMEM;
 
-   stat->nr_alloc++;
-   stat->alloc_bytes += bytes;
+   pstat->nr_alloc++;
+   pstat->alloc_bytes += bytes;
 
order_stats[order][migrate_type]++;
 
@@ -428,7 +428,7 @@ static int perf_evsel__process_page_free_event(struct 
perf_evsel *evsel,
u64 page;
unsigned int order = perf_evsel__intval(evsel, sample, "order");
u64 bytes = kmem_page_size << order;
-   struct page_stat *stat;
+   struct page_stat *pstat;
struct page_stat this = {
.order = order,
};
@@ -441,8 +441,8 @@ static int perf_evsel__process_page_fre

[tip:perf/core] perf evlist: Fix type for references to data_head /tail

2015-04-10 Thread tip-bot for David Ahern
Commit-ID:  7b8283b56d9fb36106ff1c459dfd399a20bd374d
Gitweb: http://git.kernel.org/tip/7b8283b56d9fb36106ff1c459dfd399a20bd374d
Author: David Ahern 
AuthorDate: Tue, 7 Apr 2015 09:20:37 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 10 Apr 2015 11:29:20 -0300

perf evlist: Fix type for references to data_head/tail

The data_head and data_tail fields are defined as __u64 in
linux/perf_event.h, but perf userspace uses int and unsigned int.

Convert all references to u64 for consistency.

Signed-off-by: David Ahern 
Acked-by: Peter Zijlstra 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1428420037-26599-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-record.c | 4 ++--
 tools/perf/util/evlist.c| 6 +++---
 tools/perf/util/evlist.h| 9 -
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index ac61048..c3efdfb 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -70,8 +70,8 @@ static int process_synthesized_event(struct perf_tool *tool,
 static int record__mmap_read(struct record *rec, int idx)
 {
struct perf_mmap *md = &rec->evlist->mmap[idx];
-   unsigned int head = perf_mmap__read_head(md);
-   unsigned int old = md->prev;
+   u64 head = perf_mmap__read_head(md);
+   u64 old = md->prev;
unsigned char *data = md->base + page_size;
unsigned long size;
void *buf;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 76ef7ee..080be93 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -634,8 +634,8 @@ static struct perf_evsel *perf_evlist__event2evsel(struct 
perf_evlist *evlist,
 union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
 {
struct perf_mmap *md = &evlist->mmap[idx];
-   unsigned int head = perf_mmap__read_head(md);
-   unsigned int old = md->prev;
+   u64 head = perf_mmap__read_head(md);
+   u64 old = md->prev;
unsigned char *data = md->base + page_size;
union perf_event *event = NULL;
 
@@ -716,7 +716,7 @@ void perf_evlist__mmap_consume(struct perf_evlist *evlist, 
int idx)
struct perf_mmap *md = &evlist->mmap[idx];
 
if (!evlist->overwrite) {
-   unsigned int old = md->prev;
+   u64 old = md->prev;
 
perf_mmap__write_tail(md, old);
}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index fb19c47..b5cce95 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -27,7 +27,7 @@ struct perf_mmap {
void *base;
int  mask;
int  refcnt;
-   unsigned int prev;
+   u64  prev;
char event_copy[PERF_SAMPLE_MAX_SIZE] 
__attribute__((aligned(8)));
 };
 
@@ -189,16 +189,15 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, 
FILE *fp);
 int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, 
size_t size);
 int perf_evlist__strerror_mmap(struct perf_evlist *evlist, int err, char *buf, 
size_t size);
 
-static inline unsigned int perf_mmap__read_head(struct perf_mmap *mm)
+static inline u64 perf_mmap__read_head(struct perf_mmap *mm)
 {
struct perf_event_mmap_page *pc = mm->base;
-   int head = ACCESS_ONCE(pc->data_head);
+   u64 head = ACCESS_ONCE(pc->data_head);
rmb();
return head;
 }
 
-static inline void perf_mmap__write_tail(struct perf_mmap *md,
-unsigned long tail)
+static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail)
 {
struct perf_event_mmap_page *pc = md->base;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Fix cross-endian analysis

2015-04-10 Thread tip-bot for David Ahern
Commit-ID:  1060ab857f64f33a9445881fd31fa91470aeb622
Gitweb: http://git.kernel.org/tip/1060ab857f64f33a9445881fd31fa91470aeb622
Author: David Ahern 
AuthorDate: Thu, 9 Apr 2015 16:15:46 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 10 Apr 2015 10:13:58 -0300

perf tools: Fix cross-endian analysis

Trying to analyze a big endian data file on little endian system fails
with the error:

  0xa9b40 [0x70]: failed to process type: 9

The problem is that header parsing is not done correctly because the
file attributes are not swapped. Make it so. With this patch able to
analyze a sparc64 data file on x86_64.

Signed-off-by: David Ahern 
Acked-by: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1428610546-178789-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/header.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index fff3b2a..918fd8a 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2504,8 +2504,11 @@ int perf_session__read_header(struct perf_session 
*session)
if (read_attr(fd, header, &f_attr) < 0)
goto out_errno;
 
-   if (header->needs_swap)
+   if (header->needs_swap) {
+   f_attr.ids.size   = bswap_64(f_attr.ids.size);
+   f_attr.ids.offset = bswap_64(f_attr.ids.offset);
perf_event__attr_swap(&f_attr.attr);
+   }
 
tmp = lseek(fd, 0, SEEK_CUR);
evsel = perf_evsel__new(&f_attr.attr);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Fix synthesizing fork_event.ppid for non-main thread

2015-04-10 Thread tip-bot for David Ahern
Commit-ID:  7764a385f60bd200304a33124bdb4e684caeabdf
Gitweb: http://git.kernel.org/tip/7764a385f60bd200304a33124bdb4e684caeabdf
Author: David Ahern 
AuthorDate: Thu, 9 Apr 2015 12:48:27 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 10 Apr 2015 10:10:55 -0300

perf tools: Fix synthesizing fork_event.ppid for non-main thread

Commit ca6c41c59b9 sets the ppid based on what is read from the
/proc/pid/status file when synthesizing fork events.

This is correct thing to do for new processes but not threads of a
process.

Fix ppid for threads to be the main thread when synthesizing fork events
(ie., assume main thread spawned all sub-threads in a process).

Reported-by: Arnaldo Carvalho de Melo 
Signed-off-by: David Ahern 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Don Zickus 
Link: 
http://lkml.kernel.org/r/1428598107-178999-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/event.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 5516236..9d09851 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool 
*tool,
 {
memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size);
 
-   event->fork.ppid = ppid;
-   event->fork.ptid = ppid;
+   /*
+* for main thread set parent to ppid from status file. For other
+* threads set parent pid to main thread. ie., assume main thread
+* spawns all threads in a process
+   */
+   if (tgid == pid) {
+   event->fork.ppid = ppid;
+   event->fork.ptid = ppid;
+   } else {
+   event->fork.ppid = tgid;
+   event->fork.ptid = tgid;
+   }
event->fork.pid  = tgid;
event->fork.tid  = pid;
event->fork.header.type = PERF_RECORD_FORK;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Fix ppid for synthesized fork events

2015-04-02 Thread tip-bot for David Ahern
Commit-ID:  ca6c41c59b964d362823e80442e9e32c31106b29
Gitweb: http://git.kernel.org/tip/ca6c41c59b964d362823e80442e9e32c31106b29
Author: David Ahern 
AuthorDate: Mon, 30 Mar 2015 14:35:58 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 31 Mar 2015 17:52:30 -0300

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//status the ppid can
be determined properly. Make it so.

Signed-off-by: David Ahern 
Acked-by: Don Zickus 
Acked-by: Jiri Olsa 
Cc: Joe Mario 
Link: 
http://lkml.kernel.org/r/1427747758-18510-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/event.c | 83 +
 1 file changed, 50 insertions(+), 33 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 023dd35..5516236 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -51,29 +51,32 @@ static struct perf_sample synth_sample = {
 
 /*
  * Assumes that the first 4095 bytes of /proc/pid/stat contains
- * the comm and tgid.
+ * the comm, tgid and ppid.
  */
-static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
+static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
+   pid_t *tgid, pid_t *ppid)
 {
char filename[PATH_MAX];
char bf[4096];
int fd;
size_t size = 0, n;
-   pid_t tgid = -1;
-   char *nl, *name, *tgids;
+   char *nl, *name, *tgids, *ppids;
+
+   *tgid = -1;
+   *ppid = -1;
 
snprintf(filename, sizeof(filename), "/proc/%d/status", pid);
 
fd = open(filename, O_RDONLY);
if (fd < 0) {
pr_debug("couldn't open %s\n", filename);
-   return 0;
+   return -1;
}
 
n = read(fd, bf, sizeof(bf) - 1);
close(fd);
if (n <= 0) {
-   pr_warning("Couldn't get COMM and tgid for pid %d\n",
+   pr_warning("Couldn't get COMM, tigd and ppid for pid %d\n",
   pid);
return -1;
}
@@ -81,6 +84,7 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, 
size_t len)
 
name = strstr(bf, "Name:");
tgids = strstr(bf, "Tgid:");
+   ppids = strstr(bf, "PPid:");
 
if (name) {
name += 5;  /* strlen("Name:") */
@@ -103,32 +107,45 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char 
*comm, size_t len)
 
if (tgids) {
tgids += 5;  /* strlen("Tgid:") */
-   tgid = atoi(tgids);
+   *tgid = atoi(tgids);
} else {
pr_debug("Tgid: string not found for pid %d\n", pid);
}
 
-   return tgid;
+   if (ppids) {
+   ppids += 5;  /* strlen("PPid:") */
+   *ppid = atoi(ppids);
+   } else {
+   pr_debug("PPid: string not found for pid %d\n", pid);
+   }
+
+   return 0;
 }
 
-static pid_t perf_event__prepare_comm(union perf_event *event, pid_t pid,
-struct machine *machine)
+static int perf_event__prepare_comm(union perf_event *event, pid_t pid,
+   struct machine *machine,
+   pid_t *tgid, pid_t *ppid)
 {
size_t size;
-   pid_t tgid;
+
+   *ppid = -1;
 
memset(&event->comm, 0, sizeof(event->comm));
 
-   if (machine__is_host(machine))
-   tgid = perf_event__get_comm_tgid(pid, event->comm.comm,
-sizeof(event->comm.comm));
-   else
-   tgid = machine->pid;
+   if (machine__is_host(machine)) {
+   if (perf_event__get_comm_ids(pid, event->comm.comm,
+sizeof(event->comm.comm),
+tgid, ppid) != 0) {
+   return -1;
+   }
+   } else {
+   *tgid = machine->pid;
+   }
 
-   if (tgid < 0)
-   goto out;
+   if (*tgid < 0)
+   return -1;
 
-   event->comm.pid = tgid;
+   event->comm.pid = *tgid;
event->comm.header.type = PERF_RECORD_COMM;
 
size = strlen(event->comm.comm) + 1;
@@ -138,8 +155,8 @@ static pid_t perf_event__prepare_comm(union perf_event 
*event, pid_t pid,
(sizeof(event->comm.comm) - size) +
machine->id_hdr_size);
event->comm.tid = pid;
-out:
-   return tgid;
+
+   return 0;
 }
 
 static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
@@ -147,27 +164,27 @@ static pid_t perf_event__synthesize_comm(struct perf_tool 
*tool,
 perf_event__handler_t process,
 struct machine *mach

[tip:perf/core] perf tools: Refactor comm/tgid lookup

2015-04-02 Thread tip-bot for David Ahern
Commit-ID:  5aa0b030e8d29d6719c144818814b519cfcb105c
Gitweb: http://git.kernel.org/tip/5aa0b030e8d29d6719c144818814b519cfcb105c
Author: David Ahern 
AuthorDate: Mon, 30 Mar 2015 14:35:57 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 31 Mar 2015 17:52:30 -0300

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 
Acked-by: Don Zickus 
Acked-by: Jiri Olsa 
Cc: Joe Mario 
Link: 
http://lkml.kernel.org/r/1427747758-18510-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/event.c | 72 ++---
 1 file changed, 44 insertions(+), 28 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index d5efa50..023dd35 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -49,48 +49,64 @@ static struct perf_sample synth_sample = {
.period= 1,
 };
 
+/*
+ * Assumes that the first 4095 bytes of /proc/pid/stat contains
+ * the comm and tgid.
+ */
 static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
 {
char filename[PATH_MAX];
-   char bf[BUFSIZ];
-   FILE *fp;
-   size_t size = 0;
+   char bf[4096];
+   int fd;
+   size_t size = 0, n;
pid_t tgid = -1;
+   char *nl, *name, *tgids;
 
snprintf(filename, sizeof(filename), "/proc/%d/status", pid);
 
-   fp = fopen(filename, "r");
-   if (fp == NULL) {
+   fd = open(filename, O_RDONLY);
+   if (fd < 0) {
pr_debug("couldn't open %s\n", filename);
return 0;
}
 
-   while (!comm[0] || (tgid < 0)) {
-   if (fgets(bf, sizeof(bf), fp) == NULL) {
-   pr_warning("couldn't get COMM and pgid, malformed %s\n",
-  filename);
-   break;
-   }
+   n = read(fd, bf, sizeof(bf) - 1);
+   close(fd);
+   if (n <= 0) {
+   pr_warning("Couldn't get COMM and tgid for pid %d\n",
+  pid);
+   return -1;
+   }
+   bf[n] = '\0';
 
-   if (memcmp(bf, "Name:", 5) == 0) {
-   char *name = bf + 5;
-   while (*name && isspace(*name))
-   ++name;
-   size = strlen(name) - 1;
-   if (size >= len)
-   size = len - 1;
-   memcpy(comm, name, size);
-   comm[size] = '\0';
-
-   } else if (memcmp(bf, "Tgid:", 5) == 0) {
-   char *tgids = bf + 5;
-   while (*tgids && isspace(*tgids))
-   ++tgids;
-   tgid = atoi(tgids);
-   }
+   name = strstr(bf, "Name:");
+   tgids = strstr(bf, "Tgid:");
+
+   if (name) {
+   name += 5;  /* strlen("Name:") */
+
+   while (*name && isspace(*name))
+   ++name;
+
+   nl = strchr(name, '\n');
+   if (nl)
+   *nl = '\0';
+
+   size = strlen(name);
+   if (size >= len)
+   size = len - 1;
+   memcpy(comm, name, size);
+   comm[size] = '\0';
+   } else {
+   pr_debug("Name: string not found for pid %d\n", pid);
}
 
-   fclose(fp);
+   if (tgids) {
+   tgids += 5;  /* strlen("Tgid:") */
+   tgid = atoi(tgids);
+   } else {
+   pr_debug("Tgid: string not found for pid %d\n", pid);
+   }
 
return tgid;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf/x86: Remove redundant calls to perf_pmu_{dis|en}able()

2015-03-27 Thread tip-bot for David Ahern
Commit-ID:  9332d250b4b4f67c633894b311e022e3cf943bd5
Gitweb: http://git.kernel.org/tip/9332d250b4b4f67c633894b311e022e3cf943bd5
Author: David Ahern 
AuthorDate: Wed, 18 Feb 2015 10:45:43 -0700
Committer:  Ingo Molnar 
CommitDate: Fri, 27 Mar 2015 09:49:44 +0100

perf/x86: Remove redundant calls to perf_pmu_{dis|en}able()

perf_pmu_disable() is called before pmu->add() and perf_pmu_enable() is called
afterwards. No need to call these inside of x86_pmu_add() as well.

Signed-off-by: David Ahern 
Signed-off-by: Peter Zijlstra (Intel) 
Link: 
http://lkml.kernel.org/r/1424281543-67335-1-git-send-email-dsah...@gmail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/perf_event.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index ec6e982..ac41b3a 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1044,7 +1044,6 @@ static int x86_pmu_add(struct perf_event *event, int 
flags)
 
hwc = &event->hw;
 
-   perf_pmu_disable(event->pmu);
n0 = cpuc->n_events;
ret = n = collect_events(cpuc, event, false);
if (ret < 0)
@@ -1082,7 +1081,6 @@ done_collect:
 
ret = 0;
 out:
-   perf_pmu_enable(event->pmu);
return ret;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Set JOBS based on CPU or processor

2015-03-27 Thread tip-bot for David Ahern
Commit-ID:  6428c59a97de7c3d88fc4e66317daea5e5008758
Gitweb: http://git.kernel.org/tip/6428c59a97de7c3d88fc4e66317daea5e5008758
Author: David Ahern 
AuthorDate: Tue, 24 Mar 2015 12:10:55 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 26 Mar 2015 10:52:28 -0300

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 
Acked-by: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1427213455-127249-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index d5020ae..c699dc3 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -24,7 +24,7 @@ unexport MAKEFLAGS
 # (To override it, run 'make JOBS=1' and similar.)
 #
 ifeq ($(JOBS),)
-  JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
+  JOBS := $(shell egrep -c '^processor|^CPU' /proc/cpuinfo 2>/dev/null)
   ifeq ($(JOBS),0)
 JOBS := 1
   endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf: Bump max number of cpus to 1024

2015-03-27 Thread tip-bot for David Ahern
Commit-ID:  4d255766d28b1fecec7e00ab4166b2c17bfc37be
Gitweb: http://git.kernel.org/tip/4d255766d28b1fecec7e00ab4166b2c17bfc37be
Author: David Ahern 
AuthorDate: Tue, 24 Mar 2015 12:10:38 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 26 Mar 2015 10:52:28 -0300

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 
Link: 
http://lkml.kernel.org/r/1427213438-127216-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/perf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 1caa70a..c38a085 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -29,7 +29,7 @@ static inline unsigned long long rdclock(void)
return ts.tv_sec * 10ULL + ts.tv_nsec;
 }
 
-#define MAX_NR_CPUS256
+#define MAX_NR_CPUS1024
 
 extern const char *input_name;
 extern bool perf_host, perf_guest;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf timechart: Fix SIBGUS error on sparc64

2015-03-27 Thread tip-bot for David Ahern
Commit-ID:  e94eedab3ab8201fd41480171b2fabbf3c5b1ae0
Gitweb: http://git.kernel.org/tip/e94eedab3ab8201fd41480171b2fabbf3c5b1ae0
Author: David Ahern 
AuthorDate: Tue, 24 Mar 2015 16:14:09 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 26 Mar 2015 10:52:28 -0300

perf timechart: Fix SIBGUS error on sparc64

perf timechart -T on sparc64 is terminating due to SIGBUS. Backtrace:

Program received signal SIGBUS, Bus error.
0x00173d7c in perf_evsel__intval (evsel=, 
sample=0x7feda28, name=0x289b28 "prev_state")
at util/evsel.c:1918
1918util/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  0x00173d7c in perf_evsel__intval (evsel=, 
sample=0x7feda28,
name=0x289b28 "prev_state") at util/evsel.c:1918
1  0x00123b94 in process_sample_sched_switch (tchart=0x7fee040, 
evsel=0x4ca850, sample=0x7feda28,
backtrace=0xc39010 "") at builtin-timechart.c:627
2  0x00122828 in process_sample_event (tool=0x7fee040, event=, sample=0x7feda28,
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 
Link: 
http://lkml.kernel.org/r/1427228049-51893-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bb4eff2..358e595 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1915,7 +1915,7 @@ u64 perf_evsel__intval(struct perf_evsel *evsel, struct 
perf_sample *sample,
value = *(u32 *)ptr;
break;
case 8:
-   value = *(u64 *)ptr;
+   memcpy(&value, ptr, sizeof(u64));
break;
default:
return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Add pid/ tid filtering to report and script commands

2015-03-24 Thread tip-bot for David Ahern
Commit-ID:  e03eaa400cf8b8bded86cc5c41018a1c69152f16
Gitweb: http://git.kernel.org/tip/e03eaa400cf8b8bded86cc5c41018a1c69152f16
Author: David Ahern 
AuthorDate: Tue, 24 Mar 2015 09:52:41 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 24 Mar 2015 13:02:46 -0300

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 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1427212361-7066-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-report.txt |  5 +
 tools/perf/Documentation/perf-script.txt |  6 ++
 tools/perf/builtin-report.c  |  4 
 tools/perf/builtin-script.c  |  4 
 tools/perf/util/symbol.c | 31 ++-
 tools/perf/util/symbol.h |  7 +++
 tools/perf/util/thread.h | 11 +++
 7 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index dd7cccd..4879cf6 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -40,6 +40,11 @@ OPTIONS
Only consider symbols in these comms. CSV that understands
file://filename entries.  This option will affect the percentage of
the overhead column.  See --percentage for more info.
+--pid=::
+Only show events for given process ID (comma separated list).
+
+--tid=::
+Only show events for given thread ID (comma separated list).
 -d::
 --dsos=::
Only consider symbols in these dsos. CSV that understands
diff --git a/tools/perf/Documentation/perf-script.txt 
b/tools/perf/Documentation/perf-script.txt
index a21eec0..7944575 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -193,6 +193,12 @@ OPTIONS
Only display events for these comms. CSV that understands
file://filename entries.
 
+--pid=::
+   Only show events for given process ID (comma separated list).
+
+--tid=::
+   Only show events for given thread ID (comma separated list).
+
 -I::
 --show-info::
Display extended information about the perf.data file. This adds
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 81c2f3b..b5b2ad4 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -669,6 +669,10 @@ int cmd_report(int argc, const char **argv, const char 
*prefix __maybe_unused)
   "only consider symbols in these dsos"),
OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
   "only consider symbols in these comms"),
+   OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]",
+  "only consider symbols in these pids"),
+   OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]",
+  "only consider symbols in these tids"),
OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, 
"symbol[,symbol...]",
   "only consider these symbols"),
OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter",
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index f2a348b..662366c 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1562,6 +1562,10 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
   "only display events for these comms"),
+   OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]",
+  "only consider symbols in these pids"),
+   OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]",
+  "only consider symbols in these tids"),
OPT_BOOLEAN('I', "show-info", &show_full_info,
"display extended information from perf.data file"),
OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path,
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a690668..fddeb90 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -15,6 +15,7 @@
 #include "machine.h"
 #include "symbol.h"
 #include "strlist.h"
+#include "intlist.h"
 #include "header.h"
 
 #include 
@@ -1859,6 +1860,20 @@ int setup_list(struct strlist **list, const char 
*list_str,
return 0;
 }
 
+int setup_intlist(struct intlist **list, c

[tip:perf/core] perf diff: Add kallsyms option

2015-03-24 Thread tip-bot for David Ahern
Commit-ID:  6b1f342354d45c651cabd2ae0f61f55846f33e10
Gitweb: http://git.kernel.org/tip/6b1f342354d45c651cabd2ae0f61f55846f33e10
Author: David Ahern 
AuthorDate: Tue, 24 Mar 2015 09:51:57 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 24 Mar 2015 13:01:54 -0300

perf diff: Add kallsyms option

Required for off-box analysis to convert kernel addresses.

Signed-off-by: David Ahern 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1427212317-7018-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-diff.txt | 3 +++
 tools/perf/builtin-diff.c  | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/tools/perf/Documentation/perf-diff.txt 
b/tools/perf/Documentation/perf-diff.txt
index 5182661..d1deb57 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -31,6 +31,9 @@ OPTIONS
 --dump-raw-trace::
 Dump raw trace in ASCII.
 
+--kallsyms=::
+kallsyms pathname
+
 -m::
 --modules::
 Load module symbols. WARNING: use only with -k and LIVE kernel
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 473887d..df6307b 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -791,6 +791,8 @@ static const struct option options[] = {
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"),
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
+   OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
+  "file", "kallsyms pathname"),
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
"load module symbols - WARNING: use only with -k and LIVE 
kernel"),
OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] tools lib traceevent: Add destructor for format_field

2015-03-22 Thread tip-bot for David Ahern
Commit-ID:  00ae1127a03d20f5ef89f3c1fe7d4720270fc2a5
Gitweb: http://git.kernel.org/tip/00ae1127a03d20f5ef89f3c1fe7d4720270fc2a5
Author: David Ahern 
AuthorDate: Thu, 19 Mar 2015 12:36:21 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Sat, 21 Mar 2015 14:53:38 -0300

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 
Acked-by: Steven Rostedt 
Link: 
http://lkml.kernel.org/r/1426790181-19118-1-git-send-email-dsah...@gmail.com
[ Split this part from a larger patch, added pevent_ prefix as requested by 
Steven ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/traceevent/event-parse.c | 11 ---
 tools/lib/traceevent/event-parse.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c 
b/tools/lib/traceevent/event-parse.c
index afe20ed..d7c37a7 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -6228,15 +6228,20 @@ void pevent_ref(struct pevent *pevent)
pevent->ref_count++;
 }
 
+void pevent_free_format_field(struct format_field *field)
+{
+   free(field->type);
+   free(field->name);
+   free(field);
+}
+
 static void free_format_fields(struct format_field *field)
 {
struct format_field *next;
 
while (field) {
next = field->next;
-   free(field->type);
-   free(field->name);
-   free(field);
+   pevent_free_format_field(field);
field = next;
}
 }
diff --git a/tools/lib/traceevent/event-parse.h 
b/tools/lib/traceevent/event-parse.h
index 5b4efc0..6abda54 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -619,6 +619,7 @@ enum pevent_errno pevent_parse_format(struct pevent *pevent,
  const char *buf,
  unsigned long size, const char *sys);
 void pevent_free_format(struct event_format *event);
+void pevent_free_format_field(struct format_field *field);
 
 void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
   const char *name, struct pevent_record *record,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Fix summary_only option

2015-03-22 Thread tip-bot for David Ahern
Commit-ID:  13f22a2d4a5359867aa05562fc922f1ca24873a5
Gitweb: http://git.kernel.org/tip/13f22a2d4a5359867aa05562fc922f1ca24873a5
Author: David Ahern 
AuthorDate: Thu, 19 Mar 2015 12:23:03 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Sat, 21 Mar 2015 14:53:31 -0300

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 e596663ebb2 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 
Link: 
http://lkml.kernel.org/r/1426789383-19023-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 0b3b4e4..6af6bce 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1724,7 +1724,8 @@ static int trace__sys_enter(struct trace *trace, struct 
perf_evsel *evsel,
return -1;
}
 
-   printed += trace__printf_interrupted_entry(trace, sample);
+   if (!trace->summary_only)
+   printed += trace__printf_interrupted_entry(trace, sample);
 
ttrace->entry_time = sample->time;
msg = ttrace->entry_str;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf probe: Fix compiles due to declarations using perf_probe_point

2015-03-14 Thread tip-bot for David Ahern
Commit-ID:  6d4a48968bfb5c67002f253fbaeb5acd41d7897a
Gitweb: http://git.kernel.org/tip/6d4a48968bfb5c67002f253fbaeb5acd41d7897a
Author: David Ahern 
AuthorDate: Wed, 11 Mar 2015 10:36:20 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 12 Mar 2015 12:40:00 -0300

perf probe: Fix compiles due to declarations using perf_probe_point

perf fails to build with gcc "(GCC) 4.4.7 20120313 (Red Hat
4.4.7-4.0.9)" (a.k.a., RHEL6 / CentOS 6 / OL 6):

  cc1: warnings being treated as errors
  util/probe-event.c: In function ‘get_alternative_line_range’:
  util/probe-event.c:359: error: missing initializer
  util/probe-event.c:359: error: (near initialization for ‘pp.file’)
  util/probe-event.c:359: error: missing initializer
  util/probe-event.c:359: error: (near initialization for ‘result.function’)

Fix by bringing in initializers to declaration.

Signed-off-by: David Ahern 
Cc: Masami Hiramatsu 
Link: 
http://lkml.kernel.org/r/1426084580-60780-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/probe-event.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index e2bf620..f272a71 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -356,12 +356,14 @@ static int get_alternative_line_range(struct debuginfo 
*dinfo,
  struct line_range *lr,
  const char *target, bool user)
 {
-   struct perf_probe_point pp = { 0 }, result = { 0 };
+   struct perf_probe_point pp = { .function = lr->function,
+  .file = lr->file,
+  .line = lr->start };
+   struct perf_probe_point result;
int ret, len = 0;
 
-   pp.function = lr->function;
-   pp.file = lr->file;
-   pp.line = lr->start;
+   memset(&result, 0, sizeof(result));
+
if (lr->end != INT_MAX)
len = lr->end - lr->start;
ret = find_alternative_probe_point(dinfo, &pp, &result,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Compare JOBS to 0 after grep

2015-03-02 Thread tip-bot for David Ahern
Commit-ID:  c65568c5456e5216e5467e81d1e04c1f5bdd453f
Gitweb: http://git.kernel.org/tip/c65568c5456e5216e5467e81d1e04c1f5bdd453f
Author: David Ahern 
AuthorDate: Wed, 18 Feb 2015 18:59:31 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Mar 2015 11:51:00 -0300

perf tools: Compare JOBS to 0 after grep

If JOBS is not by user perf tries to autodetect the number by grepping
the number of CPUs from /proc/cpuinfo. 'grep -c' will always return an
integer so after this command JOBS should be compared to 0, not "".

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1424303971-91904-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index cb2e586..d5020ae 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -25,7 +25,7 @@ unexport MAKEFLAGS
 #
 ifeq ($(JOBS),)
   JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
-  ifeq ($(JOBS),)
+  ifeq ($(JOBS),0)
 JOBS := 1
   endif
 endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Only include tsc file for x86

2015-03-02 Thread tip-bot for David Ahern
Commit-ID:  ecefde629fadd3fcca2ea4c6a799d6e6aab8781f
Gitweb: http://git.kernel.org/tip/ecefde629fadd3fcca2ea4c6a799d6e6aab8781f
Author: David Ahern 
AuthorDate: Thu, 19 Feb 2015 13:22:33 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Mar 2015 11:50:08 -0300

perf tools: Only include tsc file for x86

The perf_time_to_tsc and tsc_to_perf_time functions are only used for x86.

Make inclusion of tsc.c dependent on x86 as well.

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1424370153-128274-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/Build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index a2c8047..972a6e0 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -71,7 +71,7 @@ libperf-y += stat.o
 libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
-libperf-y += tsc.o
+libperf-$(CONFIG_X86) += tsc.o
 libperf-y += cloexec.o
 libperf-y += thread-stack.o
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf tools: Make sparc64 arch point to sparc

2015-03-01 Thread tip-bot for David Ahern
Commit-ID:  4861f87cd3d133f03e3b39b6650f4e12f1a9e421
Gitweb: http://git.kernel.org/tip/4861f87cd3d133f03e3b39b6650f4e12f1a9e421
Author: David Ahern 
AuthorDate: Wed, 18 Feb 2015 19:37:02 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 25 Feb 2015 17:39:17 -0300

perf tools: Make sparc64 arch point to sparc

The recent build changes cause perf to not compile for sparc64 since the
arch/sparc64/Build file does not exist:

/home/dahern/kernels/linux.git/tools/build/Makefile.build:40: 
arch/sparc64/Build: No such file or directory

Fix by converting the sparc64 RAW_ARCH to sparc ARCH -- similar to what
is done for x86_64.

Signed-off-by: David Ahern 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1424306222-96843-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/config/Makefile.arch | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/config/Makefile.arch b/tools/perf/config/Makefile.arch
index ff95a68..ac8721f 100644
--- a/tools/perf/config/Makefile.arch
+++ b/tools/perf/config/Makefile.arch
@@ -21,6 +21,10 @@ ifeq ($(RAW_ARCH),x86_64)
   endif
 endif
 
+ifeq ($(RAW_ARCH),sparc64)
+  ARCH ?= sparc
+endif
+
 ARCH ?= $(RAW_ARCH)
 
 LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf symbols: Define EM_AARCH64 for older OSes

2015-03-01 Thread tip-bot for David Ahern
Commit-ID:  e370a3d57664cd5e39c0b95d157ebc841b568409
Gitweb: http://git.kernel.org/tip/e370a3d57664cd5e39c0b95d157ebc841b568409
Author: David Ahern 
AuthorDate: Wed, 18 Feb 2015 19:33:37 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 25 Feb 2015 17:39:17 -0300

perf symbols: Define EM_AARCH64 for older OSes

4886f2ca19f6f added an arm-64 check, but the EM_AARCH64 macro is not
defined in older releases (e.g., RHEL6). Define if it is not defined.

Signed-off-by: David Ahern 
Cc: Victor Kamensky 
Link: 
http://lkml.kernel.org/r/1424306017-96797-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/symbol-elf.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index b24f9d8..33b7a2a 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -11,6 +11,11 @@
 #include 
 #include "debug.h"
 
+#ifndef EM_AARCH64
+#define EM_AARCH64 183  /* ARM 64 bit */
+#endif
+
+
 #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
 extern char *cplus_demangle(const char *, int);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf top: Fix SIGBUS on sparc64

2015-03-01 Thread tip-bot for David Ahern
Commit-ID:  a73b6c199a663d64a38198f547d5c5be42163193
Gitweb: http://git.kernel.org/tip/a73b6c199a663d64a38198f547d5c5be42163193
Author: David Ahern 
AuthorDate: Wed, 18 Feb 2015 19:03:18 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 25 Feb 2015 17:37:44 -0300

perf top: Fix SIGBUS on sparc64

perf-top is terminating due to SIGBUS on sparc64. git bisect points to:

commit 82396986032915c1572bfb74b224fcc2e4e8ba7c
Author: Arnaldo Carvalho de Melo 
Date:   Mon Sep 8 13:26:35 2014 -0300

perf evlist: Refcount mmaps

We need to know how many fds are using a perf mmap via
PERF_EVENT_IOC_SET_OUTPUT, so that we can know when to ditch an mmap,
refcount it.

This commit added 'int refcnt' to struct perf_mmap and the addition makes the
event_copy element no longer 8-byte aligned.

Fix by adding __attribute__((aligned(8))) to the event_copy struct
member.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1424304198-92028-1-git-send-email-david.ah...@oracle.com
[ Switched from 'int pad;' to using __attribute__, David tested/acked that ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evlist.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index c94a9e0..e99a676 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -28,7 +28,7 @@ struct perf_mmap {
int  mask;
int  refcnt;
unsigned int prev;
-   char event_copy[PERF_SAMPLE_MAX_SIZE];
+   char event_copy[PERF_SAMPLE_MAX_SIZE] 
__attribute__((aligned(8)));
 };
 
 struct perf_evlist {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Fix SIGBUS failures due to misaligned accesses

2015-02-28 Thread tip-bot for David Ahern
Commit-ID:  55d43bcafe78b6da33f8a49be68ef168f3cbfec9
Gitweb: http://git.kernel.org/tip/55d43bcafe78b6da33f8a49be68ef168f3cbfec9
Author: David Ahern 
AuthorDate: Thu, 19 Feb 2015 15:00:22 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 26 Feb 2015 11:59:04 -0300

perf trace: Fix SIGBUS failures due to misaligned accesses

On Sparc64 perf-trace is failing in many spots due to extended load
instructions being used on misaligned accesses.

(gdb) run trace ls
Starting program: /tmp/perf/perf trace ls
[Thread debugging using libthread_db enabled]
Detaching after fork from child process 169460.



Program received signal SIGBUS, Bus error.
0x0014f4dc in tp_field__u64 (field=0x4cc700, sample=0x7fea098) at 
builtin-trace.c:61
warning: Source file is more recent than executable.
61  TP_UINT_FIELD(64);

(gdb) bt
 0  0x0014f4dc in tp_field__u64 (field=0x4cc700, sample=0x7fea098) 
at builtin-trace.c:61
 1  0x00156ad4 in trace__sys_exit (trace=0x7fec268, evsel=0x4cc580, 
event=0xfc0104912000,
sample=0x7fea098) at builtin-trace.c:1701
 2  0x00158c14 in trace__run (trace=0x7fec268, argc=1, 
argv=0x7fef360) at builtin-trace.c:2160
 3  0x0015b78c in cmd_trace (argc=1, argv=0x7fef360, prefix=0x0) at 
builtin-trace.c:2609
 4  0x00107d94 in run_builtin (p=0x4549c8, argc=2, argv=0x7fef360) 
at perf.c:341
 5  0x00108140 in handle_internal_command (argc=2, argv=0x7fef360) 
at perf.c:400
 6  0x00108308 in run_argv (argcp=0x7feef2c, argv=0x7feef20) at 
perf.c:444
 7  0x00108728 in main (argc=2, argv=0x7fef360) at perf.c:559

(gdb) p *sample
$1 = {ip = 4391276, pid = 169472, tid = 169472, time = 6303014583281250, addr = 
0, id = 72082,
  stream_id = 18446744073709551615, period = 1, weight = 0, transaction = 0, 
cpu = 73, raw_size = 36,
  data_src = 84410401, flags = 0, insn_len = 0, raw_data = 0xfc010491203c, 
callchain = 0x0,
  branch_stack = 0x0, user_regs = {abi = 0, mask = 0, regs = 0x0, cache_regs = 
0x7fea098, cache_mask = 0},
  intr_regs = {abi = 0, mask = 0, regs = 0x0, cache_regs = 0x7fea098, 
cache_mask = 0}, user_stack = {
offset = 0, size = 0, data = 0x0}, read = {time_enabled = 0, time_running = 
0, {group = {nr = 0,
values = 0x0}, one = {value = 0, id = 0
(gdb) p *field
$2 = {offset = 16, {integer = 0x14f4a8 , pointer = 0x14f4a8 
}}

sample->raw_data is guaranteed to not be 8-byte aligned because it is preceded
by the size as a u3. So accessing raw data with an extended load instruction 
causes
the SIGBUS. Resolve by using memcpy to a temporary variable of appropriate size.

Signed-off-by: David Ahern 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1424376022-140608-1-git-send-email-david.ah...@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 36 +---
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 5cd84974..d95a8f4 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -52,7 +52,9 @@ struct tp_field {
 #define TP_UINT_FIELD(bits) \
 static u64 tp_field__u##bits(struct tp_field *field, struct perf_sample 
*sample) \
 { \
-   return *(u##bits *)(sample->raw_data + field->offset); \
+   u##bits value; \
+   memcpy(&value, sample->raw_data + field->offset, sizeof(value)); \
+   return value;  \
 }
 
 TP_UINT_FIELD(8);
@@ -63,7 +65,8 @@ TP_UINT_FIELD(64);
 #define TP_UINT_FIELD__SWAPPED(bits) \
 static u64 tp_field__swapped_u##bits(struct tp_field *field, struct 
perf_sample *sample) \
 { \
-   u##bits value = *(u##bits *)(sample->raw_data + field->offset); \
+   u##bits value; \
+   memcpy(&value, sample->raw_data + field->offset, sizeof(value)); \
return bswap_##bits(value);\
 }
 
@@ -1517,11 +1520,22 @@ static int trace__read_syscall_info(struct trace 
*trace, int id)
return syscall__set_arg_fmts(sc);
 }
 
+/*
+ * args is to be interpreted as a series of longs but we need to handle
+ * 8-byte unaligned accesses. args points to raw_data within the event
+ * and raw_data is guaranteed to be 8-byte unaligned because it is
+ * preceded by raw_size which is a u32. So we need to copy args to a temp
+ * variable to read it. Most notably this avoids extended load instructions
+ * on unaligned addresses
+ */
+
 static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t 
size,
- unsigned long *args, struct trace *trace,
+ unsigned char *args, struct trace *trace,
  struct thread *thread)
 {
size_t printed = 0;
+   unsigned char *p;
+   unsigned long val;
 
if (sc->tp_format != NULL) {
struct format_field *field;
@@ -1537,12 +1551,17 @@ static size_t syscall__scnprintf_args(struc

[tip:perf/core] tools lib traceevent: Add support for IP address formats

2015-01-28 Thread tip-bot for David Ahern
Commit-ID:  3d199b5be53348bef84883013c484b414adf0a2e
Gitweb: http://git.kernel.org/tip/3d199b5be53348bef84883013c484b414adf0a2e
Author: David Ahern 
AuthorDate: Thu, 18 Dec 2014 19:11:11 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 26 Jan 2015 12:04:41 -0300

tools lib traceevent: Add support for IP address formats

Add helpers for the following kernel formats:
  %pi4 print an IPv4 address with leading zeros
  %pI4 print an IPv4 address without leading zeros
  %pi6 print an IPv6 address without colons
  %pI6 print an IPv6 address with colons
  %pI6c print an IPv6 address in compressed form with colons
  %pISpc print an IP address from a sockaddr

Allows these formats to be used in tracepoints.

Quite a bit of this is adapted from code in lib/vsprintf.c.

v4:
- fixed pI6c description in git commit message per Valdis' comment

v3:
- use of 'c' and 'p' requires 'I'

v2:
- pass ptr+1 to print_ip_arg per Namhyung's comments
- added field length checks to sockaddr function

Signed-off-by: David Ahern 
Acked-by: Steven Rostedt 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1418955071-36241-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/traceevent/event-parse.c | 328 +
 1 file changed, 328 insertions(+)

diff --git a/tools/lib/traceevent/event-parse.c 
b/tools/lib/traceevent/event-parse.c
index cf3a44b..afe20ed 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 
+#include 
 #include "event-parse.h"
 #include "event-utils.h"
 
@@ -4149,6 +4150,324 @@ static void print_mac_arg(struct trace_seq *s, int mac, 
void *data, int size,
trace_seq_printf(s, fmt, buf[0], buf[1], buf[2], buf[3], buf[4], 
buf[5]);
 }
 
+static void print_ip4_addr(struct trace_seq *s, char i, unsigned char *buf)
+{
+   const char *fmt;
+
+   if (i == 'i')
+   fmt = "%03d.%03d.%03d.%03d";
+   else
+   fmt = "%d.%d.%d.%d";
+
+   trace_seq_printf(s, fmt, buf[0], buf[1], buf[2], buf[3]);
+}
+
+static inline bool ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+   return ((unsigned long)(a->s6_addr32[0] | a->s6_addr32[1]) |
+   (unsigned long)(a->s6_addr32[2] ^ htonl(0x))) == 0UL;
+}
+
+static inline bool ipv6_addr_is_isatap(const struct in6_addr *addr)
+{
+   return (addr->s6_addr32[2] | htonl(0x0200)) == htonl(0x02005EFE);
+}
+
+static void print_ip6c_addr(struct trace_seq *s, unsigned char *addr)
+{
+   int i, j, range;
+   unsigned char zerolength[8];
+   int longest = 1;
+   int colonpos = -1;
+   uint16_t word;
+   uint8_t hi, lo;
+   bool needcolon = false;
+   bool useIPv4;
+   struct in6_addr in6;
+
+   memcpy(&in6, addr, sizeof(struct in6_addr));
+
+   useIPv4 = ipv6_addr_v4mapped(&in6) || ipv6_addr_is_isatap(&in6);
+
+   memset(zerolength, 0, sizeof(zerolength));
+
+   if (useIPv4)
+   range = 6;
+   else
+   range = 8;
+
+   /* find position of longest 0 run */
+   for (i = 0; i < range; i++) {
+   for (j = i; j < range; j++) {
+   if (in6.s6_addr16[j] != 0)
+   break;
+   zerolength[i]++;
+   }
+   }
+   for (i = 0; i < range; i++) {
+   if (zerolength[i] > longest) {
+   longest = zerolength[i];
+   colonpos = i;
+   }
+   }
+   if (longest == 1)   /* don't compress a single 0 */
+   colonpos = -1;
+
+   /* emit address */
+   for (i = 0; i < range; i++) {
+   if (i == colonpos) {
+   if (needcolon || i == 0)
+   trace_seq_printf(s, ":");
+   trace_seq_printf(s, ":");
+   needcolon = false;
+   i += longest - 1;
+   continue;
+   }
+   if (needcolon) {
+   trace_seq_printf(s, ":");
+   needcolon = false;
+   }
+   /* hex u16 without leading 0s */
+   word = ntohs(in6.s6_addr16[i]);
+   hi = word >> 8;
+   lo = word & 0xff;
+   if (hi)
+   trace_seq_printf(s, "%x%02x", hi, lo);
+   else
+   trace_seq_printf(s, "%x", lo);
+
+   needcolon = true;
+   }
+
+   if (useIPv4) {
+   if (needcolon)
+   trace_seq_printf(s, ":");
+   print_ip4_addr(s, 'I', &in6.s6_addr[12]);
+   }
+
+   return;
+}
+
+static void print_ip6_addr(struct trace_seq *s, char i, unsigned char *buf)
+{
+   int j;
+
+   for (j = 0; j < 16; j += 2) {
+   trace_seq_printf(s, "%02x%02x", buf[j], buf[j+

[tip:perf/core] perf tools: Fix inverted error verification bug in thread__fork

2013-12-16 Thread tip-bot for David Ahern
Commit-ID:  8d00be815c05ed0f0202f606bab4e54f98fd3b30
Gitweb: http://git.kernel.org/tip/8d00be815c05ed0f0202f606bab4e54f98fd3b30
Author: David Ahern 
AuthorDate: Tue, 10 Dec 2013 21:35:38 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 13 Dec 2013 10:30:21 -0300

perf tools: Fix inverted error verification bug in thread__fork

Commit 1902efe7f for the new comm infra added the wrong check for return
code on thread__set_comm. err == 0 is normal, so don't return at that
point unless err != 0.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Link: 
http://lkml.kernel.org/r/1386736538-23525-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/thread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 49eaf1d..e394861 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -126,7 +126,7 @@ int thread__fork(struct thread *thread, struct thread 
*parent, u64 timestamp)
if (!comm)
return -ENOMEM;
err = thread__set_comm(thread, comm, timestamp);
-   if (!err)
+   if (err)
return err;
thread->comm_set = true;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Fix summary percentage when processing files

2013-12-11 Thread tip-bot for David Ahern
Commit-ID:  3160565f0e005d2ec736ae25cf0a79988c0cbe71
Gitweb: http://git.kernel.org/tip/3160565f0e005d2ec736ae25cf0a79988c0cbe71
Author: David Ahern 
AuthorDate: Wed, 4 Dec 2013 19:41:41 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Dec 2013 10:09:58 -0300

perf trace: Fix summary percentage when processing files

Getting a divide by 0 when events are processed from a file:

   perf trace -i perf.data -s
   ...
   dnsmasq (1684), 10 events, inf%, 0.000 msec

The problem is that the event count is not incremented as events are
processed. With this patch:

   perf trace -i perf.data -s
   ...
   dnsmasq (1684), 10 events, 8.9%, 0.000 msec

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1386211302-31303-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index a7aa771..56bbca5 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1770,8 +1770,10 @@ static int trace__process_sample(struct perf_tool *tool,
if (!trace->full_time && trace->base_time == 0)
trace->base_time = sample->time;
 
-   if (handler)
+   if (handler) {
+   ++trace->nr_events;
handler(trace, evsel, sample);
+   }
 
return err;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Add support for syscalls vs raw_syscalls

2013-12-11 Thread tip-bot for David Ahern
Commit-ID:  9aca7f1792c5d2d5d367bbe5cfe204fe40517929
Gitweb: http://git.kernel.org/tip/9aca7f1792c5d2d5d367bbe5cfe204fe40517929
Author: David Ahern 
AuthorDate: Wed, 4 Dec 2013 19:41:39 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Dec 2013 10:05:45 -0300

perf trace: Add support for syscalls vs raw_syscalls

Older kernels (e.g., RHEL6) do system call tracing via
syscalls:sys_{enter,exit} rather than raw_syscalls. Update perf-trace to
detect lack of raw_syscalls support and try syscalls.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1386211302-31303-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 56afe33..a7aa771 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -12,6 +12,7 @@
 #include "util/thread_map.h"
 #include "util/stat.h"
 #include "trace-event.h"
+#include "util/parse-events.h"
 
 #include 
 #include 
@@ -173,6 +174,10 @@ static struct perf_evsel *perf_evsel__syscall_newtp(const 
char *direction, void
 {
struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction);
 
+   /* older kernel (e.g., RHEL6) use syscalls:{enter,exit} */
+   if (evsel == NULL)
+   evsel = perf_evsel__newtp("syscalls", direction);
+
if (evsel) {
if (perf_evsel__init_syscall_tp(evsel, handler))
goto out_delete;
@@ -1801,10 +1806,11 @@ static int trace__record(int argc, const char **argv)
"-R",
"-m", "1024",
"-c", "1",
-   "-e", "raw_syscalls:sys_enter,raw_syscalls:sys_exit",
+   "-e",
};
 
-   rec_argc = ARRAY_SIZE(record_args) + argc;
+   /* +1 is for the event string below */
+   rec_argc = ARRAY_SIZE(record_args) + 1 + argc;
rec_argv = calloc(rec_argc + 1, sizeof(char *));
 
if (rec_argv == NULL)
@@ -1813,6 +1819,17 @@ static int trace__record(int argc, const char **argv)
for (i = 0; i < ARRAY_SIZE(record_args); i++)
rec_argv[i] = record_args[i];
 
+   /* event string may be different for older kernels - e.g., RHEL6 */
+   if (is_valid_tracepoint("raw_syscalls:sys_enter"))
+   rec_argv[i] = "raw_syscalls:sys_enter,raw_syscalls:sys_exit";
+   else if (is_valid_tracepoint("syscalls:sys_enter"))
+   rec_argv[i] = "syscalls:sys_enter,syscalls:sys_exit";
+   else {
+   pr_err("Neither raw_syscalls nor syscalls events exist.\n");
+   return -1;
+   }
+   i++;
+
for (j = 0; j < (unsigned int)argc; j++, i++)
rec_argv[i] = argv[j];
 
@@ -2048,6 +2065,10 @@ static int trace__replay(struct trace *trace)
 
evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
 "raw_syscalls:sys_enter");
+   /* older kernels have syscalls tp versus raw_syscalls */
+   if (evsel == NULL)
+   evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
+
"syscalls:sys_enter");
if (evsel == NULL) {
pr_err("Data file does not have raw_syscalls:sys_enter 
event\n");
goto out;
@@ -2061,6 +2082,9 @@ static int trace__replay(struct trace *trace)
 
evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
 "raw_syscalls:sys_exit");
+   if (evsel == NULL)
+   evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
+
"syscalls:sys_exit");
if (evsel == NULL) {
pr_err("Data file does not have raw_syscalls:sys_exit event\n");
goto out;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf thread: Move comm_list check into function

2013-11-30 Thread tip-bot for David Ahern
Commit-ID:  1f3878c11ca8c9f2d9545ec6e1e6bb5386e0565f
Gitweb: http://git.kernel.org/tip/1f3878c11ca8c9f2d9545ec6e1e6bb5386e0565f
Author: David Ahern 
AuthorDate: Mon, 18 Nov 2013 13:32:47 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Nov 2013 14:58:37 -0300

perf thread: Move comm_list check into function

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1384806771-2945-5-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/event.c  |  3 +--
 tools/perf/util/thread.h | 12 
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index bb788c1..c77814b 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -732,8 +732,7 @@ int perf_event__preprocess_sample(const union perf_event 
*event,
if (thread == NULL)
return -1;
 
-   if (symbol_conf.comm_list &&
-   !strlist__has_entry(symbol_conf.comm_list, 
thread__comm_str(thread)))
+   if (thread__is_filtered(thread))
goto out_filtered;
 
dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), 
thread->tid);
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 897c1b2..5b856bf 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include "symbol.h"
+#include 
 
 struct thread {
union {
@@ -66,4 +67,15 @@ static inline void thread__set_priv(struct thread *thread, 
void *p)
 {
thread->priv = p;
 }
+
+static inline bool thread__is_filtered(struct thread *thread)
+{
+   if (symbol_conf.comm_list &&
+   !strlist__has_entry(symbol_conf.comm_list, 
thread__comm_str(thread))) {
+   return true;
+   }
+
+   return false;
+}
+
 #endif /* __PERF_THREAD_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf script: Print callchains and symbols if they exist

2013-11-30 Thread tip-bot for David Ahern
Commit-ID:  80b8b496ec6edaff01f9ab74dbe8a517cd718de8
Gitweb: http://git.kernel.org/tip/80b8b496ec6edaff01f9ab74dbe8a517cd718de8
Author: David Ahern 
AuthorDate: Tue, 19 Nov 2013 21:07:37 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Nov 2013 14:58:38 -0300

perf script: Print callchains and symbols if they exist

The intent of perf-script is to dump the events and information in the
file. H/W, S/W and raw events all dump callchains if they are present;
might as well make that the default for tracepoints too.

v2: Only add options for sym, dso and ip if callchains are present

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Link: 
http://lkml.kernel.org/r/1384920457-5986-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-script.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index b392770..9f3ba44 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -280,6 +280,30 @@ static int perf_session__check_output_opt(struct 
perf_session *session)
set_print_ip_opts(&evsel->attr);
}
 
+   /*
+* set default for tracepoints to print symbols only
+* if callchains are present
+*/
+   if (symbol_conf.use_callchain &&
+   !output[PERF_TYPE_TRACEPOINT].user_set) {
+   struct perf_event_attr *attr;
+
+   j = PERF_TYPE_TRACEPOINT;
+   evsel = perf_session__find_first_evtype(session, j);
+   if (evsel == NULL)
+   goto out;
+
+   attr = &evsel->attr;
+
+   if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
+   output[j].fields |= PERF_OUTPUT_IP;
+   output[j].fields |= PERF_OUTPUT_SYM;
+   output[j].fields |= PERF_OUTPUT_DSO;
+   set_print_ip_opts(attr);
+   }
+   }
+
+out:
return 0;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf evsel: Skip ignored symbols while printing callchain

2013-11-30 Thread tip-bot for David Ahern
Commit-ID:  d2ff1b1499c8e0ad2fc79376a4215ba37771823f
Gitweb: http://git.kernel.org/tip/d2ff1b1499c8e0ad2fc79376a4215ba37771823f
Author: David Ahern 
AuthorDate: Mon, 18 Nov 2013 13:32:44 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Nov 2013 14:58:37 -0300

perf evsel: Skip ignored symbols while printing callchain

Allows a command to have a symbol_filter controlled by the user to skip
certain functions in a backtrace. One example is to allow the user to
reduce repeating patterns like:

do_select  core_sys_select  sys_select

to just sys_select when dumping callchains, consuming less real estate
on the screen while still conveying the essential message - the process
is in a select call.

This option is leveraged by the upcoming timehist command.

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1384806771-2945-2-git-send-email-dsah...@gmail.com
[ Checked if al.sym is NULL before touching al.sym->ignored, as noted by Adrian 
Hunter ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/session.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f36d24a..b0b15e2 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1522,6 +1522,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
if (!node)
break;
 
+   if (node->sym && node->sym->ignore)
+   goto next;
+
if (print_ip)
printf("%c%16" PRIx64, s, node->ip);
 
@@ -1544,12 +1547,15 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, 
union perf_event *event,
if (!print_oneline)
printf("\n");
 
-   callchain_cursor_advance(&callchain_cursor);
-
stack_depth--;
+next:
+   callchain_cursor_advance(&callchain_cursor);
}
 
} else {
+   if (al.sym && al.sym->ignore)
+   return;
+
if (print_ip)
printf("%16" PRIx64, sample->ip);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf symbols: Move idle syms check from top to generic function

2013-11-30 Thread tip-bot for David Ahern
Commit-ID:  82d1deb0546a4af7a2ddbcfed99690b3a61776c5
Gitweb: http://git.kernel.org/tip/82d1deb0546a4af7a2ddbcfed99690b3a61776c5
Author: David Ahern 
AuthorDate: Mon, 18 Nov 2013 13:32:45 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Nov 2013 14:58:37 -0300

perf symbols: Move idle syms check from top to generic function

Allows list of idle symbols to be leveraged by other commands, such as
the upcoming timehist command.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1384806771-2945-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-top.c | 25 ++---
 tools/perf/util/symbol.c | 30 ++
 tools/perf/util/symbol.h |  1 +
 3 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 531522d..03d37a7 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -634,26 +634,9 @@ repeat:
return NULL;
 }
 
-/* Tag samples to be skipped. */
-static const char *skip_symbols[] = {
-   "intel_idle",
-   "default_idle",
-   "native_safe_halt",
-   "cpu_idle",
-   "enter_idle",
-   "exit_idle",
-   "mwait_idle",
-   "mwait_idle_with_hints",
-   "poll_idle",
-   "ppc64_runlatch_off",
-   "pseries_dedicated_idle_sleep",
-   NULL
-};
-
 static int symbol_filter(struct map *map __maybe_unused, struct symbol *sym)
 {
const char *name = sym->name;
-   int i;
 
/*
 * ppc64 uses function descriptors and appends a '.' to the
@@ -671,12 +654,8 @@ static int symbol_filter(struct map *map __maybe_unused, 
struct symbol *sym)
strstr(name, "_text_end"))
return 1;
 
-   for (i = 0; skip_symbols[i]; i++) {
-   if (!strcmp(skip_symbols[i], name)) {
-   sym->ignore = true;
-   break;
-   }
-   }
+   if (symbol__is_idle(sym))
+   sym->ignore = true;
 
return 0;
 }
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index c0c3696..f55c18d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -573,6 +573,36 @@ static u8 kallsyms2elf_type(char type)
return isupper(type) ? STB_GLOBAL : STB_LOCAL;
 }
 
+bool symbol__is_idle(struct symbol *sym)
+{
+   const char * const idle_symbols[] = {
+   "cpu_idle",
+   "intel_idle",
+   "default_idle",
+   "native_safe_halt",
+   "enter_idle",
+   "exit_idle",
+   "mwait_idle",
+   "mwait_idle_with_hints",
+   "poll_idle",
+   "ppc64_runlatch_off",
+   "pseries_dedicated_idle_sleep",
+   NULL
+   };
+
+   int i;
+
+   if (!sym)
+   return false;
+
+   for (i = 0; idle_symbols[i]; i++) {
+   if (!strcmp(idle_symbols[i], sym->name))
+   return true;
+   }
+
+   return false;
+}
+
 static int map__process_kallsym_symbol(void *arg, const char *name,
   char type, u64 start)
 {
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 07de8fe..ad13c5d 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -240,6 +240,7 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp);
 bool symbol_type__is_a(char symbol_type, enum map_type map_type);
 bool symbol__restricted_filename(const char *filename,
 const char *restricted_filename);
+bool symbol__is_idle(struct symbol *sym);
 
 int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
  struct symsrc *runtime_ss, symbol_filter_t filter,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Export setup_list

2013-11-30 Thread tip-bot for David Ahern
Commit-ID:  3bfe5f81fc8f87bf822f3da36927cfc549f3b3db
Gitweb: http://git.kernel.org/tip/3bfe5f81fc8f87bf822f3da36927cfc549f3b3db
Author: David Ahern 
AuthorDate: Mon, 18 Nov 2013 13:32:48 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Nov 2013 14:58:38 -0300

perf tools: Export setup_list

Used in upcoming patches (perf sched timehist command).

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1384806771-2945-6-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/symbol.c | 2 +-
 tools/perf/util/symbol.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index f55c18d..ce9ce10 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1749,7 +1749,7 @@ out_fail:
return -1;
 }
 
-static int setup_list(struct strlist **list, const char *list_str,
+int setup_list(struct strlist **list, const char *list_str,
  const char *list_name)
 {
if (list_str == NULL)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index ad13c5d..f1031a1 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -274,4 +274,7 @@ void kcore_extract__delete(struct kcore_extract *kce);
 int kcore_copy(const char *from_dir, const char *to_dir);
 int compare_proc_modules(const char *from, const char *to);
 
+int setup_list(struct strlist **list, const char *list_str,
+  const char *list_name);
+
 #endif /* __PERF_SYMBOL */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf top: Make -g refer to callchains

2013-11-30 Thread tip-bot for David Ahern
Commit-ID:  bf80669e4f689f181f23a54dfe2a0f264147ad67
Gitweb: http://git.kernel.org/tip/bf80669e4f689f181f23a54dfe2a0f264147ad67
Author: David Ahern 
AuthorDate: Thu, 14 Nov 2013 20:51:30 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Nov 2013 14:58:35 -0300

perf top: Make -g refer to callchains

In most commands -g is used for callchains. Make perf-top follow suit.
Move group to just --group with no short cut making it similar to
perf-record.

Signed-off-by: David Ahern 
Acked-by: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1384487490-6865-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-top.txt | 5 ++---
 tools/perf/builtin-top.c  | 4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-top.txt 
b/tools/perf/Documentation/perf-top.txt
index 7de01dd..cdd8d49 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -50,7 +50,6 @@ Default is to monitor all CPUS.
 --count-filter=::
Only display functions with more events than this.
 
--g::
 --group::
 Put the counters into a counter group.
 
@@ -143,12 +142,12 @@ Default is to monitor all CPUS.
 --asm-raw::
Show raw instruction encoding of assembly instructions.
 
--G::
+-g::
Enables call-graph (stack chain/backtrace) recording.
 
 --call-graph::
Setup and enable call-graph (stack chain/backtrace) recording,
-   implies -G.
+   implies -g.
 
 --max-stack::
Set the stack depth limit when parsing the callchain, anything
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 71e6402..531522d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1084,7 +1084,7 @@ int cmd_top(int argc, const char **argv, const char 
*prefix __maybe_unused)
"dump the symbol table used for profiling"),
OPT_INTEGER('f', "count-filter", &top.count_filter,
"only display functions with more events than this"),
-   OPT_BOOLEAN('g', "group", &opts->group,
+   OPT_BOOLEAN(0, "group", &opts->group,
"put the counters into a counter group"),
OPT_BOOLEAN('i', "no-inherit", &opts->no_inherit,
"child tasks do not inherit counters"),
@@ -1105,7 +1105,7 @@ int cmd_top(int argc, const char **argv, const char 
*prefix __maybe_unused)
   " abort, in_tx, transaction"),
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
"Show a column with the number of samples"),
-   OPT_CALLBACK_NOOPT('G', NULL, &top.record_opts,
+   OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
   NULL, "enables call-graph recording",
   &callchain_opt),
OPT_CALLBACK(0, "call-graph", &top.record_opts,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf record: Fix segfault with --no-mmap-pages

2013-11-12 Thread tip-bot for David Ahern
Commit-ID:  8973504be70b2986a2081eeff7d9a4210dec295d
Gitweb: http://git.kernel.org/tip/8973504be70b2986a2081eeff7d9a4210dec295d
Author: David Ahern 
AuthorDate: Tue, 12 Nov 2013 07:46:53 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 12 Nov 2013 16:30:54 -0300

perf record: Fix segfault with --no-mmap-pages

Adrian reported a segfault when using --no-out-pages:

$ tools/perf/perf record -vv --no-out-pages uname
Segmentation fault (core dumped)

The same occurs with --no-mmap-pages. Fix by checking that str is
non-NULL before parsing it.

Signed-off-by: David Ahern 
Reported-by: Adrian Hunter 
Cc: Adrian Hunter 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1384267617-3446-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evlist.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 99dc58e..3960560 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -719,6 +719,9 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, 
const char *str,
{ .tag  = 0 },
};
 
+   if (str == NULL)
+   return -1;
+
val = parse_tag_value(str, tags);
if (val != (unsigned long) -1) {
/* we got file size value */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf evlist: Refactor mmap_pages parsing

2013-11-12 Thread tip-bot for David Ahern
Commit-ID:  33c2dcfdfe7f114cc656bcb4c839f5939d5e60ba
Gitweb: http://git.kernel.org/tip/33c2dcfdfe7f114cc656bcb4c839f5939d5e60ba
Author: David Ahern 
AuthorDate: Tue, 12 Nov 2013 07:46:55 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 12 Nov 2013 16:33:22 -0300

perf evlist: Refactor mmap_pages parsing

Logic will be re-used for the out-pages argument for mmap based writes
in perf-record.

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1384267617-3446-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evlist.c | 39 ---
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index fb4727d..cb19044 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -705,10 +705,9 @@ static size_t perf_evlist__mmap_size(unsigned long pages)
return (pages + 1) * page_size;
 }
 
-int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
- int unset __maybe_unused)
+static long parse_pages_arg(const char *str, unsigned long min,
+   unsigned long max)
 {
-   unsigned int *mmap_pages = opt->value;
unsigned long pages, val;
static struct parse_tag tags[] = {
{ .tag  = 'B', .mult = 1   },
@@ -719,7 +718,7 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, 
const char *str,
};
 
if (str == NULL)
-   return -1;
+   return -EINVAL;
 
val = parse_tag_value(str, tags);
if (val != (unsigned long) -1) {
@@ -729,20 +728,38 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
/* we got pages count value */
char *eptr;
pages = strtoul(str, &eptr, 10);
-   if (*eptr != '\0') {
-   pr_err("failed to parse --mmap_pages/-m value\n");
-   return -1;
-   }
+   if (*eptr != '\0')
+   return -EINVAL;
}
 
-   if (pages < (1UL << 31) && !is_power_of_2(pages)) {
+   if ((pages == 0) && (min == 0)) {
+   /* leave number of pages at 0 */
+   } else if (pages < (1UL << 31) && !is_power_of_2(pages)) {
+   /* round pages up to next power of 2 */
pages = next_pow2(pages);
pr_info("rounding mmap pages size to %lu bytes (%lu pages)\n",
pages * page_size, pages);
}
 
-   if (pages > UINT_MAX || pages > SIZE_MAX / page_size) {
-   pr_err("--mmap_pages/-m value too big\n");
+   if (pages > max)
+   return -EINVAL;
+
+   return pages;
+}
+
+int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
+ int unset __maybe_unused)
+{
+   unsigned int *mmap_pages = opt->value;
+   unsigned long max = UINT_MAX;
+   long pages;
+
+   if (max < SIZE_MAX / page_size)
+   max = SIZE_MAX / page_size;
+
+   pages = parse_pages_arg(str, 1, max);
+   if (pages < 0) {
+   pr_err("Invalid argument for --mmap_pages/-m\n");
return -1;
}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf evlist: Round mmap pages to power 2 - v2

2013-11-12 Thread tip-bot for David Ahern
Commit-ID:  9639837e95db90d056f4683c911717921519320e
Gitweb: http://git.kernel.org/tip/9639837e95db90d056f4683c911717921519320e
Author: David Ahern 
AuthorDate: Tue, 12 Nov 2013 07:46:54 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 12 Nov 2013 16:31:53 -0300

perf evlist: Round mmap pages to power 2 - v2

Currently perf requires the -m / --mmap_pages option to be a power of 2.

To be more user friendly perf should automatically round this up to the
next power of 2.

Currently:
  $ perf record -m 3 -a -- sleep 1
  --mmap_pages/-m value must be a power of two.sleep: Terminated

With patch:
  $ perf record -m 3 -a -- sleep 1
  rounding mmap pages size to 16384 (4 pages)
  ...

v2: Add bytes units to rounding message per Ingo's request. Other
suggestions (e.g., prefixing INFO) should be addressed by wrapping
pr_info to catch all instances.

Suggested-by: Ingo Molnar 
Signed-off-by: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1384267617-3446-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evlist.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 3960560..fb4727d 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -710,7 +710,6 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, 
const char *str,
 {
unsigned int *mmap_pages = opt->value;
unsigned long pages, val;
-   size_t size;
static struct parse_tag tags[] = {
{ .tag  = 'B', .mult = 1   },
{ .tag  = 'K', .mult = 1 << 10 },
@@ -726,11 +725,6 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
if (val != (unsigned long) -1) {
/* we got file size value */
pages = PERF_ALIGN(val, page_size) / page_size;
-   if (pages < (1UL << 31) && !is_power_of_2(pages)) {
-   pages = next_pow2(pages);
-   pr_info("rounding mmap pages size to %lu (%lu pages)\n",
-   pages * page_size, pages);
-   }
} else {
/* we got pages count value */
char *eptr;
@@ -741,14 +735,14 @@ int perf_evlist__parse_mmap_pages(const struct option 
*opt, const char *str,
}
}
 
-   if (pages > UINT_MAX || pages > SIZE_MAX / page_size) {
-   pr_err("--mmap_pages/-m value too big\n");
-   return -1;
+   if (pages < (1UL << 31) && !is_power_of_2(pages)) {
+   pages = next_pow2(pages);
+   pr_info("rounding mmap pages size to %lu bytes (%lu pages)\n",
+   pages * page_size, pages);
}
 
-   size = perf_evlist__mmap_size(pages);
-   if (!size) {
-   pr_err("--mmap_pages/-m value must be a power of two.");
+   if (pages > UINT_MAX || pages > SIZE_MAX / page_size) {
+   pr_err("--mmap_pages/-m value too big\n");
return -1;
}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf trace: Add summary only option

2013-11-12 Thread tip-bot for David Ahern
Commit-ID:  fd2eabaf16984bc75695e43f4b76e6f20ed4ea41
Gitweb: http://git.kernel.org/tip/fd2eabaf16984bc75695e43f4b76e6f20ed4ea41
Author: David Ahern 
AuthorDate: Tue, 12 Nov 2013 09:31:15 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 12 Nov 2013 16:24:38 -0300

perf trace: Add summary only option

Per request from Pekka make --summary a summary only option meaning do
not show the individual system calls. Add another option to see all
syscalls along with the summary. In addition use 's' and 'S' as
shortcuts for the options.

Requested-by: Pekka Enberg 
Signed-off-by: David Ahern 
Tested-by: Pekka Enberg 
Cc: Adrian Hunter 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Pekka Enberg 
Link: 
http://lkml.kernel.org/r/1384273875-3751-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-trace.txt | 10 --
 tools/perf/builtin-trace.c  | 16 +---
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index 7b0497f..fae38d9 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -93,9 +93,15 @@ the thread executes on the designated CPUs. Default is to 
monitor all CPUs.
 --comm::
 Show process COMM right beside its ID, on by default, disable with 
--no-comm.
 
+-s::
 --summary::
-   Show a summary of syscalls by thread with min, max, and average times 
(in
-msec) and relative stddev.
+   Show only a summary of syscalls by thread with min, max, and average 
times
+(in msec) and relative stddev.
+
+-S::
+--with-summary::
+   Show all syscalls followed by a summary by thread with min, max, and
+average times (in msec) and relative stddev.
 
 --tool_stats::
Show tool stats such as number of times fd->pathname was discovered thru
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 0964c0c..aa5702f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1168,6 +1168,7 @@ struct trace {
boolsched;
boolmultiple_threads;
boolsummary;
+   boolsummary_only;
boolshow_comm;
boolshow_tool_stats;
double  duration_filter;
@@ -1611,7 +1612,7 @@ static int trace__sys_enter(struct trace *trace, struct 
perf_evsel *evsel,
   args, trace, thread);
 
if (!strcmp(sc->name, "exit_group") || !strcmp(sc->name, "exit")) {
-   if (!trace->duration_filter) {
+   if (!trace->duration_filter && !trace->summary_only) {
trace__fprintf_entry_head(trace, thread, 1, 
sample->time, trace->output);
fprintf(trace->output, "%-70s\n", ttrace->entry_str);
}
@@ -1664,6 +1665,9 @@ static int trace__sys_exit(struct trace *trace, struct 
perf_evsel *evsel,
} else if (trace->duration_filter)
goto out;
 
+   if (trace->summary_only)
+   goto out;
+
trace__fprintf_entry_head(trace, thread, duration, sample->time, 
trace->output);
 
if (ttrace->entry_pending) {
@@ -2282,8 +2286,10 @@ int cmd_trace(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
OPT_BOOLEAN('T', "time", &trace.full_time,
"Show full timestamp, not time relative to first start"),
-   OPT_BOOLEAN(0, "summary", &trace.summary,
-   "Show syscall summary with statistics"),
+   OPT_BOOLEAN('s', "summary", &trace.summary_only,
+   "Show only syscall summary with statistics"),
+   OPT_BOOLEAN('S', "with-summary", &trace.summary,
+   "Show all syscalls and summary with statistics"),
OPT_END()
};
int err;
@@ -2294,6 +2300,10 @@ int cmd_trace(int argc, const char **argv, const char 
*prefix __maybe_unused)
 
argc = parse_options(argc, argv, trace_options, trace_usage, 0);
 
+   /* summary_only implies summary option, but don't overwrite summary if 
set */
+   if (trace.summary_only)
+   trace.summary = trace.summary_only;
+
if (output_name != NULL) {
err = trace__open_output(&trace, output_name);
if (err < 0) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf record: Move existing write_output into helper function

2013-11-12 Thread tip-bot for David Ahern
Commit-ID:  a9986fad6645b98d5bb3c2f83c22efb0761ca272
Gitweb: http://git.kernel.org/tip/a9986fad6645b98d5bb3c2f83c22efb0761ca272
Author: David Ahern 
AuthorDate: Thu, 7 Nov 2013 21:23:24 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 11 Nov 2013 15:56:40 -0300

perf record: Move existing write_output into helper function

Code move only; no logic changes. In preparation for the mmap based
output option in the next patch.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1383884605-30968-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-record.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 8f5af32..880227e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -76,7 +76,7 @@ struct perf_record {
longsamples;
 };
 
-static int write_output(struct perf_record *rec, void *buf, size_t size)
+static int do_write_output(struct perf_record *rec, void *buf, size_t size)
 {
struct perf_data_file *file = &rec->file;
 
@@ -97,6 +97,11 @@ static int write_output(struct perf_record *rec, void *buf, 
size_t size)
return 0;
 }
 
+static int write_output(struct perf_record *rec, void *buf, size_t size)
+{
+   return do_write_output(rec, buf, size);
+}
+
 static int process_synthesized_event(struct perf_tool *tool,
 union perf_event *event,
 struct perf_sample *sample __maybe_unused,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf record: Refactor feature handling into a separate function

2013-11-07 Thread tip-bot for David Ahern
Commit-ID:  57706abc19afc60f0b629af839d2ebee17739f59
Gitweb: http://git.kernel.org/tip/57706abc19afc60f0b629af839d2ebee17739f59
Author: David Ahern 
AuthorDate: Wed, 6 Nov 2013 11:41:34 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 7 Nov 2013 10:42:26 -0300

perf record: Refactor feature handling into a separate function

Code move only. No logic changes.

Signed-off-by: David Ahern 
Acked-by: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1383763297-27066-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-record.c | 33 +
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index ea4c04f..2932069 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -342,9 +342,28 @@ out:
return rc;
 }
 
+static void perf_record__init_features(struct perf_record *rec)
+{
+   struct perf_evlist *evsel_list = rec->evlist;
+   struct perf_session *session = rec->session;
+   int feat;
+
+   for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
+   perf_header__set_feat(&session->header, feat);
+
+   if (rec->no_buildid)
+   perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
+
+   if (!have_tracepoints(&evsel_list->entries))
+   perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);
+
+   if (!rec->opts.branch_stack)
+   perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
+}
+
 static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
 {
-   int err, feat;
+   int err;
unsigned long waking = 0;
const bool forks = argc > 0;
struct machine *machine;
@@ -371,17 +390,7 @@ static int __cmd_record(struct perf_record *rec, int argc, 
const char **argv)
 
rec->session = session;
 
-   for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
-   perf_header__set_feat(&session->header, feat);
-
-   if (rec->no_buildid)
-   perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
-
-   if (!have_tracepoints(&evsel_list->entries))
-   perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);
-
-   if (!rec->opts.branch_stack)
-   perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
+   perf_record__init_features(rec);
 
if (forks) {
err = perf_evlist__prepare_workload(evsel_list, &opts->target,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf record: Remove post_processing_offset variable

2013-11-07 Thread tip-bot for David Ahern
Commit-ID:  7ab75cffd6a1b2195944b8522673522f09e7fcb0
Gitweb: http://git.kernel.org/tip/7ab75cffd6a1b2195944b8522673522f09e7fcb0
Author: David Ahern 
AuthorDate: Wed, 6 Nov 2013 11:41:36 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 7 Nov 2013 11:01:59 -0300

perf record: Remove post_processing_offset variable

Duplicates the data_offset from header in the session.

Signed-off-by: David Ahern 
Acked-by: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1383763297-27066-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-record.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 19c4db6..15280b5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -74,7 +74,6 @@ struct perf_record {
boolno_buildid;
boolno_buildid_cache;
longsamples;
-   off_t   post_processing_offset;
 };
 
 static int write_output(struct perf_record *rec, void *buf, size_t size)
@@ -247,13 +246,14 @@ static int process_buildids(struct perf_record *rec)
 {
struct perf_data_file *file  = &rec->file;
struct perf_session *session = rec->session;
+   u64 start = session->header.data_offset;
 
u64 size = lseek(file->fd, 0, SEEK_CUR);
if (size == 0)
return 0;
 
-   return __perf_session__process_events(session, 
rec->post_processing_offset,
- size - 
rec->post_processing_offset,
+   return __perf_session__process_events(session, start,
+ size - start,
  size, 
&build_id__mark_dso_hit_ops);
 }
 
@@ -429,8 +429,6 @@ static int __cmd_record(struct perf_record *rec, int argc, 
const char **argv)
goto out_delete_session;
}
 
-   rec->post_processing_offset = lseek(file->fd, 0, SEEK_CUR);
-
machine = &session->machines.host;
 
if (file->is_pipe) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf record: Remove advance_output function

2013-11-07 Thread tip-bot for David Ahern
Commit-ID:  f34b9001f9a2f6fa41d3582fe515d194cc86bfb2
Gitweb: http://git.kernel.org/tip/f34b9001f9a2f6fa41d3582fe515d194cc86bfb2
Author: David Ahern 
AuthorDate: Wed, 6 Nov 2013 11:41:35 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 7 Nov 2013 10:43:15 -0300

perf record: Remove advance_output function

1 line function with only 1 user; might as well embed directly.

Signed-off-by: David Ahern 
Suggested-by: Ingo Molnar 
Acked-by: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1383763297-27066-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-record.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2932069..19c4db6 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -77,11 +77,6 @@ struct perf_record {
off_t   post_processing_offset;
 };
 
-static void advance_output(struct perf_record *rec, size_t size)
-{
-   rec->bytes_written += size;
-}
-
 static int write_output(struct perf_record *rec, void *buf, size_t size)
 {
struct perf_data_file *file = &rec->file;
@@ -461,7 +456,7 @@ static int __cmd_record(struct perf_record *rec, int argc, 
const char **argv)
pr_err("Couldn't record tracing data.\n");
goto out_delete_session;
}
-   advance_output(rec, err);
+   rec->bytes_written += err;
}
}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Fix version when building out of tree

2013-11-07 Thread tip-bot for David Ahern
Commit-ID:  a614d01bdd0cc8200d917da25f5a3d539b944193
Gitweb: http://git.kernel.org/tip/a614d01bdd0cc8200d917da25f5a3d539b944193
Author: David Ahern 
AuthorDate: Wed, 6 Nov 2013 08:55:35 -0700
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 7 Nov 2013 10:40:47 -0300

perf tools: Fix version when building out of tree

When building perf out of tree:

  $ make perf-tar-src-pkg
  $ tar -xf perf-.tar -C /tmp
  $ cd /tmp/perf
  $ make -C tools/perf

you get this warning message:
make[1]: *** No rule to make target `kernelversion'.  Stop.

Fix it by saving the perf version in the tar file and using that for the
out of tree builds.

v2: removed short form request and fixed up version string from usual output.

Signed-off-by: David Ahern 
Suggested-by: Ingo Molnar 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1383753335-25782-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 scripts/package/Makefile | 4 +++-
 tools/perf/util/PERF-VERSION-GEN | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index a4f31c9..c5d4733 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -115,7 +115,9 @@ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ 
\
-o $(perf-tar).tar; \
 mkdir -p $(perf-tar);   \
 git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD;\
-tar rf $(perf-tar).tar $(perf-tar)/HEAD;\
+(cd $(srctree)/tools/perf;  \
+util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null);  \
+tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
 rm -r $(perf-tar);  \
 $(if $(findstring tar-src,$@),, \
 $(if $(findstring bz2,$@),bzip2,\
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
index ce7a804..39f1750 100755
--- a/tools/perf/util/PERF-VERSION-GEN
+++ b/tools/perf/util/PERF-VERSION-GEN
@@ -19,6 +19,9 @@ if test -d ../../.git -o -f ../../.git
 then
TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && 
CID="-g$CID"
+elif test -f ../../PERF-VERSION-FILE
+then
+   TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
 fi
 if test -z "$TAG"
 then
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf list: Remove a level of indentation

2013-11-05 Thread tip-bot for David Ahern
Commit-ID:  8e00ddc9dfe09ee131144fdaf6c96ebe95cb
Gitweb: http://git.kernel.org/tip/8e00ddc9dfe09ee131144fdaf6c96ebe95cb
Author: David Ahern 
AuthorDate: Wed, 30 Oct 2013 10:15:06 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 5 Nov 2013 14:25:26 -0300

perf list: Remove a level of indentation

With a return after the if check an indentation level can be removed.
Indentation shift only; no functional changes.

Signed-off-by: David Ahern 
Acked-by: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1383149707-1008-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-list.c | 73 ---
 1 file changed, 37 insertions(+), 36 deletions(-)

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index e79f423..45000e7 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -17,48 +17,49 @@
 
 int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 {
+   int i;
+
setup_pager();
 
-   if (argc == 1)
+   if (argc == 1) {
print_events(NULL, false);
-   else {
-   int i;
-
-   for (i = 1; i < argc; ++i) {
-   if (i > 2)
-   putchar('\n');
-   if (strncmp(argv[i], "tracepoint", 10) == 0)
-   print_tracepoint_events(NULL, NULL, false);
-   else if (strcmp(argv[i], "hw") == 0 ||
-strcmp(argv[i], "hardware") == 0)
-   print_events_type(PERF_TYPE_HARDWARE);
-   else if (strcmp(argv[i], "sw") == 0 ||
-strcmp(argv[i], "software") == 0)
-   print_events_type(PERF_TYPE_SOFTWARE);
-   else if (strcmp(argv[i], "cache") == 0 ||
-strcmp(argv[i], "hwcache") == 0)
-   print_hwcache_events(NULL, false);
-   else if (strcmp(argv[i], "pmu") == 0)
-   print_pmu_events(NULL, false);
-   else if (strcmp(argv[i], "--raw-dump") == 0)
-   print_events(NULL, true);
-   else {
-   char *sep = strchr(argv[i], ':'), *s;
-   int sep_idx;
+   return 0;
+   }
 
-   if (sep == NULL) {
-   print_events(argv[i], false);
-   continue;
-   }
-   sep_idx = sep - argv[i];
-   s = strdup(argv[i]);
-   if (s == NULL)
-   return -1;
+   for (i = 1; i < argc; ++i) {
+   if (i > 2)
+   putchar('\n');
+   if (strncmp(argv[i], "tracepoint", 10) == 0)
+   print_tracepoint_events(NULL, NULL, false);
+   else if (strcmp(argv[i], "hw") == 0 ||
+strcmp(argv[i], "hardware") == 0)
+   print_events_type(PERF_TYPE_HARDWARE);
+   else if (strcmp(argv[i], "sw") == 0 ||
+strcmp(argv[i], "software") == 0)
+   print_events_type(PERF_TYPE_SOFTWARE);
+   else if (strcmp(argv[i], "cache") == 0 ||
+strcmp(argv[i], "hwcache") == 0)
+   print_hwcache_events(NULL, false);
+   else if (strcmp(argv[i], "pmu") == 0)
+   print_pmu_events(NULL, false);
+   else if (strcmp(argv[i], "--raw-dump") == 0)
+   print_events(NULL, true);
+   else {
+   char *sep = strchr(argv[i], ':'), *s;
+   int sep_idx;
 
-   s[sep_idx] = '\0';
-   print_tracepoint_events(s, s + sep_idx + 1, 
false);
-   free(s);
+   if (sep == NULL) {
+   print_events(argv[i], false);
+   continue;
}
+   sep_idx = sep - argv[i];
+   s = strdup(argv[i]);
+   if (s == NULL)
+   return -1;
+
+   s[sep_idx] = '\0';
+   print_tracepoint_events(s, s + sep_idx + 1, false);
+   free(s);
}
}
return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majo

[tip:perf/core] tools/perf/build: Fix detection of non-core features

2013-11-05 Thread tip-bot for David Ahern
Commit-ID:  5febff0066b8111785d58903b54d414e9ec6a3d0
Gitweb: http://git.kernel.org/tip/5febff0066b8111785d58903b54d414e9ec6a3d0
Author: David Ahern 
AuthorDate: Tue, 29 Oct 2013 10:43:15 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 5 Nov 2013 10:08:03 -0300

tools/perf/build: Fix detection of non-core features

feature_check needs to be invoked through call, and LDFLAGS may not be
set so quotes are needed.

Thanks to Jiri for spotting the quotes around LDFLAGS; that one was
driving me nuts with the upcoming timerfd feature detection.

Signed-off-by: David Ahern 
Reviewed-by: Jiri Olsa 
Tested-by: Jiri Olsa 
Acked-by: Ingo Molnar 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1383064996-20933-1-git-send-email-dsah...@gmail.com
[ Fixed conflict with 8a0c4c2843d3 ("perf tools: Fix libunwind build and 
feature detection for 32-bit build") ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/config/Makefile | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index be8bb9a..58b2d37 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -98,7 +98,7 @@ endif
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) 
CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" 
-C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) 
CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS="$(LDFLAGS)" 
LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 
2>/dev/null && echo 1 || echo 0)
 endef
 
 feature_set = $(eval $(feature_set_code))
@@ -235,7 +235,7 @@ CFLAGS += -I$(LIB_INCLUDE)
 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
 
 ifndef NO_BIONIC
-  $(feature_check,bionic)
+  $(call feature_check,bionic)
   ifeq ($(feature-bionic), 1)
 BIONIC := 1
 EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
@@ -479,15 +479,15 @@ else
 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
   else
 ifneq ($(feature-libbfd), 1)
-  $(feature_check,liberty)
+  $(call feature_check,liberty)
   ifeq ($(feature-liberty), 1)
 EXTLIBS += -lbfd -liberty
   else
-$(feature_check,liberty-z)
+$(call feature_check,liberty-z)
 ifeq ($(feature-liberty-z), 1)
   EXTLIBS += -lbfd -liberty -lz
 else
-  $(feature_check,cplus-demangle)
+  $(call feature_check,cplus-demangle)
   ifeq ($(feature-cplus-demangle), 1)
 EXTLIBS += -liberty
 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf list: Add usage

2013-11-05 Thread tip-bot for David Ahern
Commit-ID:  44d742e01e6d3dd544ee1873b660a3c8bc1413bb
Gitweb: http://git.kernel.org/tip/44d742e01e6d3dd544ee1873b660a3c8bc1413bb
Author: David Ahern 
AuthorDate: Wed, 30 Oct 2013 10:28:29 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 5 Nov 2013 14:26:41 -0300

perf list: Add usage

Currently 'perf list' is not very helpful if you forget the syntax:

  $ perf list -h

  List of pre-defined events (to be used in -e):

After:
  $ perf list -h

   usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]

Signed-off-by: David Ahern 
Acked-by: Ingo Molnar 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/527133ad.4030...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-list.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 45000e7..011195e 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -14,20 +14,31 @@
 #include "util/parse-events.h"
 #include "util/cache.h"
 #include "util/pmu.h"
+#include "util/parse-options.h"
 
 int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 {
int i;
+   const struct option list_options[] = {
+   OPT_END()
+   };
+   const char * const list_usage[] = {
+   "perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
+   NULL
+   };
+
+   argc = parse_options(argc, argv, list_options, list_usage,
+PARSE_OPT_STOP_AT_NON_OPTION);
 
setup_pager();
 
-   if (argc == 1) {
+   if (argc == 0) {
print_events(NULL, false);
return 0;
}
 
-   for (i = 1; i < argc; ++i) {
-   if (i > 2)
+   for (i = 0; i < argc; ++i) {
+   if (i)
putchar('\n');
if (strncmp(argv[i], "tracepoint", 10) == 0)
print_tracepoint_events(NULL, NULL, false);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf kvm: Disable live command if timerfd is not supported

2013-11-05 Thread tip-bot for David Ahern
Commit-ID:  87419c9afff1431d4b62b388baf6bfa07e0b14ff
Gitweb: http://git.kernel.org/tip/87419c9afff1431d4b62b388baf6bfa07e0b14ff
Author: David Ahern 
AuthorDate: Tue, 29 Oct 2013 10:43:16 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 5 Nov 2013 10:03:22 -0300

perf kvm: Disable live command if timerfd is not supported

If the OS does not have timerfd support (e.g., older OS'es like RHEL5)
disable perf kvm stat live.

Signed-off-by: David Ahern 
Reviewed-by: Jiri Olsa 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1383064996-20933-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kvm.c| 12 
 tools/perf/config/Makefile  |  7 +++
 tools/perf/config/feature-checks/Makefile   |  6 +-
 tools/perf/config/feature-checks/test-all.c |  5 +
 tools/perf/config/feature-checks/test-timerfd.c | 18 ++
 5 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index cb05f39..cd9f920 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -20,7 +20,9 @@
 #include "util/data.h"
 
 #include 
+#ifdef HAVE_TIMERFD_SUPPORT
 #include 
+#endif
 
 #include 
 #include 
@@ -337,6 +339,7 @@ static void init_kvm_event_record(struct perf_kvm_stat *kvm)
INIT_LIST_HEAD(&kvm->kvm_events_cache[i]);
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 static void clear_events_cache_stats(struct list_head *kvm_events_cache)
 {
struct list_head *head;
@@ -358,6 +361,7 @@ static void clear_events_cache_stats(struct list_head 
*kvm_events_cache)
}
}
 }
+#endif
 
 static int kvm_events_hash_fn(u64 key)
 {
@@ -783,6 +787,7 @@ static void print_result(struct perf_kvm_stat *kvm)
pr_info("\nLost events: %" PRIu64 "\n\n", kvm->lost_events);
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 static int process_lost_event(struct perf_tool *tool,
  union perf_event *event __maybe_unused,
  struct perf_sample *sample __maybe_unused,
@@ -793,6 +798,7 @@ static int process_lost_event(struct perf_tool *tool,
kvm->lost_events++;
return 0;
 }
+#endif
 
 static bool skip_sample(struct perf_kvm_stat *kvm,
struct perf_sample *sample)
@@ -872,6 +878,7 @@ static bool verify_vcpu(int vcpu)
return true;
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 /* keeping the max events to a modest level to keep
  * the processing of samples per mmap smooth.
  */
@@ -1213,6 +1220,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
 out:
return rc;
 }
+#endif
 
 static int read_events(struct perf_kvm_stat *kvm)
 {
@@ -1379,6 +1387,7 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, 
const char **argv)
return kvm_events_report_vcpu(kvm);
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 static struct perf_evlist *kvm_live_event_list(void)
 {
struct perf_evlist *evlist;
@@ -1566,6 +1575,7 @@ out:
 
return err;
 }
+#endif
 
 static void print_kvm_stat_usage(void)
 {
@@ -1604,8 +1614,10 @@ static int kvm_cmd_stat(const char *file_name, int argc, 
const char **argv)
if (!strncmp(argv[1], "rep", 3))
return kvm_events_report(&kvm, argc - 1 , argv + 1);
 
+#ifdef HAVE_TIMERFD_SUPPORT
if (!strncmp(argv[1], "live", 4))
return kvm_events_live(&kvm, argc - 1 , argv + 1);
+#endif
 
 perf_stat:
return cmd_stat(argc, argv, NULL);
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index ffb5f55..be8bb9a 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -397,6 +397,13 @@ else
   endif
 endif
 
+$(call feature_check,timerfd)
+ifeq ($(feature-timerfd), 1)
+  CFLAGS += -DHAVE_TIMERFD_SUPPORT
+else
+  msg := $(warning No timerfd support. Disables 'perf kvm stat live');
+endif
+
 disable-python = $(eval $(disable-python_code))
 define disable-python_code
   CFLAGS += -DNO_LIBPYTHON
diff --git a/tools/perf/config/feature-checks/Makefile 
b/tools/perf/config/feature-checks/Makefile
index d37d58d..c803f17 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -25,7 +25,8 @@ FILES=\
test-libunwind  \
test-on-exit\
test-stackprotector-all \
-   test-stackprotector
+   test-stackprotector \
+   test-timerfd
 
 CC := $(CC) -MD
 
@@ -136,6 +137,9 @@ test-on-exit:
 test-backtrace:
$(BUILD)
 
+test-timerfd:
+   $(BUILD)
+
 -include *.d
 
 ###
diff --git a/tools/perf/config/feature-checks/test-all.c 
b/tools/perf/config/feature-checks/test-all.c
index 50d4318..59e7a70 100644
--- a/tools/perf/config/feature-checks/test-all.c
+++ b/tools/perf/config/feat

[tip:perf/core] perf trace: Add option to show full timestamp

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  4bb09192d38ef08f0619667527cabb26354fff89
Gitweb: http://git.kernel.org/tip/4bb09192d38ef08f0619667527cabb26354fff89
Author: David Ahern 
AuthorDate: Wed, 4 Sep 2013 12:37:43 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Oct 2013 11:10:49 -0300

perf trace: Add option to show full timestamp

Current timestamp shown for output is time relative to firt sample. This
patch adds an option to show the absolute perf_clock timestamp which is
useful when comparing output across commands (e.g., perf-trace to
perf-script).

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1378319865-55695-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-trace.txt | 4 
 tools/perf/builtin-trace.c  | 7 +--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index daccd2c..a93e91a 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -78,6 +78,10 @@ the thread executes on the designated CPUs. Default is to 
monitor all CPUs.
 --input
Process events from a given perf data file.
 
+-T
+--time
+   Print full timestamp rather time relative to first sample.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-script[1]
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 7ce036e..bc21140 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -624,6 +624,7 @@ struct trace {
struct perf_record_opts opts;
struct machine  host;
u64 base_time;
+   boolfull_time;
FILE*output;
unsigned long   nr_events;
struct strlist  *ev_qualifier;
@@ -1066,7 +1067,7 @@ static int trace__process_sample(struct perf_tool *tool,
if (skip_sample(trace, sample))
return 0;
 
-   if (trace->base_time == 0)
+   if (!trace->full_time && trace->base_time == 0)
trace->base_time = sample->time;
 
if (handler)
@@ -1195,7 +1196,7 @@ again:
continue;
}
 
-   if (trace->base_time == 0)
+   if (!trace->full_time && trace->base_time == 0)
trace->base_time = sample.time;
 
if (type != PERF_RECORD_SAMPLE) {
@@ -1433,6 +1434,8 @@ int cmd_trace(int argc, const char **argv, const char 
*prefix __maybe_unused)
 trace__set_duration),
OPT_BOOLEAN(0, "sched", &trace.sched, "show blocking scheduler events"),
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
+   OPT_BOOLEAN('T', "time", &trace.full_time,
+   "Show full timestamp, not time relative to first start"),
OPT_END()
};
int err;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Remove duplicate mmap entry in syscall_fmts array

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  770480592084d2c114adedfbe6740e345aaf2279
Gitweb: http://git.kernel.org/tip/770480592084d2c114adedfbe6740e345aaf2279
Author: David Ahern 
AuthorDate: Wed, 4 Sep 2013 12:37:44 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Oct 2013 11:10:56 -0300

perf trace: Remove duplicate mmap entry in syscall_fmts array

Entries in syscall_fmts need to be in alphabetical order, and the
duplicate entry breaks bsearch on new entries around this duplicate
entry.

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1378319865-55695-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index bc21140..903416c 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -461,7 +461,6 @@ static struct syscall_fmt {
{ .name = "arch_prctl", .errmsg = true, .alias = "prctl", },
{ .name = "brk",.hexret = true,
  .arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, },
-   { .name = "mmap",   .hexret = true, },
{ .name = "connect",.errmsg = true, },
{ .name = "fcntl",  .errmsg = true,
  .arg_scnprintf = { [1] = SCA_STRARRAY, /* cmd */ },
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Fix comm resolution when reading events from file

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  8fb598e5a3b0ac213012e8461a309843ba0f2e74
Gitweb: http://git.kernel.org/tip/8fb598e5a3b0ac213012e8461a309843ba0f2e74
Author: David Ahern 
AuthorDate: Sat, 28 Sep 2013 13:13:00 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:48 -0300

perf trace: Fix comm resolution when reading events from file

Task comm's are getting lost when processing events from a file. The
problem is that the trace struct used by the live processing has its
host machine and the perf-session used for file based processing has its
host machine.  Fix by having both references point to the same machine.

Before:

 0.030 ( 0.001 ms): :27743/27743 brk( ...
 0.057 ( 0.004 ms): :27743/27743 mmap(len: 4096, prot: READ|WRITE, flags: 
...
 0.075 ( 0.006 ms): :27743/27743 access(filename: 0x7f3809fbce00, mode: R 
...
 0.091 ( 0.005 ms): :27743/27743 open(filename: 0x7f3809fba14c, flags: 
CLOEXEC ...
...

After:
 0.030 ( 0.001 ms): make/27743 brk( ...
 0.057 ( 0.004 ms): make/27743 mmap(len: 4096, prot: READ|WRITE, flags: ...
 0.075 ( 0.006 ms): make/27743 access(filename: 0x7f3809fbce00, mode: R ...
 0.091 ( 0.005 ms): make/27743 open(filename: 0x7f3809fba14c, flags: 
CLOEXEC ...
...

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1380395584-9025-4-git-send-email-dsah...@gmail.com
[ Moved creation of new host machine to a separate constructor: 
machine__new_host() ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 25 +
 tools/perf/util/machine.c  | 17 +
 tools/perf/util/machine.h  |  1 +
 3 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index fcc157f..5776b5f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -906,7 +906,7 @@ struct trace {
struct syscall  *table;
} syscalls;
struct perf_record_opts opts;
-   struct machine  host;
+   struct machine  *host;
u64 base_time;
boolfull_time;
FILE*output;
@@ -1083,16 +1083,17 @@ static int trace__symbols_init(struct trace *trace, 
struct perf_evlist *evlist)
if (err)
return err;
 
-   machine__init(&trace->host, "", HOST_KERNEL_ID);
-   machine__create_kernel_maps(&trace->host);
+   trace->host = machine__new_host();
+   if (trace->host == NULL)
+   return -ENOMEM;
 
if (perf_target__has_task(&trace->opts.target)) {
err = perf_event__synthesize_thread_map(&trace->tool, 
evlist->threads,
trace__tool_process,
-   &trace->host);
+   trace->host);
} else {
err = perf_event__synthesize_threads(&trace->tool, 
trace__tool_process,
-&trace->host);
+trace->host);
}
 
if (err)
@@ -1304,8 +1305,7 @@ static int trace__sys_enter(struct trace *trace, struct 
perf_evsel *evsel,
if (sc->filtered)
return 0;
 
-   thread = machine__findnew_thread(&trace->host, sample->pid,
-sample->tid);
+   thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
ttrace = thread__trace(thread, trace->output);
if (ttrace == NULL)
return -1;
@@ -1357,8 +1357,7 @@ static int trace__sys_exit(struct trace *trace, struct 
perf_evsel *evsel,
if (sc->filtered)
return 0;
 
-   thread = machine__findnew_thread(&trace->host, sample->pid,
-sample->tid);
+   thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
ttrace = thread__trace(thread, trace->output);
if (ttrace == NULL)
return -1;
@@ -1414,7 +1413,7 @@ static int trace__sched_stat_runtime(struct trace *trace, 
struct perf_evsel *evs
 {
 u64 runtime = perf_evsel__intval(evsel, sample, "runtime");
double runtime_ms = (double)runtime / NSEC_PER_MSEC;
-   struct thread *thread = machine__findnew_thread(&trace->host,
+   struct thread *thread = machine__findnew_thread(trace->host,
sample->pid,
sample->tid);
struct thread_trace *ttrace = thread__trace(thread, trace->output);
@@ -1597,7 +1596,7 @@ again:
trace->base_time = sample.time;
 
if (type != PERF_RECORD_SAMPLE) {
-

[tip:perf/core] perf stat: Fix misleading message when specifying cpu list or system wide

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  62d3b617c02785a4f1fbde8d93ca77a0b33d8454
Gitweb: http://git.kernel.org/tip/62d3b617c02785a4f1fbde8d93ca77a0b33d8454
Author: David Ahern 
AuthorDate: Sat, 28 Sep 2013 14:27:58 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:42 -0300

perf stat: Fix misleading message when specifying cpu list or system wide

The "perf stat" tool displays the command run in its summary output
which is misleading when using a cpu list or system wide collection.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

16152.670249 task-clock#   16.132 CPUs utilized
 417 context-switches  #0.002 M/sec
   7 cpu-migrations#0.030 K/sec
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

16206.931120 task-clock#   16.144 CPUs utilized
 395 context-switches  #0.002 M/sec
   5 cpu-migrations#0.030 K/sec
...

or

perf stat -C1 -- sleep 1

 Performance counter stats for 'CPU(s) 1':

   1001.669257 task-clock#1.000 CPUs utilized
 4,264 context-switches  #0.004 M/sec
 3 cpu-migrations#0.003 K/sec
...

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1380400080-9211-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index fb02b53..c8a2662 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1229,7 +1229,11 @@ static void print_stat(int argc, const char **argv)
if (!csv_output) {
fprintf(output, "\n");
fprintf(output, " Performance counter stats for ");
-   if (!perf_target__has_task(&target)) {
+   if (target.system_wide)
+   fprintf(output, "\'system wide");
+   else if (target.cpu_list)
+   fprintf(output, "\'CPU(s) %s", target.cpu_list);
+   else if (!perf_target__has_task(&target)) {
fprintf(output, "\'%s", argv[0]);
for (i = 1; i < argc; i++)
fprintf(output, " %s", argv[i]);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Fix old GCC build error in ' get_srcline'

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  a949fffb84df6f9be136198a00f796a9dc696bd0
Gitweb: http://git.kernel.org/tip/a949fffb84df6f9be136198a00f796a9dc696bd0
Author: David Ahern 
AuthorDate: Wed, 9 Oct 2013 21:51:31 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 14 Oct 2013 10:28:52 -0300

perf tools: Fix old GCC build error in 'get_srcline'

trace-event-parse.c:parse_proc_kallsyms()

Old GCC (4.4.2) does not see through the code flow of get_srcline() and
gets confused about the status of 'file' and 'line':

CC   /tmp/build/perf/util/srcline.o
  cc1: warnings being treated as errors
  util/srcline.c: In function ¿get_srcline¿:
  util/srcline.c:226: error: ¿file¿ may be used uninitialized in this function
  util/srcline.c:227: error: ¿line¿ may be used uninitialized in this function
  make[1]: *** [/tmp/build/perf/util/srcline.o] Error 1
  make: *** [install] Error 2
  make: Leaving directory `/home/acme/git/linux/tools/perf'
  [acme@fedora12 linux]$

Help out GCC by initializing 'file' and 'line'.

Signed-off-by: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/n/tip-h8k7h49z3cndqgjdftkmm...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/srcline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 3735319..d11aefb 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -223,8 +223,8 @@ out:
 
 char *get_srcline(struct dso *dso, unsigned long addr)
 {
-   char *file;
-   unsigned line;
+   char *file = NULL;
+   unsigned line = 0;
char *srcline;
char *dso_name = dso->long_name;
size_t size;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf util: Add findnew method to intlist

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  813335b8b27d9ceeb67a073f501ada8b8dde37a7
Gitweb: http://git.kernel.org/tip/813335b8b27d9ceeb67a073f501ada8b8dde37a7
Author: David Ahern 
AuthorDate: Tue, 8 Oct 2013 21:26:52 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 14 Oct 2013 10:28:48 -0300

perf util: Add findnew method to intlist

Similar to other findnew based methods if the requested object is not
found, add it to the list.

v2: followed format of other findnew methods per acme's request

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1381289214-24885-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/intlist.c | 22 ++
 tools/perf/util/intlist.h |  1 +
 tools/perf/util/rblist.c  | 27 ---
 tools/perf/util/rblist.h  |  1 +
 4 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/intlist.c b/tools/perf/util/intlist.c
index 826d7b3..89715b6 100644
--- a/tools/perf/util/intlist.c
+++ b/tools/perf/util/intlist.c
@@ -58,22 +58,36 @@ void intlist__remove(struct intlist *ilist, struct int_node 
*node)
rblist__remove_node(&ilist->rblist, &node->rb_node);
 }
 
-struct int_node *intlist__find(struct intlist *ilist, int i)
+static struct int_node *__intlist__findnew(struct intlist *ilist,
+  int i, bool create)
 {
-   struct int_node *node;
+   struct int_node *node = NULL;
struct rb_node *rb_node;
 
if (ilist == NULL)
return NULL;
 
-   node = NULL;
-   rb_node = rblist__find(&ilist->rblist, (void *)((long)i));
+   if (create)
+   rb_node = rblist__findnew(&ilist->rblist, (void *)((long)i));
+   else
+   rb_node = rblist__find(&ilist->rblist, (void *)((long)i));
+
if (rb_node)
node = container_of(rb_node, struct int_node, rb_node);
 
return node;
 }
 
+struct int_node *intlist__find(struct intlist *ilist, int i)
+{
+   return __intlist__findnew(ilist, i, false);
+}
+
+struct int_node *intlist__findnew(struct intlist *ilist, int i)
+{
+   return __intlist__findnew(ilist, i, true);
+}
+
 static int intlist__parse_list(struct intlist *ilist, const char *s)
 {
char *sep;
diff --git a/tools/perf/util/intlist.h b/tools/perf/util/intlist.h
index 0eb00ac..aa6877d 100644
--- a/tools/perf/util/intlist.h
+++ b/tools/perf/util/intlist.h
@@ -24,6 +24,7 @@ int intlist__add(struct intlist *ilist, int i);
 
 struct int_node *intlist__entry(const struct intlist *ilist, unsigned int idx);
 struct int_node *intlist__find(struct intlist *ilist, int i);
+struct int_node *intlist__findnew(struct intlist *ilist, int i);
 
 static inline bool intlist__has_entry(struct intlist *ilist, int i)
 {
diff --git a/tools/perf/util/rblist.c b/tools/perf/util/rblist.c
index a16cdd2..0dfe27d 100644
--- a/tools/perf/util/rblist.c
+++ b/tools/perf/util/rblist.c
@@ -48,10 +48,12 @@ void rblist__remove_node(struct rblist *rblist, struct 
rb_node *rb_node)
rblist->node_delete(rblist, rb_node);
 }
 
-struct rb_node *rblist__find(struct rblist *rblist, const void *entry)
+static struct rb_node *__rblist__findnew(struct rblist *rblist,
+const void *entry,
+bool create)
 {
struct rb_node **p = &rblist->entries.rb_node;
-   struct rb_node *parent = NULL;
+   struct rb_node *parent = NULL, *new_node = NULL;
 
while (*p != NULL) {
int rc;
@@ -67,7 +69,26 @@ struct rb_node *rblist__find(struct rblist *rblist, const 
void *entry)
return parent;
}
 
-   return NULL;
+   if (create) {
+   new_node = rblist->node_new(rblist, entry);
+   if (new_node) {
+   rb_link_node(new_node, parent, p);
+   rb_insert_color(new_node, &rblist->entries);
+   ++rblist->nr_entries;
+   }
+   }
+
+   return new_node;
+}
+
+struct rb_node *rblist__find(struct rblist *rblist, const void *entry)
+{
+   return __rblist__findnew(rblist, entry, false);
+}
+
+struct rb_node *rblist__findnew(struct rblist *rblist, const void *entry)
+{
+   return __rblist__findnew(rblist, entry, true);
 }
 
 void rblist__init(struct rblist *rblist)
diff --git a/tools/perf/util/rblist.h b/tools/perf/util/rblist.h
index 6d0cae5..ff9913b 100644
--- a/tools/perf/util/rblist.h
+++ b/tools/perf/util/rblist.h
@@ -32,6 +32,7 @@ void rblist__delete(struct rblist *rblist);
 int rblist__add_node(struct rblist *rblist, const void *new_entry);
 void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node);
 struct rb_node *rblist__find(struct rblist *rblist, const void *entry);
+struct rb_node *rblist__findnew(struct rblist *rblist, c

[tip:perf/core] perf trace: Add summary option to dump syscall statistics

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  bf2575c121ca11247ef07fd02b43f7430834f7b1
Gitweb: http://git.kernel.org/tip/bf2575c121ca11247ef07fd02b43f7430834f7b1
Author: David Ahern 
AuthorDate: Tue, 8 Oct 2013 21:26:53 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 14 Oct 2013 10:28:50 -0300

perf trace: Add summary option to dump syscall statistics

When enabled dumps a summary of all syscalls by task with the usual
statistics -- min, max, average and relative stddev. For example,

make - 26341 :   3344   [ 17.4% ]  0.000 ms

read :   520.000 4.802 0.644   30.08
   write :   200.004 0.036 0.010   21.72
open :   240.003 0.046 0.014   23.68
   close :   640.002 0.055 0.008   22.53
stat : 27140.002 0.222 0.0044.47
   fstat :   180.001 0.041 0.006   46.26
mmap :   300.003 0.009 0.0065.71
mprotect :80.006 0.039 0.016   32.16
  munmap :   120.007 0.077 0.020   38.25
 brk :   480.002 0.014 0.004   10.18
rt_sigaction :   180.002 0.002 0.0022.11
  rt_sigprocmask :   600.002 0.128 0.010   32.88
  access :20.006 0.006 0.0060.00
pipe :   120.004 0.048 0.013   35.98
   vfork :   340.448 0.980 0.6923.04
  execve :   200.000 0.387 0.046   56.66
   wait4 :   340.017  9923.287   593.221   68.45
   fcntl :80.001 0.041 0.013   48.79
getdents :   480.002 0.079 0.013   19.62
  getcwd :20.005 0.005 0.0050.00
   chdir :20.070 0.070 0.0700.00
   getrlimit :20.045 0.045 0.0450.00
  arch_prctl :20.002 0.002 0.0020.00
   setrlimit :20.002 0.002 0.0020.00
  openat :   940.003 0.005 0.0032.11

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1381289214-24885-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-trace.txt |   4 ++
 tools/perf/builtin-trace.c  | 110 
 2 files changed, 102 insertions(+), 12 deletions(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index 1a22486..54139c6 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -93,6 +93,10 @@ the thread executes on the designated CPUs. Default is to 
monitor all CPUs.
 --comm::
 Show process COMM right beside its ID, on by default, disable with 
--no-comm.
 
+--summary::
+   Show a summary of syscalls by thread with min, max, and average times 
(in
+msec) and relative stddev.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-script[1]
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 5496546..d0f91fe 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -10,6 +10,7 @@
 #include "util/strlist.h"
 #include "util/intlist.h"
 #include "util/thread_map.h"
+#include "util/stat.h"
 
 #include 
 #include 
@@ -909,6 +910,8 @@ struct thread_trace {
int   max;
char  **table;
} paths;
+
+   struct intlist *syscall_stats;
 };
 
 static struct thread_trace *thread_trace__new(void)
@@ -918,6 +921,8 @@ static struct thread_trace *thread_trace__new(void)
if (ttrace)
ttrace->paths.max = -1;
 
+   ttrace->syscall_stats = intlist__new(NULL);
+
return ttrace;
 }
 
@@ -964,6 +969,7 @@ struct trace {
struct intlist  *pid_list;
boolsched;
boolmultiple_threads;
+   boolsummary;
boolshow_comm;
double  duration_filter;
double  runtime_ms;
@@ -1291,10 +1297,8 @@ typedef int (*tracepoint_handler)(struct trace *trace, 
struct perf_evsel *evsel,
  struct perf_sample *sample);
 
 static struct syscall *trace__syscall_info(struct trace *trace,
-  struct perf_evsel *evsel,
-  struct perf_sample *sample)
+  struct perf_evsel *evsel, int id)
 {
-   int id = perf_evsel__intval(evsel, sample, "id");
 
if (id < 0) {
 
@@ -1335,6 +1339,32 @@ out_cant_read:
return NULL;
 }
 
+static void thread__update_stats(struct thread_trace *ttrace,
+

[tip:perf/core] perf trace: Use new machine method to loop over threads

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  896cbb56bfee6ad99e0ee1b8209dc678f1a49f5a
Gitweb: http://git.kernel.org/tip/896cbb56bfee6ad99e0ee1b8209dc678f1a49f5a
Author: David Ahern 
AuthorDate: Sat, 28 Sep 2013 13:12:59 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:53 -0300

perf trace: Use new machine method to loop over threads

Use the new machine method that loops over threads to dump summary data.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1380395584-9025-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 76 +-
 1 file changed, 48 insertions(+), 28 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 1e2368f..addc3e1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1751,37 +1751,57 @@ static size_t trace__fprintf_threads_header(FILE *fp)
return printed;
 }
 
+/* struct used to pass data to per-thread function */
+struct summary_data {
+   FILE *fp;
+   struct trace *trace;
+   size_t printed;
+};
+
+static int trace__fprintf_one_thread(struct thread *thread, void *priv)
+{
+   struct summary_data *data = priv;
+   FILE *fp = data->fp;
+   size_t printed = data->printed;
+   struct trace *trace = data->trace;
+   struct thread_trace *ttrace = thread->priv;
+   const char *color;
+   double ratio;
+
+   if (ttrace == NULL)
+   return 0;
+
+   ratio = (double)ttrace->nr_events / trace->nr_events * 100.0;
+
+   color = PERF_COLOR_NORMAL;
+   if (ratio > 50.0)
+   color = PERF_COLOR_RED;
+   else if (ratio > 25.0)
+   color = PERF_COLOR_GREEN;
+   else if (ratio > 5.0)
+   color = PERF_COLOR_YELLOW;
+
+   printed += color_fprintf(fp, color, "%20s", thread->comm);
+   printed += fprintf(fp, " - %-5d :%11lu   [", thread->tid, 
ttrace->nr_events);
+   printed += color_fprintf(fp, color, "%5.1f%%", ratio);
+   printed += fprintf(fp, " ] %10.3f ms\n", ttrace->runtime_ms);
+
+   data->printed += printed;
+
+   return 0;
+}
+
 static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
 {
-   size_t printed = trace__fprintf_threads_header(fp);
-   struct rb_node *nd;
-
-   for (nd = rb_first(&trace->host->threads); nd; nd = rb_next(nd)) {
-   struct thread *thread = rb_entry(nd, struct thread, rb_node);
-   struct thread_trace *ttrace = thread->priv;
-   const char *color;
-   double ratio;
-
-   if (ttrace == NULL)
-   continue;
-
-   ratio = (double)ttrace->nr_events / trace->nr_events * 100.0;
-
-   color = PERF_COLOR_NORMAL;
-   if (ratio > 50.0)
-   color = PERF_COLOR_RED;
-   else if (ratio > 25.0)
-   color = PERF_COLOR_GREEN;
-   else if (ratio > 5.0)
-   color = PERF_COLOR_YELLOW;
-
-   printed += color_fprintf(fp, color, "%20s", thread->comm);
-   printed += fprintf(fp, " - %-5d :%11lu   [", thread->tid, 
ttrace->nr_events);
-   printed += color_fprintf(fp, color, "%5.1f%%", ratio);
-   printed += fprintf(fp, " ] %10.3f ms\n", ttrace->runtime_ms);
-   }
+   struct summary_data data = {
+   .fp = fp,
+   .trace = trace
+   };
+   data.printed = trace__fprintf_threads_header(fp);
 
-   return printed;
+   machine__for_each_thread(trace->host, trace__fprintf_one_thread, &data);
+
+   return data.printed;
 }
 
 static int trace__set_duration(const struct option *opt, const char *str,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf stat: Add units to nanosec-based counters

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  4bbe5a61f29b13437a6a16467328d3bae8fce9e7
Gitweb: http://git.kernel.org/tip/4bbe5a61f29b13437a6a16467328d3bae8fce9e7
Author: David Ahern 
AuthorDate: Sat, 28 Sep 2013 14:28:00 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:46 -0300

perf stat: Add units to nanosec-based counters

Ingo pointed out that the task-clock counter should have the units
explicitly stated since it is not a counter.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

  16186.874834 task-clock  #   16.154 CPUs utilized
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

  16146.402138 task-clock (msec)   #   16.125 CPUs utilized
...

Reported-by: Ingo Molnar 
Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1380400080-9211-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2178e66..1a9c95d 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -706,10 +706,13 @@ static void nsec_printout(int cpu, int nr, struct 
perf_evsel *evsel, double avg)
 {
double msecs = avg / 1e6;
const char *fmt = csv_output ? "%.6f%s%s" : "%18.6f%s%-25s";
+   char name[25];
 
aggr_printout(evsel, cpu, nr);
 
-   fprintf(output, fmt, msecs, csv_sep, perf_evsel__name(evsel));
+   scnprintf(name, sizeof(name), "%s%s",
+ perf_evsel__name(evsel), csv_output ? "" : " (msec)");
+   fprintf(output, fmt, msecs, csv_sep, name);
 
if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf intlist: Add priv member

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  2969b12993ca7a8b9692048431e075a67815002d
Gitweb: http://git.kernel.org/tip/2969b12993ca7a8b9692048431e075a67815002d
Author: David Ahern 
AuthorDate: Sat, 28 Sep 2013 13:13:02 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:55 -0300

perf intlist: Add priv member

Allows commands to leverage intlist infrastructure for opaque
structures.

For example an upcoming perf-trace change will use this as a means of
tracking syscalls statistics by task.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1380395584-9025-6-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/intlist.c | 1 +
 tools/perf/util/intlist.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/tools/perf/util/intlist.c b/tools/perf/util/intlist.c
index 11a8d86..826d7b3 100644
--- a/tools/perf/util/intlist.c
+++ b/tools/perf/util/intlist.c
@@ -20,6 +20,7 @@ static struct rb_node *intlist__node_new(struct rblist 
*rblist __maybe_unused,
 
if (node != NULL) {
node->i = i;
+   node->priv = NULL;
rc = &node->rb_node;
}
 
diff --git a/tools/perf/util/intlist.h b/tools/perf/util/intlist.h
index 62351da..0eb00ac 100644
--- a/tools/perf/util/intlist.h
+++ b/tools/perf/util/intlist.h
@@ -9,6 +9,7 @@
 struct int_node {
struct rb_node rb_node;
int i;
+   void *priv;
 };
 
 struct intlist {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf machine: Add method to loop over threads and invoke handler

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  35feee19f9fda7447f51073b5be3f6d082b508f5
Gitweb: http://git.kernel.org/tip/35feee19f9fda7447f51073b5be3f6d082b508f5
Author: David Ahern 
AuthorDate: Sat, 28 Sep 2013 13:12:58 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:51 -0300

perf machine: Add method to loop over threads and invoke handler

Loop over all threads within a machine - including threads moved to the
dead threads list -- and invoked a function.

This allows commands to run some specific function on each thread (eg.,
dump statistics) yet hides how the threads are maintained within the
machine.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1380395584-9025-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/machine.c | 23 +++
 tools/perf/util/machine.h |  4 
 2 files changed, 27 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index fc14f9b..901397a 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1393,3 +1393,26 @@ int machine__resolve_callchain(struct machine *machine,
   sample);
 
 }
+
+int machine__for_each_thread(struct machine *machine,
+int (*fn)(struct thread *thread, void *p),
+void *priv)
+{
+   struct rb_node *nd;
+   struct thread *thread;
+   int rc = 0;
+
+   for (nd = rb_first(&machine->threads); nd; nd = rb_next(nd)) {
+   thread = rb_entry(nd, struct thread, rb_node);
+   rc = fn(thread, priv);
+   if (rc != 0)
+   return rc;
+   }
+
+   list_for_each_entry(thread, &machine->dead_threads, node) {
+   rc = fn(thread, priv);
+   if (rc != 0)
+   return rc;
+   }
+   return rc;
+}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 5150d5e..d44c09b 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -166,4 +166,8 @@ void machines__destroy_kernel_maps(struct machines 
*machines);
 
 size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
 
+int machine__for_each_thread(struct machine *machine,
+int (*fn)(struct thread *thread, void *p),
+void *priv);
+
 #endif /* __PERF_MACHINE_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Add record option

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  5e2485b1a2813faa6b80007c653f8bbbed9457ee
Gitweb: http://git.kernel.org/tip/5e2485b1a2813faa6b80007c653f8bbbed9457ee
Author: David Ahern 
AuthorDate: Sat, 28 Sep 2013 13:13:01 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:49 -0300

perf trace: Add record option

The record option is a convience alias to include the -e raw_syscalls:*
argument to perf-record. All other options are passed to perf-record's
handler. Resulting data file can be analyzed by perf-trace -i.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1380395584-9025-5-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-trace.txt | 12 +---
 tools/perf/builtin-trace.c  | 32 
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index 7f70d36..1a22486 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -9,6 +9,7 @@ SYNOPSIS
 
 [verse]
 'perf trace'
+'perf trace record'
 
 DESCRIPTION
 ---
@@ -16,9 +17,14 @@ This command will show the events associated with the 
target, initially
 syscalls, but other system events like pagefaults, task lifetime events,
 scheduling events, etc.
 
-Initially this is a live mode only tool, but eventually will work with
-perf.data files like the other tools, allowing a detached 'record' from
-analysis phases.
+This is a live mode tool in addition to working with perf.data files like
+the other perf tools. Files can be generated using the 'perf record' command
+but the session needs to include the raw_syscalls events (-e 'raw_syscalls:*').
+Alernatively, the 'perf trace record' can be used as a shortcut to
+automatically include the raw_syscalls events when writing events to a file.
+
+The following options apply to perf trace; options to perf trace record are
+found in the perf record man page.
 
 OPTIONS
 ---
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 5776b5f..1e2368f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1501,6 +1501,33 @@ static int parse_target_str(struct trace *trace)
return 0;
 }
 
+static int trace__record(int argc, const char **argv)
+{
+   unsigned int rec_argc, i, j;
+   const char **rec_argv;
+   const char * const record_args[] = {
+   "record",
+   "-R",
+   "-m", "1024",
+   "-c", "1",
+   "-e", "raw_syscalls:sys_enter,raw_syscalls:sys_exit",
+   };
+
+   rec_argc = ARRAY_SIZE(record_args) + argc;
+   rec_argv = calloc(rec_argc + 1, sizeof(char *));
+
+   if (rec_argv == NULL)
+   return -ENOMEM;
+
+   for (i = 0; i < ARRAY_SIZE(record_args); i++)
+   rec_argv[i] = record_args[i];
+
+   for (j = 0; j < (unsigned int)argc; j++, i++)
+   rec_argv[i] = argv[j];
+
+   return cmd_record(i, rec_argv, NULL);
+}
+
 static int trace__run(struct trace *trace, int argc, const char **argv)
 {
struct perf_evlist *evlist = perf_evlist__new();
@@ -1788,6 +1815,8 @@ int cmd_trace(int argc, const char **argv, const char 
*prefix __maybe_unused)
const char * const trace_usage[] = {
"perf trace [] []",
"perf trace [] --  []",
+   "perf trace record [] []",
+   "perf trace record [] --  []",
NULL
};
struct trace trace = {
@@ -1844,6 +1873,9 @@ int cmd_trace(int argc, const char **argv, const char 
*prefix __maybe_unused)
int err;
char bf[BUFSIZ];
 
+   if ((argc > 1) && (strcmp(argv[1], "record") == 0))
+   return trace__record(argc-2, &argv[2]);
+
argc = parse_options(argc, argv, trace_options, trace_usage, 0);
 
if (output_name != NULL) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf stat: Don' t require a workload when using system wide or CPU options

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  ac3063bd4725689f39d7a23fdfca2e034c73dcac
Gitweb: http://git.kernel.org/tip/ac3063bd4725689f39d7a23fdfca2e034c73dcac
Author: David Ahern 
AuthorDate: Mon, 30 Sep 2013 07:37:37 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 11 Oct 2013 12:17:44 -0300

perf stat: Don't require a workload when using system wide or CPU options

The "perf stat" command can do system wide counters or one or more cpus.
For these options do not require a workload to be specified.

v2: use perf_target__none per Namhyung's comment.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: http://lkml.kernel.org/r/52497f3c.9070...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c8a2662..2178e66 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1659,8 +1659,9 @@ int cmd_stat(int argc, const char **argv, const char 
*prefix __maybe_unused)
} else if (big_num_opt == 0) /* User passed --no-big-num */
big_num = false;
 
-   if (!argc && !perf_target__has_task(&target))
+   if (!argc && perf_target__none(&target))
usage_with_options(stat_usage, options);
+
if (run_count < 0) {
usage_with_options(stat_usage, options);
} else if (run_count == 0) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Handle MSG_WAITFORONE not defined

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  b6e8f8f4674be5a32f78027ec6e432f5ea33921e
Gitweb: http://git.kernel.org/tip/b6e8f8f4674be5a32f78027ec6e432f5ea33921e
Author: David Ahern 
AuthorDate: Sun, 22 Sep 2013 19:44:56 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Oct 2013 17:42:37 -0300

perf trace: Handle MSG_WAITFORONE not defined

Needed for compiles on Fedora 12 for example.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1379900700-5186-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 39a947a..3ca6a85 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -363,6 +363,9 @@ static size_t syscall_arg__scnprintf_socket_type(char *bf, 
size_t size,
 #ifndef MSG_PROBE
 #define MSG_PROBE   0x10
 #endif
+#ifndef MSG_WAITFORONE
+#define MSG_WAITFORONE 0x1
+#endif
 #ifndef MSG_SENDPAGE_NOTLAST
 #define MSG_SENDPAGE_NOTLAST 0x2
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Add beautifier for clock_gettime' s clk_id argument

2013-10-14 Thread tip-bot for David Ahern
Commit-ID:  4f8c1b74c5fdac35ee4480685d42030446724848
Gitweb: http://git.kernel.org/tip/4f8c1b74c5fdac35ee4480685d42030446724848
Author: David Ahern 
AuthorDate: Sun, 22 Sep 2013 19:45:00 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Oct 2013 17:41:42 -0300

perf trace: Add beautifier for clock_gettime's clk_id argument

Before:
0.030 ( 0.002 ms): 2571 clock_gettime(which_clock: 1, tp: 0x7f3b45729cd0 ) = 0

After:
0.030 ( 0.002 ms): 2571 clock_gettime(which_clock: MONOTONIC, tp: 
0x7f3b45729cd0 ) = 0

v2: Update to use the STRARRAY option

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1379900700-5186-6-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 76d9427..39a947a 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -297,6 +297,12 @@ static DEFINE_STRARRAY(rlimit_resources);
 static const char *sighow[] = { "BLOCK", "UNBLOCK", "SETMASK", };
 static DEFINE_STRARRAY(sighow);
 
+static const char *clockid[] = {
+   "REALTIME", "MONOTONIC", "PROCESS_CPUTIME_ID", "THREAD_CPUTIME_ID",
+   "MONOTONIC_RAW", "REALTIME_COARSE", "MONOTONIC_COARSE",
+};
+static DEFINE_STRARRAY(clockid);
+
 static const char *socket_families[] = {
"UNSPEC", "LOCAL", "INET", "AX25", "IPX", "APPLETALK", "NETROM",
"BRIDGE", "ATMPVC", "X25", "INET6", "ROSE", "DECnet", "NETBEUI",
@@ -603,6 +609,7 @@ static struct syscall_fmt {
{ .name = "arch_prctl", .errmsg = true, .alias = "prctl", },
{ .name = "brk",.hexret = true,
  .arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, },
+   { .name = "clock_gettime",  .errmsg = true, STRARRAY(0, clk_id, 
clockid), },
{ .name = "connect",.errmsg = true, },
{ .name = "epoll_ctl",  .errmsg = true, STRARRAY(1, op, 
epoll_ctl_ops), },
{ .name = "eventfd2",   .errmsg = true,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf tools: Add default handler for mmap2 events

2013-10-08 Thread tip-bot for David Ahern
Commit-ID:  6adb0b0ae26fcc35cfec068d71f13863faac5b44
Gitweb: http://git.kernel.org/tip/6adb0b0ae26fcc35cfec068d71f13863faac5b44
Author: David Ahern 
AuthorDate: Sun, 22 Sep 2013 19:44:59 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 4 Oct 2013 15:16:04 -0300

perf tools: Add default handler for mmap2 events

Commands that do not implement an mmap2 handler should at least not die
with a segfault when processing files with MMAP2 events.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1379900700-5186-5-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/session.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 70ffa41..37c4718 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -256,6 +256,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
tool->sample = process_event_sample_stub;
if (tool->mmap == NULL)
tool->mmap = process_event_stub;
+   if (tool->mmap2 == NULL)
+   tool->mmap2 = process_event_stub;
if (tool->comm == NULL)
tool->comm = process_event_stub;
if (tool->fork == NULL)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf tools: Explicitly add libdl dependency

2013-09-25 Thread tip-bot for David Ahern
Commit-ID:  6d19912c9bc0ae0ba5f7dd32c714ea7cc3339c81
Gitweb: http://git.kernel.org/tip/6d19912c9bc0ae0ba5f7dd32c714ea7cc3339c81
Author: David Ahern 
AuthorDate: Sun, 22 Sep 2013 19:44:57 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 25 Sep 2013 12:39:27 -0300

perf tools: Explicitly add libdl dependency

Fixes compile failure on Fedora 12.

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1379900700-5186-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/config/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 346ee92..5f6f9b3 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -87,7 +87,7 @@ CFLAGS += -Wall
 CFLAGS += -Wextra
 CFLAGS += -std=gnu99
 
-EXTLIBS = -lelf -lpthread -lrt -lm
+EXTLIBS = -lelf -lpthread -lrt -lm -ldl
 
 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror 
-fstack-protector-all,-fstack-protector-all),y)
   CFLAGS += -fstack-protector-all
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf trace: Add mmap2 handler

2013-09-25 Thread tip-bot for David Ahern
Commit-ID:  384c671e33a7ddf905f2c60b433b9883f0e5a605
Gitweb: http://git.kernel.org/tip/384c671e33a7ddf905f2c60b433b9883f0e5a605
Author: David Ahern 
AuthorDate: Sun, 22 Sep 2013 19:44:58 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 24 Sep 2013 14:15:51 -0300

perf trace: Add mmap2 handler

5c5e854b changed perf_event__synthesize_mmap_events to generate MMAP2
events. Since perf-trace does not have a handler for it it dies with a
segfault when trying to process files:

perf trace -i /tmp/perf.data
Segmentation fault

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1379900700-5186-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index fd48534..71aa3e3 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1055,6 +1055,7 @@ static int trace__replay(struct trace *trace)
 
trace->tool.sample= trace__process_sample;
trace->tool.mmap  = perf_event__process_mmap;
+   trace->tool.mmap2 = perf_event__process_mmap2;
trace->tool.comm  = perf_event__process_comm;
trace->tool.exit  = perf_event__process_exit;
trace->tool.fork  = perf_event__process_fork;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Fix symbol offset computation for some dsos

2013-09-03 Thread tip-bot for David Ahern
Commit-ID:  0b8c25d949e010274c6697c570b772797ebc7c27
Gitweb: http://git.kernel.org/tip/0b8c25d949e010274c6697c570b772797ebc7c27
Author: David Ahern 
AuthorDate: Sun, 28 Jul 2013 09:48:32 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Sep 2013 14:58:21 -0300

perf tools: Fix symbol offset computation for some dsos

For some dsos (e.g., libc, libpthread, kernel modules) the symbol offset
is huge. e.g.,

qemu-kvm 17238/17242 [007] 762235.640311:
816288a1 __schedule+0x451 ([kernel.kallsyms])
81629609 schedule+0x29 ([kernel.kallsyms])
a00a6ded kvm_vcpu_block+0xa00a106d 
(/lib/modules/3.11.0-rc1+/kernel/arch/x86/kvm/kvm.ko)
a00bae6b kvm_arch_vcpu_ioctl_run+0xa00a118b 
(/lib/modules/3.11.0-rc1+/kernel/arch/x86/kvm/kvm.ko)
a00a4d7a kvm_vcpu_ioctl+0xa00a141a 
(/lib/modules/3.11.0-rc1+/kernel/arch/x86/kvm/kvm.ko)
811a7bdb do_vfs_ioctl+0x8b ([kernel.kallsyms])
811a80c1 sys_ioctl+0x91 ([kernel.kallsyms])
81633182 system_call+0x72 ([kernel.kallsyms])
7f882a97af27 __GI___ioctl+0x7f882a891007 (/lib64/libc-2.14.90.so)
   10002 [unknown] ([unknown])

It seems to be maps with a non-0 start. Taking that into account the
offsets are correct:

qemu-kvm 17238/17242 [007] 762235.640311:
816288a1 __schedule+0x451 ([kernel.kallsyms])
81629609 schedule+0x29 ([kernel.kallsyms])
a00a6ded kvm_vcpu_block+0x6d 
(/lib/modules/3.11.0-rc1+/kernel/arch/x86/kvm/kvm.ko)
a00bae6b kvm_arch_vcpu_ioctl_run+0x18b 
(/lib/modules/3.11.0-rc1+/kernel/arch/x86/kvm/kvm.ko)
a00a4d7a kvm_vcpu_ioctl+0x41a 
(/lib/modules/3.11.0-rc1+/kernel/arch/x86/kvm/kvm.ko)
811a7bdb do_vfs_ioctl+0x8b ([kernel.kallsyms])
811a80c1 sys_ioctl+0x91 ([kernel.kallsyms])
81633182 system_call+0x72 ([kernel.kallsyms])
7f882a97af27 __GI___ioctl+0x7 (/lib64/libc-2.14.90.so)
   10002 [unknown] ([unknown])

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1375026512-45826-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/session.c | 1 +
 tools/perf/util/symbol.c  | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 07642a7..1fc0c62 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1513,6 +1513,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
printf(" ");
if (print_symoffset) {
al.addr = node->ip;
+   al.map  = node->map;
symbol__fprintf_symname_offs(node->sym, 
&al, stdout);
} else
symbol__fprintf_symname(node->sym, 
stdout);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 77f3b95..7eb0362 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -259,7 +259,10 @@ size_t symbol__fprintf_symname_offs(const struct symbol 
*sym,
if (sym && sym->name) {
length = fprintf(fp, "%s", sym->name);
if (al) {
-   offset = al->addr - sym->start;
+   if (al->addr < sym->end)
+   offset = al->addr - sym->start;
+   else
+   offset = al->addr - al->map->start - sym->start;
length += fprintf(fp, "+0x%lx", offset);
}
return length;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Add option to analyze events in a file versus live

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  6810fc915f7a89d8134edb3996dbbf8eac386c26
Gitweb: http://git.kernel.org/tip/6810fc915f7a89d8134edb3996dbbf8eac386c26
Author: David Ahern 
AuthorDate: Wed, 28 Aug 2013 22:29:52 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 29 Aug 2013 17:42:34 -0300

perf trace: Add option to analyze events in a file versus live

Allows capture of raw_syscall:* events and analyzed at a later time.

v2: change -i option from inherit to input name for consistency with
other perf commands

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Mike Galbraith 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1377750593-48046-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-trace.txt |  4 ++
 tools/perf/builtin-trace.c  | 98 -
 2 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index fe19811..daccd2c 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -74,6 +74,10 @@ the thread executes on the designated CPUs. Default is to 
monitor all CPUs.
 --sched:
Accrue thread runtime and provide a summary at the end of the session.
 
+-i
+--input
+   Process events from a given perf data file.
+
 SEE ALSO
 
 linkperf:perf-record[1], linkperf:perf-script[1]
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 88387c5..2a6ebe1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -4,6 +4,7 @@
 #include "util/debug.h"
 #include "util/evlist.h"
 #include "util/machine.h"
+#include "util/session.h"
 #include "util/thread.h"
 #include "util/parse-options.h"
 #include "util/strlist.h"
@@ -652,6 +653,36 @@ out_dump:
return 0;
 }
 
+static int trace__process_sample(struct perf_tool *tool,
+union perf_event *event __maybe_unused,
+struct perf_sample *sample,
+struct perf_evsel *evsel,
+struct machine *machine __maybe_unused)
+{
+   struct trace *trace = container_of(tool, struct trace, tool);
+   int err = 0;
+
+   tracepoint_handler handler = evsel->handler.func;
+
+   if (trace->base_time == 0)
+   trace->base_time = sample->time;
+
+   if (handler)
+   handler(trace, evsel, sample);
+
+   return err;
+}
+
+static bool
+perf_session__has_tp(struct perf_session *session, const char *name)
+{
+   struct perf_evsel *evsel;
+
+   evsel = perf_evlist__find_tracepoint_by_name(session->evlist, name);
+
+   return evsel != NULL;
+}
+
 static int trace__run(struct trace *trace, int argc, const char **argv)
 {
struct perf_evlist *evlist = perf_evlist__new();
@@ -791,6 +822,65 @@ out:
return err;
 }
 
+static int trace__replay(struct trace *trace)
+{
+   const struct perf_evsel_str_handler handlers[] = {
+   { "raw_syscalls:sys_enter",  trace__sys_enter, },
+   { "raw_syscalls:sys_exit",   trace__sys_exit, },
+   };
+
+   struct perf_session *session;
+   int err = -1;
+
+   trace->tool.sample= trace__process_sample;
+   trace->tool.mmap  = perf_event__process_mmap;
+   trace->tool.comm  = perf_event__process_comm;
+   trace->tool.exit  = perf_event__process_exit;
+   trace->tool.fork  = perf_event__process_fork;
+   trace->tool.attr  = perf_event__process_attr;
+   trace->tool.tracing_data = perf_event__process_tracing_data;
+   trace->tool.build_id  = perf_event__process_build_id;
+
+   trace->tool.ordered_samples = true;
+   trace->tool.ordering_requires_timestamps = true;
+
+   /* add tid to output */
+   trace->multiple_threads = true;
+
+   if (symbol__init() < 0)
+   return -1;
+
+   session = perf_session__new(input_name, O_RDONLY, 0, false,
+   &trace->tool);
+   if (session == NULL)
+   return -ENOMEM;
+
+   err = perf_session__set_tracepoints_handlers(session, handlers);
+   if (err)
+   goto out;
+
+   if (!perf_session__has_tp(session, "raw_syscalls:sys_enter")) {
+   pr_err("Data file does not have raw_syscalls:sys_enter 
events\n");
+   goto out;
+   }
+
+   if (!perf_session__has_tp(session, "raw_syscalls:sys_exit")) {
+   pr_err("Data file does not have raw_syscalls:sys_exit 
events\n");
+   goto out;
+   }
+
+   setup_pager();
+
+   err = perf_session__process_events(session, &trace->tool);
+   if (err)
+   pr_err("Failed to process events, error %d", err);
+
+out:
+   perf_session__delete(session);
+
+  

[tip:perf/core] perf trace: Honor target pid / tid options when analyzing a file

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  bdc896617b4fcaa9c89da9a9c5b72660f6741d46
Gitweb: http://git.kernel.org/tip/bdc896617b4fcaa9c89da9a9c5b72660f6741d46
Author: David Ahern 
AuthorDate: Wed, 28 Aug 2013 22:29:53 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 29 Aug 2013 17:45:39 -0300

perf trace: Honor target pid / tid options when analyzing a file

Allows capture of raw_syscall events for all processes or threads in a
task and then analyzing specific ones.

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Mike Galbraith 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1377750593-48046-4-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 2a6ebe1..845facc 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -8,6 +8,7 @@
 #include "util/thread.h"
 #include "util/parse-options.h"
 #include "util/strlist.h"
+#include "util/intlist.h"
 #include "util/thread_map.h"
 
 #include 
@@ -259,6 +260,8 @@ struct trace {
unsigned long   nr_events;
struct strlist  *ev_qualifier;
boolnot_ev_qualifier;
+   struct intlist  *tid_list;
+   struct intlist  *pid_list;
boolsched;
boolmultiple_threads;
double  duration_filter;
@@ -653,6 +656,18 @@ out_dump:
return 0;
 }
 
+static bool skip_sample(struct trace *trace, struct perf_sample *sample)
+{
+   if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) ||
+   (trace->tid_list && intlist__find(trace->tid_list, sample->tid)))
+   return false;
+
+   if (trace->pid_list || trace->tid_list)
+   return true;
+
+   return false;
+}
+
 static int trace__process_sample(struct perf_tool *tool,
 union perf_event *event __maybe_unused,
 struct perf_sample *sample,
@@ -664,6 +679,9 @@ static int trace__process_sample(struct perf_tool *tool,
 
tracepoint_handler handler = evsel->handler.func;
 
+   if (skip_sample(trace, sample))
+   return 0;
+
if (trace->base_time == 0)
trace->base_time = sample->time;
 
@@ -683,6 +701,27 @@ perf_session__has_tp(struct perf_session *session, const 
char *name)
return evsel != NULL;
 }
 
+static int parse_target_str(struct trace *trace)
+{
+   if (trace->opts.target.pid) {
+   trace->pid_list = intlist__new(trace->opts.target.pid);
+   if (trace->pid_list == NULL) {
+   pr_err("Error parsing process id string\n");
+   return -EINVAL;
+   }
+   }
+
+   if (trace->opts.target.tid) {
+   trace->tid_list = intlist__new(trace->opts.target.tid);
+   if (trace->tid_list == NULL) {
+   pr_err("Error parsing thread id string\n");
+   return -EINVAL;
+   }
+   }
+
+   return 0;
+}
+
 static int trace__run(struct trace *trace, int argc, const char **argv)
 {
struct perf_evlist *evlist = perf_evlist__new();
@@ -869,6 +908,10 @@ static int trace__replay(struct trace *trace)
goto out;
}
 
+   err = parse_target_str(trace);
+   if (err != 0)
+   goto out;
+
setup_pager();
 
err = perf_session__process_events(session, &trace->tool);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf evlist: Add tracepoint lookup by name

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  a2f2804a7142b043dafd39f21b86777840e1a78c
Gitweb: http://git.kernel.org/tip/a2f2804a7142b043dafd39f21b86777840e1a78c
Author: David Ahern 
AuthorDate: Wed, 28 Aug 2013 22:29:51 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 29 Aug 2013 17:41:02 -0300

perf evlist: Add tracepoint lookup by name

Will be used by upcoming perf-trace replay option.

Signed-off-by: David Ahern 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Mike Galbraith 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1377750593-48046-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evlist.c | 15 +++
 tools/perf/util/evlist.h |  4 
 2 files changed, 19 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 6a629af..5df4ca9 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -208,6 +208,21 @@ perf_evlist__find_tracepoint_by_id(struct perf_evlist 
*evlist, int id)
return NULL;
 }
 
+struct perf_evsel *
+perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
+const char *name)
+{
+   struct perf_evsel *evsel;
+
+   list_for_each_entry(evsel, &evlist->entries, node) {
+   if ((evsel->attr.type == PERF_TYPE_TRACEPOINT) &&
+   (strcmp(evsel->name, name) == 0))
+   return evsel;
+   }
+
+   return NULL;
+}
+
 int perf_evlist__add_newtp(struct perf_evlist *evlist,
   const char *sys, const char *name, void *handler)
 {
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index ab95d72..841a394 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -74,6 +74,10 @@ int perf_evlist__set_filter(struct perf_evlist *evlist, 
const char *filter);
 struct perf_evsel *
 perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id);
 
+struct perf_evsel *
+perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
+const char *name);
+
 void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel,
 int cpu, int thread, u64 id);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf trace: Handle missing HUGEPAGE defines

2013-08-31 Thread tip-bot for David Ahern
Commit-ID:  f2935f3e585226b8203ec3861907e1cb16ad3d6a
Gitweb: http://git.kernel.org/tip/f2935f3e585226b8203ec3861907e1cb16ad3d6a
Author: David Ahern 
AuthorDate: Tue, 27 Aug 2013 10:50:40 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 30 Aug 2013 15:43:28 -0300

perf trace: Handle missing HUGEPAGE defines

Needed for compile on Fedora 12 which goes back to the 2.6.32 kernel.
Might be needed for RHEL6. I use F12 to compile static binaries for
Wind River Linux 4.3.

Signed-off-by: David Ahern 
Link: http://lkml.kernel.org/n/tip-nd0d7rbajgm8k6tah3xv3...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 845facc..69a065e 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -71,7 +71,9 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, 
size_t size, unsigned
P_MMAP_FLAG(FILE);
P_MMAP_FLAG(FIXED);
P_MMAP_FLAG(GROWSDOWN);
+#ifdef MAP_HUGETLB
P_MMAP_FLAG(HUGETLB);
+#endif
P_MMAP_FLAG(LOCKED);
P_MMAP_FLAG(NONBLOCK);
P_MMAP_FLAG(NORESERVE);
@@ -110,8 +112,12 @@ static size_t syscall_arg__scnprintf_madvise_behavior(char 
*bf, size_t size, uns
 #endif
P_MADV_BHV(MERGEABLE);
P_MADV_BHV(UNMERGEABLE);
+#ifdef MADV_HUGEPAGE
P_MADV_BHV(HUGEPAGE);
+#endif
+#ifdef MADV_NOHUGEPAGE
P_MADV_BHV(NOHUGEPAGE);
+#endif
 #ifdef MADV_DONTDUMP
P_MADV_BHV(DONTDUMP);
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tools: Sample after exit loses thread correlation

2013-08-29 Thread tip-bot for David Ahern
Commit-ID:  236a3bbd5cb51edbf9550f5a7df885665d18a271
Gitweb: http://git.kernel.org/tip/236a3bbd5cb51edbf9550f5a7df885665d18a271
Author: David Ahern 
AuthorDate: Wed, 14 Aug 2013 08:49:27 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 26 Aug 2013 17:25:36 -0300

perf tools: Sample after exit loses thread correlation

Occassionally events (e.g., context-switch, sched tracepoints) are losing
the conversion of sample data associated with a thread. For example:

$ perf record -e sched:sched_switch -c 1 -a -- sleep 5
$ perf script

ls 30482 [000] 1379727.583037: sched:sched_switch: prev_comm=ls 
prev_pid=30482 ...
ls 30482 [000] 1379727.586339: sched:sched_switch: prev_comm=ls 
prev_pid=30482 ...
:30482 30482 [000] 1379727.589462: sched:sched_switch: prev_comm=ls 
prev_pid=30482 ...

The last line lost the conversion from tid to comm. If you look at the events
(perf script -D) you see why - a SAMPLE event is generated after the EXIT:

0 1379727589449774 0x1540b0 [0x38]: PERF_RECORD_EXIT(30482:30482):(30482:30482)
0 1379727589462497 0x1540e8 [0x80]: PERF_RECORD_SAMPLE(IP, 1): 30482/30482: 
0x816416f1 period: 1 addr: 0
... thread: :30482:30482

When perf processes the EXIT event the thread is moved to the dead_threads
list. When the SAMPLE event is processed no thread exists for the pid so a new
one is created by machine__findnew_thread.

This patch address the problem by delaying the move to the dead_threads list
until the tid is re-used (per Adrian's suggestion).

With this patch we get the previous example shows:

  ls 30482 [000] 1379727.583037: sched:sched_switch: prev_comm=ls 
prev_pid=30482 ...
  ls 30482 [000] 1379727.586339: sched:sched_switch: prev_comm=ls 
prev_pid=30482 ...
  ls 30482 [000] 1379727.589462: sched:sched_switch: prev_comm=ls 
prev_pid=30482 ...

and

  0 1379727589449774 0x1540b0 [0x38]: 
PERF_RECORD_EXIT(30482:30482):(30482:30482)
  0 1379727589462497 0x1540e8 [0x80]: PERF_RECORD_SAMPLE(IP, 1): 30482/30482: 
0x816416f1 period: 1 addr: 0
  ... thread: ls:30482

v4: per Arnaldo's request add dead flag to thread struct and set when task exits

v3: re-do from a time based check to a delayed move to dead_threads list

v2: Rebased to latest perf/core branch. Changed time comparison to use
a macro which explicitly shows the time basis

Signed-off-by: David Ahern 
Acked-by: Adrian Hunter 
Cc: Adrian Hunter 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Mike Galbraith 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1376491767-84171-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/machine.c | 34 --
 tools/perf/util/thread.h  |  5 +
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 4514e7e..574feb7 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1031,11 +1031,27 @@ out_problem:
return 0;
 }
 
+static void machine__remove_thread(struct machine *machine, struct thread *th)
+{
+   machine->last_match = NULL;
+   rb_erase(&th->rb_node, &machine->threads);
+   /*
+* We may have references to this thread, for instance in some 
hist_entry
+* instances, so just move them to a separate list.
+*/
+   list_add_tail(&th->node, &machine->dead_threads);
+}
+
 int machine__process_fork_event(struct machine *machine, union perf_event 
*event)
 {
-   struct thread *thread = machine__findnew_thread(machine, 
event->fork.tid);
+   struct thread *thread = machine__find_thread(machine, event->fork.tid);
struct thread *parent = machine__findnew_thread(machine, 
event->fork.ptid);
 
+   /* if a thread currently exists for the thread id remove it */
+   if (thread != NULL)
+   machine__remove_thread(machine, thread);
+
+   thread = machine__findnew_thread(machine, event->fork.tid);
if (dump_trace)
perf_event__fprintf_task(event, stdout);
 
@@ -1048,18 +1064,8 @@ int machine__process_fork_event(struct machine *machine, 
union perf_event *event
return 0;
 }
 
-static void machine__remove_thread(struct machine *machine, struct thread *th)
-{
-   machine->last_match = NULL;
-   rb_erase(&th->rb_node, &machine->threads);
-   /*
-* We may have references to this thread, for instance in some 
hist_entry
-* instances, so just move them to a separate list.
-*/
-   list_add_tail(&th->node, &machine->dead_threads);
-}
-
-int machine__process_exit_event(struct machine *machine, union perf_event 
*event)
+int machine__process_exit_event(struct machine *machine __maybe_unused,
+   union perf_event *event)
 {
struct thread *thread = machine__find_thread(machine, event->fork.tid);
 
@@ -1067,7 +1073,7 @@ int machine__process_exit_event(struct machine *ma

[tip:perf/core] perf trace: Make command line arguments consistent with perf-record

2013-08-29 Thread tip-bot for David Ahern
Commit-ID:  ac9be8ee4ecdeae73c78d84ebfe37009e11cf99d
Gitweb: http://git.kernel.org/tip/ac9be8ee4ecdeae73c78d84ebfe37009e11cf99d
Author: David Ahern 
AuthorDate: Tue, 20 Aug 2013 11:15:45 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 26 Aug 2013 17:25:35 -0300

perf trace: Make command line arguments consistent with perf-record

Common arguments like thread id, CPU list, mmap pages, etc should be
consistent across perf commands.

v3: Updated man page
v2: rebased to latest core branch

Signed-off-by: David Ahern 
Link: 
http://lkml.kernel.org/r/1377018945-21940-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-trace.txt |  6 ++
 tools/perf/builtin-trace.c  | 12 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index 2794efc..cb3371e 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -23,6 +23,7 @@ analysis phases.
 OPTIONS
 ---
 
+-a::
 --all-cpus::
 System-wide collection from all CPUs.
 
@@ -38,18 +39,23 @@ OPTIONS
 --pid=::
Record events on existing process ID (comma separated list).
 
+-t::
 --tid=::
 Record events on existing thread ID (comma separated list).
 
+-u::
 --uid=::
 Record events in threads owned by uid. Name or number.
 
+-i::
 --no-inherit::
Child tasks do not inherit counters.
 
+-m::
 --mmap-pages=::
Number of mmap data pages. Must be a power of two.
 
+-C::
 --cpu::
 Collect samples only on the list of CPUs provided. Multiple CPUs can be 
provided as a
 comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 
0-2.
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4235316..9891d8c 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -693,17 +693,17 @@ int cmd_trace(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_STRING('o', "output", &output_name, "file", "output file name"),
OPT_STRING('p', "pid", &trace.opts.target.pid, "pid",
"trace events on existing process id"),
-   OPT_STRING(0, "tid", &trace.opts.target.tid, "tid",
+   OPT_STRING('t', "tid", &trace.opts.target.tid, "tid",
"trace events on existing thread id"),
-   OPT_BOOLEAN(0, "all-cpus", &trace.opts.target.system_wide,
+   OPT_BOOLEAN('a', "all-cpus", &trace.opts.target.system_wide,
"system-wide collection from all CPUs"),
-   OPT_STRING(0, "cpu", &trace.opts.target.cpu_list, "cpu",
+   OPT_STRING('C', "cpu", &trace.opts.target.cpu_list, "cpu",
"list of cpus to monitor"),
-   OPT_BOOLEAN(0, "no-inherit", &trace.opts.no_inherit,
+   OPT_BOOLEAN('i', "no-inherit", &trace.opts.no_inherit,
"child tasks do not inherit counters"),
-   OPT_UINTEGER(0, "mmap-pages", &trace.opts.mmap_pages,
+   OPT_UINTEGER('m', "mmap-pages", &trace.opts.mmap_pages,
 "number of mmap data pages"),
-   OPT_STRING(0, "uid", &trace.opts.target.uid_str, "user",
+   OPT_STRING('u', "uid", &trace.opts.target.uid_str, "user",
   "user to profile"),
OPT_CALLBACK(0, "duration", &trace, "float",
 "show only events with duration > N.M ms",
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf kvm: Remove force option to cmd_record

2013-08-29 Thread tip-bot for David Ahern
Commit-ID:  fe32ee0fc1c43f780529da79329d8c87ebc51464
Gitweb: http://git.kernel.org/tip/fe32ee0fc1c43f780529da79329d8c87ebc51464
Author: David Ahern 
AuthorDate: Wed, 14 Aug 2013 14:36:13 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 16 Aug 2013 17:17:57 -0300

perf kvm: Remove force option to cmd_record

4a4d371a missed builtin-kvm in the cleanup to remove the force option
to cmd_record.

Signed-off-by: David Ahern 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1376512573-85012-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kvm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index fa2f3d7..6cd4de5 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1305,7 +1305,6 @@ kvm_events_record(struct perf_kvm_stat *kvm, int argc, 
const char **argv)
const char * const record_args[] = {
"record",
"-R",
-   "-f",
"-m", "1024",
"-c", "1",
};
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf kvm: Option to print events that exceed a duration

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  70f7b4a7f3f9a46807b644aa0fcfa7daa0d553e4
Gitweb: http://git.kernel.org/tip/70f7b4a7f3f9a46807b644aa0fcfa7daa0d553e4
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 21:56:38 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:04 -0300

perf kvm: Option to print events that exceed a duration

This is useful to spot high latency blips. It is normal for HLT reasons
to have long exit times, so strip those from the duration check.

v2: changed threshold to duration per acme's request

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Runzhen Wang 
Cc: Xiao Guangrong 
Link: 
http://lkml.kernel.org/r/1375926999-75129-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kvm.c | 25 +
 tools/perf/perf.h|  3 +++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 2ceec81..fa2f3d7 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -106,6 +106,7 @@ struct perf_kvm_stat {
u64 total_time;
u64 total_count;
u64 lost_events;
+   u64 duration;
 
const char *pid_str;
struct intlist *pid_list;
@@ -473,7 +474,7 @@ static bool update_kvm_event(struct kvm_event *event, int 
vcpu_id,
 static bool handle_end_event(struct perf_kvm_stat *kvm,
 struct vcpu_event_record *vcpu_record,
 struct event_key *key,
-u64 timestamp)
+struct perf_sample *sample)
 {
struct kvm_event *event;
u64 time_begin, time_diff;
@@ -510,12 +511,24 @@ static bool handle_end_event(struct perf_kvm_stat *kvm,
vcpu_record->start_time = 0;
 
/* seems to happen once in a while during live mode */
-   if (timestamp < time_begin) {
+   if (sample->time < time_begin) {
pr_debug("End time before begin time; skipping event.\n");
return true;
}
 
-   time_diff = timestamp - time_begin;
+   time_diff = sample->time - time_begin;
+
+   if (kvm->duration && time_diff > kvm->duration) {
+   char decode[32];
+
+   kvm->events_ops->decode_key(kvm, &event->key, decode);
+   if (strcmp(decode, "HLT")) {
+   pr_info("%" PRIu64 " VM %d, vcpu %d: %s event took %" 
PRIu64 "usec\n",
+sample->time, sample->pid, 
vcpu_record->vcpu_id,
+decode, time_diff/1000);
+   }
+   }
+
return update_kvm_event(event, vcpu, time_diff);
 }
 
@@ -562,7 +575,7 @@ static bool handle_kvm_event(struct perf_kvm_stat *kvm,
return handle_begin_event(kvm, vcpu_record, &key, sample->time);
 
if (kvm->events_ops->is_end_event(evsel, sample, &key))
-   return handle_end_event(kvm, vcpu_record, &key, sample->time);
+   return handle_end_event(kvm, vcpu_record, &key, sample);
 
return true;
 }
@@ -1429,6 +1442,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
OPT_STRING('k', "key", &kvm->sort_key, "sort-key",
"key for sorting: sample(sort by samples number)"
" time (sort by avg time)"),
+   OPT_U64(0, "duration", &kvm->duration,
+   "show events other than HALT that take longer than duration 
usecs"),
OPT_END()
};
const char * const live_usage[] = {
@@ -1467,6 +1482,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
usage_with_options(live_usage, live_options);
}
 
+   kvm->duration *= NSEC_PER_USEC;   /* convert usec to nsec */
+
/*
 * target related setups
 */
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 32bd102..cf20187 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -125,6 +125,9 @@
 #ifndef NSEC_PER_SEC
 # define NSEC_PER_SEC  10ULL
 #endif
+#ifndef NSEC_PER_USEC
+# define NSEC_PER_USEC 1000ULL
+#endif
 
 static inline unsigned long long rdclock(void)
 {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf sched: Simplify arguments to read_events

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  ad9def7ca020ef5b54968c89194f52d18ef1ef49
Gitweb: http://git.kernel.org/tip/ad9def7ca020ef5b54968c89194f52d18ef1ef49
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 22:50:44 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:05 -0300

perf sched: Simplify arguments to read_events

Destroy argument is not necessary. If session is not returned to caller,
then clean it up.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1375930261-77273-3-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 948183a..34ce57d 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1445,7 +1445,7 @@ static int perf_sched__process_tracepoint_sample(struct 
perf_tool *tool __maybe_
return err;
 }
 
-static int perf_sched__read_events(struct perf_sched *sched, bool destroy,
+static int perf_sched__read_events(struct perf_sched *sched,
   struct perf_session **psession)
 {
const struct perf_evsel_str_handler handlers[] = {
@@ -1480,11 +1480,10 @@ static int perf_sched__read_events(struct perf_sched 
*sched, bool destroy,
sched->nr_lost_chunks = 
session->stats.nr_events[PERF_RECORD_LOST];
}
 
-   if (destroy)
-   perf_session__delete(session);
-
if (psession)
*psession = session;
+   else
+   perf_session__delete(session);
 
return 0;
 
@@ -1529,8 +1528,11 @@ static int perf_sched__lat(struct perf_sched *sched)
struct perf_session *session;
 
setup_pager();
-   if (perf_sched__read_events(sched, false, &session))
+
+   /* save session -- references to threads are held in work_list */
+   if (perf_sched__read_events(sched, &session))
return -1;
+
perf_sched__sort_lat(sched);
 
printf("\n 
---\n");
@@ -1565,7 +1567,7 @@ static int perf_sched__map(struct perf_sched *sched)
sched->max_cpu = sysconf(_SC_NPROCESSORS_CONF);
 
setup_pager();
-   if (perf_sched__read_events(sched, true, NULL))
+   if (perf_sched__read_events(sched, NULL))
return -1;
print_bad_events(sched);
return 0;
@@ -1580,7 +1582,7 @@ static int perf_sched__replay(struct perf_sched *sched)
 
test_calibrations(sched);
 
-   if (perf_sched__read_events(sched, true, NULL))
+   if (perf_sched__read_events(sched, NULL))
return -1;
 
printf("nr_run_events:%ld\n", sched->nr_run_events);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tests: Fix compile failure on do_sort_something

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  309b5185047c5309bbc576025f6c5e257edd9f69
Gitweb: http://git.kernel.org/tip/309b5185047c5309bbc576025f6c5e257edd9f69
Author: David Ahern 
AuthorDate: Tue, 13 Aug 2013 22:32:12 -0600
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 14 Aug 2013 11:42:45 -0300

perf tests: Fix compile failure on do_sort_something

Commit b55ae0a9 added code-reading.c which fails to compile on Fedora 16
with compiler version:
$ gcc --version
gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)

Failure message is:

tests/code-reading.c: In function ‘do_sort_something’:
tests/code-reading.c:305:13: error: stack protector not protecting local 
variables: variable length buffer [-Werror=stack-protector]
cc1: all warnings being treated as errors
make: *** [/tmp/junk/tests/code-reading.o] Error 1
make: *** Waiting for unfinished jobs

v2: as Adrian noticed changed sizeof to ARRAY_SIZE

Signed-off-by: David Ahern 
Acked-by: Adrian Hunter 
Cc: Adrian Hunter 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1376454732-83728-1-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/code-reading.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index eec1421..df9afd9 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -304,15 +304,14 @@ static int comp(const void *a, const void *b)
 
 static void do_sort_something(void)
 {
-   size_t sz = 40960;
-   int buf[sz], i;
+   int buf[40960], i;
 
-   for (i = 0; i < (int)sz; i++)
-   buf[i] = sz - i - 1;
+   for (i = 0; i < (int)ARRAY_SIZE(buf); i++)
+   buf[i] = ARRAY_SIZE(buf) - i - 1;
 
-   qsort(buf, sz, sizeof(int), comp);
+   qsort(buf, ARRAY_SIZE(buf), sizeof(int), comp);
 
-   for (i = 0; i < (int)sz; i++) {
+   for (i = 0; i < (int)ARRAY_SIZE(buf); i++) {
if (buf[i] != i) {
pr_debug("qsort failed\n");
break;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf evsel: Add option to limit stack depth in callchain dumps

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  307cbb92aa2bdc9eed7c74409ff4d5fc9135b4e2
Gitweb: http://git.kernel.org/tip/307cbb92aa2bdc9eed7c74409ff4d5fc9135b4e2
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 22:50:53 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:08 -0300

perf evsel: Add option to limit stack depth in callchain dumps

Option is used by upcoming timehist command.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1375930261-77273-12-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-script.c | 6 --
 tools/perf/util/session.c   | 6 --
 tools/perf/util/session.h   | 2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ee5d6f8..33b2d83 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -402,7 +402,8 @@ static void print_sample_bts(union perf_event *event,
else
printf("\n");
perf_evsel__print_ip(evsel, event, sample, machine,
-output[attr->type].print_ip_opts);
+output[attr->type].print_ip_opts,
+PERF_MAX_STACK_DEPTH);
}
 
printf(" => ");
@@ -444,7 +445,8 @@ static void process_event(union perf_event *event, struct 
perf_sample *sample,
printf("\n");
 
perf_evsel__print_ip(evsel, event, sample, machine,
-output[attr->type].print_ip_opts);
+output[attr->type].print_ip_opts,
+PERF_MAX_STACK_DEPTH);
}
 
printf("\n");
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 0d895e7..5a89964 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1489,7 +1489,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct 
perf_session *session,
 
 void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
  struct perf_sample *sample, struct machine *machine,
- unsigned int print_opts)
+ unsigned int print_opts, unsigned int stack_depth)
 {
struct addr_location al;
struct callchain_cursor_node *node;
@@ -1517,7 +1517,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
}
callchain_cursor_commit(&callchain_cursor);
 
-   while (1) {
+   while (stack_depth) {
node = callchain_cursor_current(&callchain_cursor);
if (!node)
break;
@@ -1544,6 +1544,8 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
printf("\n");
 
callchain_cursor_advance(&callchain_cursor);
+
+   stack_depth--;
}
 
} else {
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 7c00ccb..3aa75fb 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -109,7 +109,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct 
perf_session *session,
 
 void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
  struct perf_sample *sample, struct machine *machine,
- unsigned int print_opts);
+ unsigned int print_opts, unsigned int stack_depth);
 
 int perf_session__cpu_bitmap(struct perf_session *session,
 const char *cpu_list, unsigned long *cpu_bitmap);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf session: Change perf_session__has_traces to actually check for tracepoints

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  93ea01c29d4ed5a9fcf6d9a95bc584e54a420834
Gitweb: http://git.kernel.org/tip/93ea01c29d4ed5a9fcf6d9a95bc584e54a420834
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 22:50:58 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:08 -0300

perf session: Change perf_session__has_traces to actually check for tracepoints

Any event can have RAW data attribute set. The intent of the function is
to determine if the session has tracepoints, so check for the type of
each event explicitly.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1375930261-77273-17-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/session.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 5a89964..4d9028e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1401,12 +1401,15 @@ int perf_session__process_events(struct perf_session 
*self,
 
 bool perf_session__has_traces(struct perf_session *session, const char *msg)
 {
-   if (!(perf_evlist__sample_type(session->evlist) & PERF_SAMPLE_RAW)) {
-   pr_err("No trace sample to read. Did you call 'perf %s'?\n", 
msg);
-   return false;
+   struct perf_evsel *evsel;
+
+   list_for_each_entry(evsel, &session->evlist->entries, node) {
+   if (evsel->attr.type == PERF_TYPE_TRACEPOINT)
+   return true;
}
 
-   return true;
+   pr_err("No trace sample to read. Did you call 'perf %s'?\n", msg);
+   return false;
 }
 
 int maps__set_kallsyms_ref_reloc_sym(struct map **maps,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf evsel: Add option to print stack trace on single line

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  b0b35f0179161a5e256eebffa274b0b6f023f451
Gitweb: http://git.kernel.org/tip/b0b35f0179161a5e256eebffa274b0b6f023f451
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 22:50:52 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:08 -0300

perf evsel: Add option to print stack trace on single line

Option is used by upcoming timehist command.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1375930261-77273-11-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/session.c | 8 ++--
 tools/perf/util/session.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e5fd658..0d895e7 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1497,6 +1497,8 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
int print_sym = print_opts & PRINT_IP_OPT_SYM;
int print_dso = print_opts & PRINT_IP_OPT_DSO;
int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET;
+   int print_oneline = print_opts & PRINT_IP_OPT_ONELINE;
+   char s = print_oneline ? ' ' : '\t';
 
if (perf_event__preprocess_sample(event, machine, &al, sample,
  NULL) < 0) {
@@ -1521,7 +1523,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
break;
 
if (print_ip)
-   printf("%16" PRIx64, node->ip);
+   printf("%c%16" PRIx64, s, node->ip);
 
if (print_sym) {
printf(" ");
@@ -1537,7 +1539,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
map__fprintf_dsoname(node->map, stdout);
printf(")");
}
-   printf("\n");
+
+   if (!print_oneline)
+   printf("\n");
 
callchain_cursor_advance(&callchain_cursor);
}
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 69e554a..7c00ccb 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -45,6 +45,7 @@ struct perf_session {
 #define PRINT_IP_OPT_SYM   (1<<1)
 #define PRINT_IP_OPT_DSO   (1<<2)
 #define PRINT_IP_OPT_SYMOFFSET (1<<3)
+#define PRINT_IP_OPT_ONELINE   (1<<4)
 
 struct perf_tool;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf tool: Simplify options to perf_evsel__print_ip

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  a6ffaf91302dc1689fc72da0068b87226747fbe0
Gitweb: http://git.kernel.org/tip/a6ffaf91302dc1689fc72da0068b87226747fbe0
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 22:50:51 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:07 -0300

perf tool: Simplify options to perf_evsel__print_ip

Make print options based on flags. Simplifies addition of more print
options which is the subject of upcoming patches.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1375930261-77273-10-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-script.c | 27 +++
 tools/perf/util/session.c   | 14 +++---
 tools/perf/util/session.h   |  7 ++-
 3 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index cd616ff..ee5d6f8 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -66,6 +66,7 @@ struct output_option {
 static struct {
bool user_set;
bool wildcard_set;
+   unsigned int print_ip_opts;
u64 fields;
u64 invalid_fields;
 } output[PERF_TYPE_MAX] = {
@@ -235,6 +236,7 @@ static int perf_session__check_output_opt(struct 
perf_session *session)
 {
int j;
struct perf_evsel *evsel;
+   struct perf_event_attr *attr;
 
for (j = 0; j < PERF_TYPE_MAX; ++j) {
evsel = perf_session__find_first_evtype(session, j);
@@ -253,6 +255,24 @@ static int perf_session__check_output_opt(struct 
perf_session *session)
if (evsel && output[j].fields &&
perf_evsel__check_attr(evsel, session))
return -1;
+
+   if (evsel == NULL)
+   continue;
+
+   attr = &evsel->attr;
+
+   output[j].print_ip_opts = 0;
+   if (PRINT_FIELD(IP))
+   output[j].print_ip_opts |= PRINT_IP_OPT_IP;
+
+   if (PRINT_FIELD(SYM))
+   output[j].print_ip_opts |= PRINT_IP_OPT_SYM;
+
+   if (PRINT_FIELD(DSO))
+   output[j].print_ip_opts |= PRINT_IP_OPT_DSO;
+
+   if (PRINT_FIELD(SYMOFFSET))
+   output[j].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET;
}
 
return 0;
@@ -382,8 +402,7 @@ static void print_sample_bts(union perf_event *event,
else
printf("\n");
perf_evsel__print_ip(evsel, event, sample, machine,
-PRINT_FIELD(SYM), PRINT_FIELD(DSO),
-PRINT_FIELD(SYMOFFSET));
+output[attr->type].print_ip_opts);
}
 
printf(" => ");
@@ -423,9 +442,9 @@ static void process_event(union perf_event *event, struct 
perf_sample *sample,
printf(" ");
else
printf("\n");
+
perf_evsel__print_ip(evsel, event, sample, machine,
-PRINT_FIELD(SYM), PRINT_FIELD(DSO),
-PRINT_FIELD(SYMOFFSET));
+output[attr->type].print_ip_opts);
}
 
printf("\n");
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index dedaeb2..e5fd658 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1489,10 +1489,14 @@ struct perf_evsel 
*perf_session__find_first_evtype(struct perf_session *session,
 
 void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
  struct perf_sample *sample, struct machine *machine,
- int print_sym, int print_dso, int print_symoffset)
+ unsigned int print_opts)
 {
struct addr_location al;
struct callchain_cursor_node *node;
+   int print_ip = print_opts & PRINT_IP_OPT_IP;
+   int print_sym = print_opts & PRINT_IP_OPT_SYM;
+   int print_dso = print_opts & PRINT_IP_OPT_DSO;
+   int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET;
 
if (perf_event__preprocess_sample(event, machine, &al, sample,
  NULL) < 0) {
@@ -1516,7 +1520,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union 
perf_event *event,
if (!node)
break;
 
-   printf("\t%16" PRIx64, node->ip);
+   if (print_ip)
+   printf("%16" PRIx64, node->ip);
+
if (print_sym) {
printf(" ");
if (print_symoffset) {
@@ -1537,7 +1543,9 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, unio

[tip:perf/core] perf sched: Remove sched_process_fork tracepoint

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  cb627505ae028a0cd88cc29ed72a4c168a08751d
Gitweb: http://git.kernel.org/tip/cb627505ae028a0cd88cc29ed72a4c168a08751d
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 22:50:47 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:07 -0300

perf sched: Remove sched_process_fork tracepoint

The PERF_RECORD_FORK event is already collected as part of the use of
cmd_record and those events are analyzed as part of the libperf
machinery.  Using the fork tracepoint as well just duplicates the event
load.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1375930261-77273-6-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c | 60 --
 1 file changed, 31 insertions(+), 29 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 42f4587..f809cc7 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -109,8 +109,9 @@ struct trace_sched_handler {
int (*wakeup_event)(struct perf_sched *sched, struct perf_evsel *evsel,
struct perf_sample *sample, struct machine 
*machine);
 
-   int (*fork_event)(struct perf_sched *sched, struct perf_evsel *evsel,
- struct perf_sample *sample);
+   /* PERF_RECORD_FORK event, not sched_process_fork tracepoint */
+   int (*fork_event)(struct perf_sched *sched, union perf_event *event,
+ struct machine *machine);
 
int (*migrate_task_event)(struct perf_sched *sched,
  struct perf_evsel *evsel,
@@ -717,22 +718,29 @@ static int replay_switch_event(struct perf_sched *sched,
return 0;
 }
 
-static int replay_fork_event(struct perf_sched *sched, struct perf_evsel 
*evsel,
-struct perf_sample *sample)
+static int replay_fork_event(struct perf_sched *sched,
+union perf_event *event,
+struct machine *machine)
 {
-   const char *parent_comm = perf_evsel__strval(evsel, sample, 
"parent_comm"),
-  *child_comm  = perf_evsel__strval(evsel, sample, 
"child_comm");
-   const u32 parent_pid  = perf_evsel__intval(evsel, sample, "parent_pid"),
- child_pid  = perf_evsel__intval(evsel, sample, "child_pid");
+   struct thread *child, *parent;
+
+   child = machine__findnew_thread(machine, event->fork.tid);
+   parent = machine__findnew_thread(machine, event->fork.ptid);
+
+   if (child == NULL || parent == NULL) {
+   pr_debug("thread does not exist on fork event: child %p, parent 
%p\n",
+child, parent);
+   return 0;
+   }
 
if (verbose) {
-   printf("sched_fork event %p\n", evsel);
-   printf("... parent: %s/%d\n", parent_comm, parent_pid);
-   printf("...  child: %s/%d\n", child_comm, child_pid);
+   printf("fork event\n");
+   printf("... parent: %s/%d\n", parent->comm, parent->tid);
+   printf("...  child: %s/%d\n", child->comm, child->tid);
}
 
-   register_pid(sched, parent_pid, parent_comm);
-   register_pid(sched, child_pid, child_comm);
+   register_pid(sched, parent->tid, parent->comm);
+   register_pid(sched, child->tid, child->comm);
return 0;
 }
 
@@ -824,14 +832,6 @@ static int thread_atoms_insert(struct perf_sched *sched, 
struct thread *thread)
return 0;
 }
 
-static int latency_fork_event(struct perf_sched *sched __maybe_unused,
- struct perf_evsel *evsel __maybe_unused,
- struct perf_sample *sample __maybe_unused)
-{
-   /* should insert the newcomer */
-   return 0;
-}
-
 static char sched_out_state(u64 prev_state)
 {
const char *str = TASK_STATE_TO_CHAR_STR;
@@ -1379,15 +1379,19 @@ static int process_sched_runtime_event(struct perf_tool 
*tool,
return 0;
 }
 
-static int process_sched_fork_event(struct perf_tool *tool,
-   struct perf_evsel *evsel,
-   struct perf_sample *sample,
-   struct machine *machine __maybe_unused)
+static int perf_sched__process_fork_event(struct perf_tool *tool,
+ union perf_event *event,
+ struct perf_sample *sample,
+ struct machine *machine)
 {
struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
 
+   /* run the fork event through the perf machineruy */
+   perf_event__process_fork(tool, event, sample, machine);
+
+   /* and then run additional processing needed

[tip:perf/core] perf sched: Remove sched_process_exit tracepoint

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  4a957e4df1a212c447fd162d18dc7ee6320c1621
Gitweb: http://git.kernel.org/tip/4a957e4df1a212c447fd162d18dc7ee6320c1621
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 22:50:46 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:06 -0300

perf sched: Remove sched_process_exit tracepoint

Event is not needed nor analyzed. Since perf-sched leverages perf-record
to capture the sched data, we already capture task events like EXIT.

Signed-off-by: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1375930261-77273-5-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 5285024..42f4587 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1392,15 +1392,6 @@ static int process_sched_fork_event(struct perf_tool 
*tool,
return 0;
 }
 
-static int process_sched_exit_event(struct perf_tool *tool __maybe_unused,
-   struct perf_evsel *evsel,
-   struct perf_sample *sample __maybe_unused,
-   struct machine *machine __maybe_unused)
-{
-   pr_debug("sched_exit event %p\n", evsel);
-   return 0;
-}
-
 static int process_sched_migrate_task_event(struct perf_tool *tool,
struct perf_evsel *evsel,
struct perf_sample *sample,
@@ -1447,7 +1438,6 @@ static int perf_sched__read_events(struct perf_sched 
*sched,
{ "sched:sched_wakeup",   process_sched_wakeup_event, },
{ "sched:sched_wakeup_new",   process_sched_wakeup_event, },
{ "sched:sched_process_fork", process_sched_fork_event, },
-   { "sched:sched_process_exit", process_sched_exit_event, },
{ "sched:sched_migrate_task", process_sched_migrate_task_event, 
},
};
struct perf_session *session;
@@ -1634,7 +1624,6 @@ static int __cmd_record(int argc, const char **argv)
"-e", "sched:sched_stat_sleep",
"-e", "sched:sched_stat_iowait",
"-e", "sched:sched_stat_runtime",
-   "-e", "sched:sched_process_exit",
"-e", "sched:sched_process_fork",
"-e", "sched:sched_wakeup",
"-e", "sched:sched_migrate_task",
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf kvm: Update documentation with live command

2013-08-15 Thread tip-bot for David Ahern
Commit-ID:  9a6d316692d59c4400a66b01db675abac432b4b2
Gitweb: http://git.kernel.org/tip/9a6d316692d59c4400a66b01db675abac432b4b2
Author: David Ahern 
AuthorDate: Wed, 7 Aug 2013 21:56:39 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 12 Aug 2013 10:31:05 -0300

perf kvm: Update documentation with live command

Update perf-kvm documentation with new live subcommand. Add -p/--pid
option for perf-kvm-stat-report as well.

Signed-off-by: David Ahern 
Requested-by: Xiao Guangrong 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Runzhen Wang 
Cc: Xiao Guangrong 
Link: 
http://lkml.kernel.org/r/1375926999-75129-2-git-send-email-dsah...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-kvm.txt | 46 +--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-kvm.txt 
b/tools/perf/Documentation/perf-kvm.txt
index 326f2cb..ac84db2 100644
--- a/tools/perf/Documentation/perf-kvm.txt
+++ b/tools/perf/Documentation/perf-kvm.txt
@@ -13,6 +13,7 @@ SYNOPSIS
{top|record|report|diff|buildid-list}
 'perf kvm' [--host] [--guest] [--guestkallsyms= --guestmodules=
| --guestvmlinux=] {top|record|report|diff|buildid-list|stat}
+'perf kvm stat [record|report|live] []
 
 DESCRIPTION
 ---
@@ -50,6 +51,10 @@ There are a couple of variants of perf kvm:
   'perf kvm stat report' reports statistical data which includes events
   handled time, samples, and so on.
 
+  'perf kvm stat live' reports statistical data in a live mode (similar to
+  record + report but with statistical data updated live at a given display
+  rate).
+
 OPTIONS
 ---
 -i::
@@ -85,13 +90,50 @@ STAT REPORT OPTIONS
 --vcpu=::
analyze events which occures on this vcpu. (default: all vcpus)
 
---events=::
-   events to be analyzed. Possible values: vmexit, mmio, ioport.
+--event=::
+   event to be analyzed. Possible values: vmexit, mmio, ioport.
(default: vmexit)
 -k::
 --key=::
Sorting key. Possible values: sample (default, sort by samples
number), time (sort by average time).
+-p::
+--pid=::
+Analyze events only for given process ID(s) (comma separated list).
+
+STAT LIVE OPTIONS
+-
+-d::
+--display::
+Time in seconds between display updates
+
+-m::
+--mmap-pages=::
+Number of mmap data pages. Must be a power of two.
+
+-a::
+--all-cpus::
+System-wide collection from all CPUs.
+
+-p::
+--pid=::
+Analyze events only for given process ID(s) (comma separated list).
+
+--vcpu=::
+   analyze events which occures on this vcpu. (default: all vcpus)
+
+
+--event=::
+   event to be analyzed. Possible values: vmexit, mmio, ioport.
+   (default: vmexit)
+
+-k::
+--key=::
+   Sorting key. Possible values: sample (default, sort by samples
+   number), time (sort by average time).
+
+--duration=::
+   Show events other than HLT that take longer than duration usecs.
 
 SEE ALSO
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   >