aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-trace.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-02-13 11:22:21 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-02-13 11:22:21 -0500
commite596663ebb28a068f5cca57f83285b7b293a2c83 (patch)
tree149beb49298539086dfa813b56e8dbdc19af18db /tools/perf/builtin-trace.c
parent42052bea1683fad5a7a06d84a3b4f7bd16131ce8 (diff)
perf trace: Handle multiple threads better wrt syscalls being intermixed
$ trace time taskset -c 0 usleep 1 0.845 ( 0.021 ms): time/16722 wait4(upid: 4294967295, stat_addr: 0x7fff17f443d4, ru: 0x7fff17f44438 ) ... 0.865 ( 0.008 ms): time/16723 execve(arg0: 140733595272004, arg1: 140733595272720, arg2: 140733595272768, arg3: 139755107218496, arg4: 7307199665339051828, arg5: 3) = -2 2.395 ( 1.523 ms): taskset/16723 execve(arg0: 140733595272013, arg1: 140733595272720, arg2: 140733595272768, arg3: 139755107218496, arg4: 7307199665339051828, arg5: 3) = 0 2.411 ( 0.002 ms): taskset/16723 brk( ) = 0x1915000 3.300 ( 0.058 ms): usleep/16723 nanosleep(rqtp: 0x7ffff4ada190 ) = 0 <SNIP> 3.305 ( 0.000 ms): usleep/16723 exit_group( 3.363 ( 2.539 ms): time/16722 ... [continued]: wait4()) = 16723 3.366 ( 0.001 ms): time/16722 rt_sigaction(sig: INT, act: 0x7fff17f44160, oact: 0x7fff17f44200, sigsetsize: 8) = 0 We we're not seeing this line: 0.845 ( 0.021 ms): time/16722 wait4(upid: 4294967295, stat_addr: 0x7fff17f443d4, ru: 0x7fff17f44438 ) ... just the one when it finishes: 3.363 ( 2.539 ms): time/16722 ... [continued]: wait4()) = 16723 Still some issues left till we move to ordered_samples when multiple CPUs/threads are involved... Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-zq9x30a1ky3djqewqn2v3ja3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r--tools/perf/builtin-trace.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 2bfb2343b798..feabd08ec90d 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1220,6 +1220,7 @@ struct trace {
1220 } syscalls; 1220 } syscalls;
1221 struct record_opts opts; 1221 struct record_opts opts;
1222 struct machine *host; 1222 struct machine *host;
1223 struct thread *current;
1223 u64 base_time; 1224 u64 base_time;
1224 FILE *output; 1225 FILE *output;
1225 unsigned long nr_events; 1226 unsigned long nr_events;
@@ -1642,6 +1643,29 @@ static void thread__update_stats(struct thread_trace *ttrace,
1642 update_stats(stats, duration); 1643 update_stats(stats, duration);
1643} 1644}
1644 1645
1646static int trace__printf_interrupted_entry(struct trace *trace, struct perf_sample *sample)
1647{
1648 struct thread_trace *ttrace;
1649 u64 duration;
1650 size_t printed;
1651
1652 if (trace->current == NULL)
1653 return 0;
1654
1655 ttrace = thread__priv(trace->current);
1656
1657 if (!ttrace->entry_pending)
1658 return 0;
1659
1660 duration = sample->time - ttrace->entry_time;
1661
1662 printed = trace__fprintf_entry_head(trace, trace->current, duration, sample->time, trace->output);
1663 printed += fprintf(trace->output, "%-70s) ...\n", ttrace->entry_str);
1664 ttrace->entry_pending = false;
1665
1666 return printed;
1667}
1668
1645static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, 1669static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
1646 union perf_event *event __maybe_unused, 1670 union perf_event *event __maybe_unused,
1647 struct perf_sample *sample) 1671 struct perf_sample *sample)
@@ -1673,6 +1697,8 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
1673 return -1; 1697 return -1;
1674 } 1698 }
1675 1699
1700 printed += trace__printf_interrupted_entry(trace, sample);
1701
1676 ttrace->entry_time = sample->time; 1702 ttrace->entry_time = sample->time;
1677 msg = ttrace->entry_str; 1703 msg = ttrace->entry_str;
1678 printed += scnprintf(msg + printed, 1024 - printed, "%s(", sc->name); 1704 printed += scnprintf(msg + printed, 1024 - printed, "%s(", sc->name);
@@ -1688,6 +1714,8 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
1688 } else 1714 } else
1689 ttrace->entry_pending = true; 1715 ttrace->entry_pending = true;
1690 1716
1717 trace->current = thread;
1718
1691 return 0; 1719 return 0;
1692} 1720}
1693 1721