diff options
| author | Koki Sanagi <sanagi.koki@jp.fujitsu.com> | 2010-08-23 05:47:09 -0400 |
|---|---|---|
| committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-09-07 12:43:32 -0400 |
| commit | 359d5106a2ff4ffa2ba129ec8f54743c341dabfc (patch) | |
| tree | 681eedcf26a1acf029b5a3fbc3f271df36625aff /tools/perf/scripts | |
| parent | 07dc22e7295f25526f110d704655ff0ea7687420 (diff) | |
perf: Add a script to show packets processing
Add a perf script which shows packets processing and processed
time. It helps us to investigate networking or network devices.
If you want to use it, install perf and record perf.data like
following.
If you set script, perf gathers records until it ends.
If not, you must Ctrl-C to stop recording.
And if you want a report from record,
If you use some options, you can limit the output.
Option is below.
tx: show only tx packets processing
rx: show only rx packets processing
dev=: show processing on this device
debug: work with debug mode. It shows buffer status.
For example, if you want to show received packets processing
associated with eth4,
106133.171439sec cpu=0
irq_entry(+0.000msec irq=24:eth4)
|
softirq_entry(+0.006msec)
|
|---netif_receive_skb(+0.010msec skb=f2d15900 len=100)
| |
| skb_copy_datagram_iovec(+0.039msec 10291::10291)
|
napi_poll_exit(+0.022msec eth4)
This perf script helps us to analyze the processing time of a
transmit/receive sequence.
Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Kaneshige Kenji <kaneshige.kenji@jp.fujitsu.com>
Cc: Izumo Taku <izumi.taku@jp.fujitsu.com>
Cc: Kosaki Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Scott Mcmillan <scott.a.mcmillan@intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4C72439D.3040001@jp.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'tools/perf/scripts')
| -rw-r--r-- | tools/perf/scripts/python/bin/netdev-times-record | 8 | ||||
| -rw-r--r-- | tools/perf/scripts/python/bin/netdev-times-report | 5 | ||||
| -rw-r--r-- | tools/perf/scripts/python/netdev-times.py | 464 |
3 files changed, 477 insertions, 0 deletions
diff --git a/tools/perf/scripts/python/bin/netdev-times-record b/tools/perf/scripts/python/bin/netdev-times-record new file mode 100644 index 000000000000..d931a828126b --- /dev/null +++ b/tools/perf/scripts/python/bin/netdev-times-record | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | perf record -a -e net:net_dev_xmit -e net:net_dev_queue \ | ||
| 3 | -e net:netif_receive_skb -e net:netif_rx \ | ||
| 4 | -e skb:consume_skb -e skb:kfree_skb \ | ||
| 5 | -e skb:skb_copy_datagram_iovec -e napi:napi_poll \ | ||
| 6 | -e irq:irq_handler_entry -e irq:irq_handler_exit \ | ||
| 7 | -e irq:softirq_entry -e irq:softirq_exit \ | ||
| 8 | -e irq:softirq_raise $@ | ||
diff --git a/tools/perf/scripts/python/bin/netdev-times-report b/tools/perf/scripts/python/bin/netdev-times-report new file mode 100644 index 000000000000..c3d0a638123d --- /dev/null +++ b/tools/perf/scripts/python/bin/netdev-times-report | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # description: display a process of packet and processing time | ||
| 3 | # args: [tx] [rx] [dev=] [debug] | ||
| 4 | |||
| 5 | perf trace -s ~/libexec/perf-core/scripts/python/netdev-times.py $@ | ||
diff --git a/tools/perf/scripts/python/netdev-times.py b/tools/perf/scripts/python/netdev-times.py new file mode 100644 index 000000000000..9aa0a32972e8 --- /dev/null +++ b/tools/perf/scripts/python/netdev-times.py | |||
| @@ -0,0 +1,464 @@ | |||
| 1 | # Display a process of packets and processed time. | ||
| 2 | # It helps us to investigate networking or network device. | ||
| 3 | # | ||
| 4 | # options | ||
| 5 | # tx: show only tx chart | ||
| 6 | # rx: show only rx chart | ||
| 7 | # dev=: show only thing related to specified device | ||
| 8 | # debug: work with debug mode. It shows buffer status. | ||
| 9 | |||
| 10 | import os | ||
| 11 | import sys | ||
| 12 | |||
| 13 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ | ||
| 14 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') | ||
| 15 | |||
| 16 | from perf_trace_context import * | ||
| 17 | from Core import * | ||
| 18 | from Util import * | ||
| 19 | |||
| 20 | all_event_list = []; # insert all tracepoint event related with this script | ||
| 21 | irq_dic = {}; # key is cpu and value is a list which stacks irqs | ||
| 22 | # which raise NET_RX softirq | ||
| 23 | net_rx_dic = {}; # key is cpu and value include time of NET_RX softirq-entry | ||
| 24 | # and a list which stacks receive | ||
| 25 | receive_hunk_list = []; # a list which include a sequence of receive events | ||
| 26 | rx_skb_list = []; # received packet list for matching | ||
| 27 | # skb_copy_datagram_iovec | ||
| 28 | |||
| 29 | buffer_budget = 65536; # the budget of rx_skb_list, tx_queue_list and | ||
| 30 | # tx_xmit_list | ||
| 31 | of_count_rx_skb_list = 0; # overflow count | ||
| 32 | |||
| 33 | tx_queue_list = []; # list of packets which pass through dev_queue_xmit | ||
| 34 | of_count_tx_queue_list = 0; # overflow count | ||
| 35 | |||
| 36 | tx_xmit_list = []; # list of packets which pass through dev_hard_start_xmit | ||
| 37 | of_count_tx_xmit_list = 0; # overflow count | ||
| 38 | |||
| 39 | tx_free_list = []; # list of packets which is freed | ||
| 40 | |||
| 41 | # options | ||
| 42 | show_tx = 0; | ||
| 43 | show_rx = 0; | ||
| 44 | dev = 0; # store a name of device specified by option "dev=" | ||
| 45 | debug = 0; | ||
| 46 | |||
| 47 | # indices of event_info tuple | ||
| 48 | EINFO_IDX_NAME= 0 | ||
| 49 | EINFO_IDX_CONTEXT=1 | ||
| 50 | EINFO_IDX_CPU= 2 | ||
| 51 | EINFO_IDX_TIME= 3 | ||
| 52 | EINFO_IDX_PID= 4 | ||
| 53 | EINFO_IDX_COMM= 5 | ||
| 54 | |||
| 55 | # Calculate a time interval(msec) from src(nsec) to dst(nsec) | ||
| 56 | def diff_msec(src, dst): | ||
| 57 | return (dst - src) / 1000000.0 | ||
| 58 | |||
| 59 | # Display a process of transmitting a packet | ||
| 60 | def print_transmit(hunk): | ||
| 61 | if dev != 0 and hunk['dev'].find(dev) < 0: | ||
| 62 | return | ||
| 63 | print "%7s %5d %6d.%06dsec %12.3fmsec %12.3fmsec" % \ | ||
| 64 | (hunk['dev'], hunk['len'], | ||
| 65 | nsecs_secs(hunk['queue_t']), | ||
| 66 | nsecs_nsecs(hunk['queue_t'])/1000, | ||
| 67 | diff_msec(hunk['queue_t'], hunk['xmit_t']), | ||
| 68 | diff_msec(hunk['xmit_t'], hunk['free_t'])) | ||
| 69 | |||
| 70 | # Format for displaying rx packet processing | ||
| 71 | PF_IRQ_ENTRY= " irq_entry(+%.3fmsec irq=%d:%s)" | ||
| 72 | PF_SOFT_ENTRY=" softirq_entry(+%.3fmsec)" | ||
| 73 | PF_NAPI_POLL= " napi_poll_exit(+%.3fmsec %s)" | ||
| 74 | PF_JOINT= " |" | ||
| 75 | PF_WJOINT= " | |" | ||
| 76 | PF_NET_RECV= " |---netif_receive_skb(+%.3fmsec skb=%x len=%d)" | ||
| 77 | PF_NET_RX= " |---netif_rx(+%.3fmsec skb=%x)" | ||
| 78 | PF_CPY_DGRAM= " | skb_copy_datagram_iovec(+%.3fmsec %d:%s)" | ||
| 79 | PF_KFREE_SKB= " | kfree_skb(+%.3fmsec location=%x)" | ||
| 80 | PF_CONS_SKB= " | consume_skb(+%.3fmsec)" | ||
| 81 | |||
| 82 | # Display a process of received packets and interrputs associated with | ||
| 83 | # a NET_RX softirq | ||
| 84 | def print_receive(hunk): | ||
| 85 | show_hunk = 0 | ||
| 86 | irq_list = hunk['irq_list'] | ||
| 87 | cpu = irq_list[0]['cpu'] | ||
| 88 | base_t = irq_list[0]['irq_ent_t'] | ||
| 89 | # check if this hunk should be showed | ||
| 90 | if dev != 0: | ||
| 91 | for i in range(len(irq_list)): | ||
| 92 | if irq_list[i]['name'].find(dev) >= 0: | ||
| 93 | show_hunk = 1 | ||
| 94 | break | ||
| 95 | else: | ||
| 96 | show_hunk = 1 | ||
| 97 | if show_hunk == 0: | ||
| 98 | return | ||
| 99 | |||
| 100 | print "%d.%06dsec cpu=%d" % \ | ||
| 101 | (nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu) | ||
| 102 | for i in range(len(irq_list)): | ||
| 103 | print PF_IRQ_ENTRY % \ | ||
| 104 | (diff_msec(base_t, irq_list[i]['irq_ent_t']), | ||
| 105 | irq_list[i]['irq'], irq_list[i]['name']) | ||
| 106 | print PF_JOINT | ||
| 107 | irq_event_list = irq_list[i]['event_list'] | ||
| 108 | for j in range(len(irq_event_list)): | ||
| 109 | irq_event = irq_event_list[j] | ||
| 110 | if irq_event['event'] == 'netif_rx': | ||
| 111 | print PF_NET_RX % \ | ||
| 112 | (diff_msec(base_t, irq_event['time']), | ||
| 113 | irq_event['skbaddr']) | ||
| 114 | print PF_JOINT | ||
| 115 | print PF_SOFT_ENTRY % \ | ||
| 116 | diff_msec(base_t, hunk['sirq_ent_t']) | ||
| 117 | print PF_JOINT | ||
| 118 | event_list = hunk['event_list'] | ||
| 119 | for i in range(len(event_list)): | ||
| 120 | event = event_list[i] | ||
| 121 | if event['event_name'] == 'napi_poll': | ||
| 122 | print PF_NAPI_POLL % \ | ||
| 123 | (diff_msec(base_t, event['event_t']), event['dev']) | ||
| 124 | if i == len(event_list) - 1: | ||
| 125 | print "" | ||
| 126 | else: | ||
| 127 | print PF_JOINT | ||
| 128 | else: | ||
| 129 | print PF_NET_RECV % \ | ||
| 130 | (diff_msec(base_t, event['event_t']), event['skbaddr'], | ||
| 131 | event['len']) | ||
| 132 | if 'comm' in event.keys(): | ||
| 133 | print PF_WJOINT | ||
| 134 | print PF_CPY_DGRAM % \ | ||
| 135 | (diff_msec(base_t, event['comm_t']), | ||
| 136 | event['pid'], event['comm']) | ||
| 137 | elif 'handle' in event.keys(): | ||
| 138 | print PF_WJOINT | ||
| 139 | if event['handle'] == "kfree_skb": | ||
| 140 | print PF_KFREE_SKB % \ | ||
| 141 | (diff_msec(base_t, | ||
| 142 | event['comm_t']), | ||
| 143 | event['location']) | ||
| 144 | elif event['handle'] == "consume_skb": | ||
| 145 | print PF_CONS_SKB % \ | ||
| 146 | diff_msec(base_t, | ||
| 147 | event['comm_t']) | ||
| 148 | print PF_JOINT | ||
| 149 | |||
| 150 | def trace_begin(): | ||
| 151 | global show_tx | ||
| 152 | global show_rx | ||
| 153 | global dev | ||
| 154 | global debug | ||
| 155 | |||
| 156 | for i in range(len(sys.argv)): | ||
| 157 | if i == 0: | ||
| 158 | continue | ||
| 159 | arg = sys.argv[i] | ||
| 160 | if arg == 'tx': | ||
| 161 | show_tx = 1 | ||
| 162 | elif arg =='rx': | ||
| 163 | show_rx = 1 | ||
| 164 | elif arg.find('dev=',0, 4) >= 0: | ||
| 165 | dev = arg[4:] | ||
| 166 | elif arg == 'debug': | ||
| 167 | |||
