diff options
| author | Kirill Smelkov <kirr@mns.spb.ru> | 2011-01-12 09:59:36 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-13 08:38:44 -0500 |
| commit | acac03fa15a8684bb60489ed87b5aae5258c0838 (patch) | |
| tree | abaeaadf91bd4191d62904509815bcc372c42ba3 | |
| parent | 9710118bd4e7f3406865171cb9b9c94547c1c2f9 (diff) | |
perf record: Add "nodelay" mode, disabled by default
Sometimes there is a need to use perf in "live-log" mode. The problem
is, for seldom events, actual info output is largely delayed because
perf-record reads sample data in whole pages.
So for such scenarious, add flag for perf-record to go in "nodelay"
mode. To track e.g. what's going on in icmp_rcv while ping is running
Use it with something like this:
(1) $ perf probe -L icmp_rcv | grep -U8 '^ *43\>'
goto error;
}
38 if (!pskb_pull(skb, sizeof(*icmph)))
goto error;
icmph = icmp_hdr(skb);
43 ICMPMSGIN_INC_STATS_BH(net, icmph->type);
/*
* 18 is the highest 'known' ICMP type. Anything else is a mystery
*
* RFC 1122: 3.2.2 Unknown ICMP messages types MUST be silently
* discarded.
*/
50 if (icmph->type > NR_ICMP_TYPES)
goto error;
$ perf probe icmp_rcv:43 'type=icmph->type'
(2) $ cat trace-icmp.py
[...]
def trace_begin():
print "in trace_begin"
def trace_end():
print "in trace_end"
def probe__icmp_rcv(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
__probe_ip, type):
print_header(event_name, common_cpu, common_secs, common_nsecs,
common_pid, common_comm)
print "__probe_ip=%u, type=%u\n" % \
(__probe_ip, type),
[...]
(3) $ perf record -a -D -e probe:icmp_rcv -o - | \
perf script -i - -s trace-icmp.py
Thanks to Peter Zijlstra for pointing how to do it.
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20110112140613.GA11698@tugrik.mns.mnsspb.ru>
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/Documentation/perf-record.txt | 3 | ||||
| -rw-r--r-- | tools/perf/builtin-record.c | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 52462ae26455..e032716c839b 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt | |||
| @@ -61,6 +61,9 @@ OPTIONS | |||
| 61 | -r:: | 61 | -r:: |
| 62 | --realtime=:: | 62 | --realtime=:: |
| 63 | Collect data with this RT SCHED_FIFO priority. | 63 | Collect data with this RT SCHED_FIFO priority. |
| 64 | -D:: | ||
| 65 | --no-delay:: | ||
| 66 | Collect data without buffering. | ||
| 64 | -A:: | 67 | -A:: |
| 65 | --append:: | 68 | --append:: |
| 66 | Append to the output file to do incremental profiling. | 69 | Append to the output file to do incremental profiling. |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 1210e6484ad5..df6064ad9bf2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -49,6 +49,7 @@ static int pipe_output = 0; | |||
| 49 | static const char *output_name = "perf.data"; | 49 | static const char *output_name = "perf.data"; |
| 50 | static int group = 0; | 50 | static int group = 0; |
| 51 | static int realtime_prio = 0; | 51 | static int realtime_prio = 0; |
| 52 | static bool nodelay = false; | ||
| 52 | static bool raw_samples = false; | 53 | static bool raw_samples = false; |
| 53 | static bool sample_id_all_avail = true; | 54 | static bool sample_id_all_avail = true; |
| 54 | static bool system_wide = false; | 55 | static bool system_wide = false; |
| @@ -307,6 +308,11 @@ static void create_counter(struct perf_evsel *evsel, int cpu) | |||
| 307 | attr->sample_type |= PERF_SAMPLE_CPU; | 308 | attr->sample_type |= PERF_SAMPLE_CPU; |
| 308 | } | 309 | } |
| 309 | 310 | ||
| 311 | if (nodelay) { | ||
| 312 | attr->watermark = 0; | ||
| 313 | attr->wakeup_events = 1; | ||
| 314 | } | ||
| 315 | |||
| 310 | attr->mmap = track; | 316 | attr->mmap = track; |
| 311 | attr->comm = track; | 317 | attr->comm = track; |
| 312 | attr->inherit = !no_inherit; | 318 | attr->inherit = !no_inherit; |
| @@ -843,6 +849,8 @@ const struct option record_options[] = { | |||
| 843 | "record events on existing thread id"), | 849 | "record events on existing thread id"), |
| 844 | OPT_INTEGER('r', "realtime", &realtime_prio, | 850 | OPT_INTEGER('r', "realtime", &realtime_prio, |
| 845 | "collect data with this RT SCHED_FIFO priority"), | 851 | "collect data with this RT SCHED_FIFO priority"), |
| 852 | OPT_BOOLEAN('D', "no-delay", &nodelay, | ||
| 853 | "collect data without buffering"), | ||
| 846 | OPT_BOOLEAN('R', "raw-samples", &raw_samples, | 854 | OPT_BOOLEAN('R', "raw-samples", &raw_samples, |
| 847 | "collect raw sample records from all opened counters"), | 855 | "collect raw sample records from all opened counters"), |
| 848 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 856 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
