14 sys.path.append(os.environ[
'PERF_EXEC_PATH'] + \
15 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
17 from perf_trace_context
import *
26 receive_hunk_list = [];
30 buffer_budget = 65536;
32 of_count_rx_skb_list = 0;
35 of_count_tx_queue_list = 0;
38 of_count_tx_xmit_list = 0;
58 return (dst - src) / 1000000.0
62 if dev != 0
and hunk[
'dev'].find(dev) < 0:
64 print "%7s %5d %6d.%06dsec %12.3fmsec %12.3fmsec" % \
65 (hunk[
'dev'], hunk[
'len'],
68 diff_msec(hunk[
'queue_t'], hunk[
'xmit_t']),
69 diff_msec(hunk[
'xmit_t'], hunk[
'free_t']))
72 PF_IRQ_ENTRY=
" irq_entry(+%.3fmsec irq=%d:%s)" 73 PF_SOFT_ENTRY=
" softirq_entry(+%.3fmsec)" 74 PF_NAPI_POLL=
" napi_poll_exit(+%.3fmsec %s)" 77 PF_NET_RECV=
" |---netif_receive_skb(+%.3fmsec skb=%x len=%d)" 78 PF_NET_RX=
" |---netif_rx(+%.3fmsec skb=%x)" 79 PF_CPY_DGRAM=
" | skb_copy_datagram_iovec(+%.3fmsec %d:%s)" 80 PF_KFREE_SKB=
" | kfree_skb(+%.3fmsec location=%x)" 81 PF_CONS_SKB=
" | consume_skb(+%.3fmsec)" 87 irq_list = hunk[
'irq_list']
88 cpu = irq_list[0][
'cpu']
89 base_t = irq_list[0][
'irq_ent_t']
92 for i
in range(len(irq_list)):
93 if irq_list[i][
'name'].find(dev) >= 0:
101 print "%d.%06dsec cpu=%d" % \
103 for i
in range(len(irq_list)):
104 print PF_IRQ_ENTRY % \
105 (
diff_msec(base_t, irq_list[i][
'irq_ent_t']),
106 irq_list[i][
'irq'], irq_list[i][
'name'])
108 irq_event_list = irq_list[i][
'event_list']
109 for j
in range(len(irq_event_list)):
110 irq_event = irq_event_list[j]
111 if irq_event[
'event'] ==
'netif_rx':
114 irq_event[
'skbaddr'])
116 print PF_SOFT_ENTRY % \
119 event_list = hunk[
'event_list']
120 for i
in range(len(event_list)):
121 event = event_list[i]
122 if event[
'event_name'] ==
'napi_poll':
123 print PF_NAPI_POLL % \
124 (
diff_msec(base_t, event[
'event_t']), event[
'dev'])
125 if i == len(event_list) - 1:
130 print PF_NET_RECV % \
131 (
diff_msec(base_t, event[
'event_t']), event[
'skbaddr'],
133 if 'comm' in event.keys():
135 print PF_CPY_DGRAM % \
137 event[
'pid'], event[
'comm'])
138 elif 'handle' in event.keys():
140 if event[
'handle'] ==
"kfree_skb":
141 print PF_KFREE_SKB % \
145 elif event[
'handle'] ==
"consume_skb":
146 print PF_CONS_SKB % \
157 for i
in range(len(sys.argv)):
165 elif arg.find(
'dev=',0, 4) >= 0:
169 if show_tx == 0
and show_rx == 0:
175 all_event_list.sort(
lambda a,b :cmp(a[EINFO_IDX_TIME],
178 for i
in range(len(all_event_list)):
179 event_info = all_event_list[i]
180 name = event_info[EINFO_IDX_NAME]
181 if name ==
'irq__softirq_exit':
183 elif name ==
'irq__softirq_entry':
185 elif name ==
'irq__softirq_raise':
187 elif name ==
'irq__irq_handler_entry':
189 elif name ==
'irq__irq_handler_exit':
191 elif name ==
'napi__napi_poll':
193 elif name ==
'net__netif_receive_skb':
195 elif name ==
'net__netif_rx':
197 elif name ==
'skb__skb_copy_datagram_iovec':
199 elif name ==
'net__net_dev_queue':
201 elif name ==
'net__net_dev_xmit':
203 elif name ==
'skb__kfree_skb':
205 elif name ==
'skb__consume_skb':
209 for i
in range(len(receive_hunk_list)):
213 print " dev len Qdisc " \
215 for i
in range(len(tx_free_list)):
218 print "debug buffer status" 219 print "----------------------------" 220 print "xmit Qdisc:remain:%d overflow:%d" % \
221 (len(tx_queue_list), of_count_tx_queue_list)
222 print "xmit netdevice:remain:%d overflow:%d" % \
223 (len(tx_xmit_list), of_count_tx_xmit_list)
224 print "receive:remain:%d overflow:%d" % \
225 (len(rx_skb_list), of_count_rx_skb_list)
229 if symbol_str(
"irq__softirq_entry",
"vec", vec) !=
"NET_RX":
231 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm, vec)
232 all_event_list.append(event_info)
235 if symbol_str(
"irq__softirq_entry",
"vec", vec) !=
"NET_RX":
237 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm, vec)
238 all_event_list.append(event_info)
241 if symbol_str(
"irq__softirq_entry",
"vec", vec) !=
"NET_RX":
243 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm, vec)
244 all_event_list.append(event_info)
247 callchain, irq, irq_name):
248 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
250 all_event_list.append(event_info)
253 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm, irq, ret)
254 all_event_list.append(event_info)
256 def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi,
257 dev_name, work=None, budget=None):
258 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
259 napi, dev_name, work, budget)
260 all_event_list.append(event_info)
264 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
265 skbaddr, skblen, dev_name)
266 all_event_list.append(event_info)
268 def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
270 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
271 skbaddr, skblen, dev_name)
272 all_event_list.append(event_info)
275 skbaddr, skblen, dev_name):
276 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
277 skbaddr, skblen, dev_name)
278 all_event_list.append(event_info)
281 skbaddr, skblen, rc, dev_name):
282 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
283 skbaddr, skblen, rc ,dev_name)
284 all_event_list.append(event_info)
286 def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
287 skbaddr, protocol, location):
288 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
289 skbaddr, protocol, location)
290 all_event_list.append(event_info)
293 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
295 all_event_list.append(event_info)
299 event_info = (name, context, cpu,
nsecs(sec, nsec), pid, comm,
301 all_event_list.append(event_info)
304 (name, context, cpu, time, pid, comm, irq, irq_name) = event_info
305 if cpu
not in irq_dic.keys():
307 irq_record = {
'irq':irq,
'name':irq_name,
'cpu':cpu,
'irq_ent_t':time}
308 irq_dic[cpu].append(irq_record)
311 (name, context, cpu, time, pid, comm, irq, ret) = event_info
312 if cpu
not in irq_dic.keys():
314 irq_record = irq_dic[cpu].pop()
315 if irq != irq_record[
'irq']:
317 irq_record.update({
'irq_ext_t':time})
319 if 'event_list' in irq_record.keys():
320 irq_dic[cpu].append(irq_record)
323 (name, context, cpu, time, pid, comm, vec) = event_info
324 if cpu
not in irq_dic.keys() \
325 or len(irq_dic[cpu]) == 0:
327 irq_record = irq_dic[cpu].pop()
328 if 'event_list' in irq_record.keys():
329 irq_event_list = irq_record[
'event_list']
332 irq_event_list.append({
'time':time,
'event':
'sirq_raise'})
333 irq_record.update({
'event_list':irq_event_list})
334 irq_dic[cpu].append(irq_record)
337 (name, context, cpu, time, pid, comm, vec) = event_info
338 net_rx_dic[cpu] = {
'sirq_ent_t':time,
'event_list':[]}
341 (name, context, cpu, time, pid, comm, vec) = event_info
344 if cpu
in irq_dic.keys():
345 irq_list = irq_dic[cpu]
347 if cpu
in net_rx_dic.keys():
348 sirq_ent_t = net_rx_dic[cpu][
'sirq_ent_t']
349 event_list = net_rx_dic[cpu][
'event_list']
351 if irq_list == []
or event_list == 0:
353 rec_data = {
'sirq_ent_t':sirq_ent_t,
'sirq_ext_t':time,
354 'irq_list':irq_list,
'event_list':event_list}
356 receive_hunk_list.append(rec_data)
359 (name, context, cpu, time, pid, comm, napi, dev_name,
360 work, budget) = event_info
361 if cpu
in net_rx_dic.keys():
362 event_list = net_rx_dic[cpu][
'event_list']
363 rec_data = {
'event_name':
'napi_poll',
364 'dev':dev_name,
'event_t':time,
365 'work':work,
'budget':budget}
366 event_list.append(rec_data)
369 (name, context, cpu, time, pid, comm,
370 skbaddr, skblen, dev_name) = event_info
371 if cpu
not in irq_dic.keys() \
372 or len(irq_dic[cpu]) == 0:
374 irq_record = irq_dic[cpu].pop()
375 if 'event_list' in irq_record.keys():
376 irq_event_list = irq_record[
'event_list']
379 irq_event_list.append({
'time':time,
'event':
'netif_rx',
380 'skbaddr':skbaddr,
'skblen':skblen,
'dev_name':dev_name})
381 irq_record.update({
'event_list':irq_event_list})
382 irq_dic[cpu].append(irq_record)
385 global of_count_rx_skb_list
387 (name, context, cpu, time, pid, comm,
388 skbaddr, skblen, dev_name) = event_info
389 if cpu
in net_rx_dic.keys():
390 rec_data = {
'event_name':
'netif_receive_skb',
391 'event_t':time,
'skbaddr':skbaddr,
'len':skblen}
392 event_list = net_rx_dic[cpu][
'event_list']
393 event_list.append(rec_data)
394 rx_skb_list.insert(0, rec_data)
395 if len(rx_skb_list) > buffer_budget:
397 of_count_rx_skb_list += 1
400 global of_count_tx_queue_list
402 (name, context, cpu, time, pid, comm,
403 skbaddr, skblen, dev_name) = event_info
404 skb = {
'dev':dev_name,
'skbaddr':skbaddr,
'len':skblen,
'queue_t':time}
405 tx_queue_list.insert(0, skb)
406 if len(tx_queue_list) > buffer_budget:
408 of_count_tx_queue_list += 1
411 global of_count_tx_xmit_list
413 (name, context, cpu, time, pid, comm,
414 skbaddr, skblen, rc, dev_name) = event_info
416 for i
in range(len(tx_queue_list)):
417 skb = tx_queue_list[i]
418 if skb[
'skbaddr'] == skbaddr:
420 tx_xmit_list.insert(0, skb)
422 if len(tx_xmit_list) > buffer_budget:
424 of_count_tx_xmit_list += 1
428 (name, context, cpu, time, pid, comm,
429 skbaddr, protocol, location) = event_info
430 for i
in range(len(tx_queue_list)):
431 skb = tx_queue_list[i]
432 if skb[
'skbaddr'] == skbaddr:
435 for i
in range(len(tx_xmit_list)):
436 skb = tx_xmit_list[i]
437 if skb[
'skbaddr'] == skbaddr:
439 tx_free_list.append(skb)
442 for i
in range(len(rx_skb_list)):
443 rec_data = rx_skb_list[i]
444 if rec_data[
'skbaddr'] == skbaddr:
445 rec_data.update({
'handle':
"kfree_skb",
446 'comm':comm,
'pid':pid,
'comm_t':time})
451 (name, context, cpu, time, pid, comm, skbaddr) = event_info
452 for i
in range(len(tx_xmit_list)):
453 skb = tx_xmit_list[i]
454 if skb[
'skbaddr'] == skbaddr:
456 tx_free_list.append(skb)
461 (name, context, cpu, time, pid, comm, skbaddr, skblen) = event_info
462 for i
in range(len(rx_skb_list)):
463 rec_data = rx_skb_list[i]
464 if skbaddr == rec_data[
'skbaddr']:
465 rec_data.update({
'handle':
"skb_copy_datagram_iovec",
466 'comm':comm,
'pid':pid,
'comm_t':time})
def handle_irq_softirq_raise(event_info)
def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr, skblen)
def handle_irq_softirq_entry(event_info)
def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr, skblen, dev_name)
def handle_irq_handler_exit(event_info)
def handle_net_dev_xmit(event_info)
def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec)
def handle_skb_copy_datagram_iovec(event_info)
def handle_irq_handler_entry(event_info)
def irq__irq_handler_entry(name, context, cpu, sec, nsec, pid, comm, callchain, irq, irq_name)
def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr, protocol, location)
def handle_net_dev_queue(event_info)
def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr, skblen, dev_name)
def handle_netif_receive_skb(event_info)
def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr, skblen, rc, dev_name)
def handle_netif_rx(event_info)
def symbol_str(event_name, field_name, value)
def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi, dev_name, work=None, budget=None)
def handle_consume_skb(event_info)
def handle_kfree_skb(event_info)
static unsigned int nsecs
def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr, skblen, dev_name)
def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec)
def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, irq, ret)
def handle_napi_poll(event_info)
def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr)
def handle_irq_softirq_exit(event_info)
def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, callchain, vec)