^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # Display a process of packets and processed time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) # It helps us to investigate networking or network device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # tx: show only tx chart
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # rx: show only rx chart
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # dev=: show only thing related to specified device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # debug: work with debug mode. It shows buffer status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) from __future__ import print_function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) import os
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) import sys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) sys.path.append(os.environ['PERF_EXEC_PATH'] + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) from perf_trace_context import *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) from Core import *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) from Util import *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) from functools import cmp_to_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) all_event_list = []; # insert all tracepoint event related with this script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) irq_dic = {}; # key is cpu and value is a list which stacks irqs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) # which raise NET_RX softirq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) net_rx_dic = {}; # key is cpu and value include time of NET_RX softirq-entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) # and a list which stacks receive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) receive_hunk_list = []; # a list which include a sequence of receive events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) rx_skb_list = []; # received packet list for matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) # skb_copy_datagram_iovec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) buffer_budget = 65536; # the budget of rx_skb_list, tx_queue_list and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # tx_xmit_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) of_count_rx_skb_list = 0; # overflow count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) tx_queue_list = []; # list of packets which pass through dev_queue_xmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) of_count_tx_queue_list = 0; # overflow count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) tx_xmit_list = []; # list of packets which pass through dev_hard_start_xmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) of_count_tx_xmit_list = 0; # overflow count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) tx_free_list = []; # list of packets which is freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) # options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) show_tx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) show_rx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) dev = 0; # store a name of device specified by option "dev="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) debug = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) # indices of event_info tuple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) EINFO_IDX_NAME= 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) EINFO_IDX_CONTEXT=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) EINFO_IDX_CPU= 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) EINFO_IDX_TIME= 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) EINFO_IDX_PID= 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) EINFO_IDX_COMM= 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) # Calculate a time interval(msec) from src(nsec) to dst(nsec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) def diff_msec(src, dst):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return (dst - src) / 1000000.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) # Display a process of transmitting a packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) def print_transmit(hunk):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if dev != 0 and hunk['dev'].find(dev) < 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) print("%7s %5d %6d.%06dsec %12.3fmsec %12.3fmsec" %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) (hunk['dev'], hunk['len'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) nsecs_secs(hunk['queue_t']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) nsecs_nsecs(hunk['queue_t'])/1000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) diff_msec(hunk['queue_t'], hunk['xmit_t']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) diff_msec(hunk['xmit_t'], hunk['free_t'])))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) # Format for displaying rx packet processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) PF_IRQ_ENTRY= " irq_entry(+%.3fmsec irq=%d:%s)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) PF_SOFT_ENTRY=" softirq_entry(+%.3fmsec)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) PF_NAPI_POLL= " napi_poll_exit(+%.3fmsec %s)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) PF_JOINT= " |"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) PF_WJOINT= " | |"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) PF_NET_RECV= " |---netif_receive_skb(+%.3fmsec skb=%x len=%d)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) PF_NET_RX= " |---netif_rx(+%.3fmsec skb=%x)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) PF_CPY_DGRAM= " | skb_copy_datagram_iovec(+%.3fmsec %d:%s)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) PF_KFREE_SKB= " | kfree_skb(+%.3fmsec location=%x)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) PF_CONS_SKB= " | consume_skb(+%.3fmsec)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) # Display a process of received packets and interrputs associated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) # a NET_RX softirq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) def print_receive(hunk):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) show_hunk = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) irq_list = hunk['irq_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) cpu = irq_list[0]['cpu']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) base_t = irq_list[0]['irq_ent_t']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) # check if this hunk should be showed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if dev != 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) for i in range(len(irq_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if irq_list[i]['name'].find(dev) >= 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) show_hunk = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) break
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) show_hunk = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if show_hunk == 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) print("%d.%06dsec cpu=%d" %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) (nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) for i in range(len(irq_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) print(PF_IRQ_ENTRY %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) (diff_msec(base_t, irq_list[i]['irq_ent_t']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) irq_list[i]['irq'], irq_list[i]['name']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) print(PF_JOINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) irq_event_list = irq_list[i]['event_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) for j in range(len(irq_event_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) irq_event = irq_event_list[j]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if irq_event['event'] == 'netif_rx':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) print(PF_NET_RX %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) (diff_msec(base_t, irq_event['time']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) irq_event['skbaddr']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) print(PF_JOINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) print(PF_SOFT_ENTRY %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) diff_msec(base_t, hunk['sirq_ent_t']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) print(PF_JOINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) event_list = hunk['event_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) for i in range(len(event_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) event = event_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if event['event_name'] == 'napi_poll':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) print(PF_NAPI_POLL %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) (diff_msec(base_t, event['event_t']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) event['dev']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if i == len(event_list) - 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) print("")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) print(PF_JOINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) print(PF_NET_RECV %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) (diff_msec(base_t, event['event_t']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) event['skbaddr'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) event['len']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if 'comm' in event.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) print(PF_WJOINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) print(PF_CPY_DGRAM %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) (diff_msec(base_t, event['comm_t']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) event['pid'], event['comm']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) elif 'handle' in event.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) print(PF_WJOINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if event['handle'] == "kfree_skb":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) print(PF_KFREE_SKB %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) (diff_msec(base_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) event['comm_t']),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) event['location']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) elif event['handle'] == "consume_skb":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) print(PF_CONS_SKB %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) diff_msec(base_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) event['comm_t']))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) print(PF_JOINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) def trace_begin():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) global show_tx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) global show_rx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) global dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) global debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) for i in range(len(sys.argv)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if i == 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) arg = sys.argv[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if arg == 'tx':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) show_tx = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) elif arg =='rx':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) show_rx = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) elif arg.find('dev=',0, 4) >= 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) dev = arg[4:]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) elif arg == 'debug':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) debug = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if show_tx == 0 and show_rx == 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) show_tx = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) show_rx = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) def trace_end():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) # order all events in time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) all_event_list.sort(key=cmp_to_key(lambda a,b :a[EINFO_IDX_TIME] < b[EINFO_IDX_TIME]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) # process all events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) for i in range(len(all_event_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) event_info = all_event_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) name = event_info[EINFO_IDX_NAME]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if name == 'irq__softirq_exit':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) handle_irq_softirq_exit(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) elif name == 'irq__softirq_entry':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) handle_irq_softirq_entry(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) elif name == 'irq__softirq_raise':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) handle_irq_softirq_raise(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) elif name == 'irq__irq_handler_entry':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) handle_irq_handler_entry(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) elif name == 'irq__irq_handler_exit':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) handle_irq_handler_exit(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) elif name == 'napi__napi_poll':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) handle_napi_poll(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) elif name == 'net__netif_receive_skb':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) handle_netif_receive_skb(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) elif name == 'net__netif_rx':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) handle_netif_rx(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) elif name == 'skb__skb_copy_datagram_iovec':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) handle_skb_copy_datagram_iovec(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) elif name == 'net__net_dev_queue':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) handle_net_dev_queue(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) elif name == 'net__net_dev_xmit':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) handle_net_dev_xmit(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) elif name == 'skb__kfree_skb':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) handle_kfree_skb(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) elif name == 'skb__consume_skb':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) handle_consume_skb(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) # display receive hunks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if show_rx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) for i in range(len(receive_hunk_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) print_receive(receive_hunk_list[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) # display transmit hunks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if show_tx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) print(" dev len Qdisc "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) " netdevice free")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) for i in range(len(tx_free_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) print_transmit(tx_free_list[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if debug:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) print("debug buffer status")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) print("----------------------------")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) print("xmit Qdisc:remain:%d overflow:%d" %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) (len(tx_queue_list), of_count_tx_queue_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) print("xmit netdevice:remain:%d overflow:%d" %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) (len(tx_xmit_list), of_count_tx_xmit_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) print("receive:remain:%d overflow:%d" %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) (len(rx_skb_list), of_count_rx_skb_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) # called from perf, when it finds a correspoinding event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) def irq__irq_handler_entry(name, context, cpu, sec, nsec, pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) callchain, irq, irq_name):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) irq, irq_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, irq, ret):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) dev_name, work=None, budget=None):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) napi, dev_name, work, budget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) skblen, dev_name):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) skbaddr, skblen, dev_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) def net__netif_rx(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) skblen, dev_name):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) skbaddr, skblen, dev_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) def net__net_dev_queue(name, context, cpu, sec, nsec, pid, comm, callchain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) skbaddr, skblen, dev_name):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) skbaddr, skblen, dev_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) def net__net_dev_xmit(name, context, cpu, sec, nsec, pid, comm, callchain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) skbaddr, skblen, rc, dev_name):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) skbaddr, skblen, rc ,dev_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) skbaddr, protocol, location):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) skbaddr, protocol, location)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) def skb__consume_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) skbaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) def skb__skb_copy_datagram_iovec(name, context, cpu, sec, nsec, pid, comm, callchain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) skbaddr, skblen):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) skbaddr, skblen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) all_event_list.append(event_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) def handle_irq_handler_entry(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) (name, context, cpu, time, pid, comm, irq, irq_name) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) if cpu not in irq_dic.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) irq_dic[cpu] = []
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) irq_record = {'irq':irq, 'name':irq_name, 'cpu':cpu, 'irq_ent_t':time}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) irq_dic[cpu].append(irq_record)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) def handle_irq_handler_exit(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) (name, context, cpu, time, pid, comm, irq, ret) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if cpu not in irq_dic.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) irq_record = irq_dic[cpu].pop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if irq != irq_record['irq']:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) irq_record.update({'irq_ext_t':time})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) # if an irq doesn't include NET_RX softirq, drop.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) if 'event_list' in irq_record.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) irq_dic[cpu].append(irq_record)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) def handle_irq_softirq_raise(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) (name, context, cpu, time, pid, comm, vec) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if cpu not in irq_dic.keys() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) or len(irq_dic[cpu]) == 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) irq_record = irq_dic[cpu].pop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) if 'event_list' in irq_record.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) irq_event_list = irq_record['event_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) irq_event_list = []
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) irq_event_list.append({'time':time, 'event':'sirq_raise'})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) irq_record.update({'event_list':irq_event_list})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) irq_dic[cpu].append(irq_record)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) def handle_irq_softirq_entry(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) (name, context, cpu, time, pid, comm, vec) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) net_rx_dic[cpu] = {'sirq_ent_t':time, 'event_list':[]}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) def handle_irq_softirq_exit(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) (name, context, cpu, time, pid, comm, vec) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) irq_list = []
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) event_list = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if cpu in irq_dic.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) irq_list = irq_dic[cpu]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) del irq_dic[cpu]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if cpu in net_rx_dic.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) sirq_ent_t = net_rx_dic[cpu]['sirq_ent_t']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) event_list = net_rx_dic[cpu]['event_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) del net_rx_dic[cpu]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if irq_list == [] or event_list == 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) rec_data = {'sirq_ent_t':sirq_ent_t, 'sirq_ext_t':time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 'irq_list':irq_list, 'event_list':event_list}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) # merge information realted to a NET_RX softirq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) receive_hunk_list.append(rec_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) def handle_napi_poll(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) (name, context, cpu, time, pid, comm, napi, dev_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) work, budget) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) if cpu in net_rx_dic.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) event_list = net_rx_dic[cpu]['event_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) rec_data = {'event_name':'napi_poll',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 'dev':dev_name, 'event_t':time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 'work':work, 'budget':budget}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) event_list.append(rec_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) def handle_netif_rx(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) (name, context, cpu, time, pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) skbaddr, skblen, dev_name) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) if cpu not in irq_dic.keys() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) or len(irq_dic[cpu]) == 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) irq_record = irq_dic[cpu].pop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) if 'event_list' in irq_record.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) irq_event_list = irq_record['event_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) irq_event_list = []
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) irq_event_list.append({'time':time, 'event':'netif_rx',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 'skbaddr':skbaddr, 'skblen':skblen, 'dev_name':dev_name})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) irq_record.update({'event_list':irq_event_list})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) irq_dic[cpu].append(irq_record)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) def handle_netif_receive_skb(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) global of_count_rx_skb_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) (name, context, cpu, time, pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) skbaddr, skblen, dev_name) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) if cpu in net_rx_dic.keys():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) rec_data = {'event_name':'netif_receive_skb',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 'event_t':time, 'skbaddr':skbaddr, 'len':skblen}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) event_list = net_rx_dic[cpu]['event_list']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) event_list.append(rec_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) rx_skb_list.insert(0, rec_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) if len(rx_skb_list) > buffer_budget:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) rx_skb_list.pop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) of_count_rx_skb_list += 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) def handle_net_dev_queue(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) global of_count_tx_queue_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) (name, context, cpu, time, pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) skbaddr, skblen, dev_name) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) skb = {'dev':dev_name, 'skbaddr':skbaddr, 'len':skblen, 'queue_t':time}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) tx_queue_list.insert(0, skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) if len(tx_queue_list) > buffer_budget:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) tx_queue_list.pop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) of_count_tx_queue_list += 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) def handle_net_dev_xmit(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) global of_count_tx_xmit_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) (name, context, cpu, time, pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) skbaddr, skblen, rc, dev_name) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if rc == 0: # NETDEV_TX_OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) for i in range(len(tx_queue_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) skb = tx_queue_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if skb['skbaddr'] == skbaddr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) skb['xmit_t'] = time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) tx_xmit_list.insert(0, skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) del tx_queue_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if len(tx_xmit_list) > buffer_budget:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) tx_xmit_list.pop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) of_count_tx_xmit_list += 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) def handle_kfree_skb(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) (name, context, cpu, time, pid, comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) skbaddr, protocol, location) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) for i in range(len(tx_queue_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) skb = tx_queue_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if skb['skbaddr'] == skbaddr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) del tx_queue_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) for i in range(len(tx_xmit_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) skb = tx_xmit_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) if skb['skbaddr'] == skbaddr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) skb['free_t'] = time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) tx_free_list.append(skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) del tx_xmit_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) for i in range(len(rx_skb_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) rec_data = rx_skb_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if rec_data['skbaddr'] == skbaddr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) rec_data.update({'handle':"kfree_skb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 'comm':comm, 'pid':pid, 'comm_t':time})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) del rx_skb_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) def handle_consume_skb(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) (name, context, cpu, time, pid, comm, skbaddr) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) for i in range(len(tx_xmit_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) skb = tx_xmit_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) if skb['skbaddr'] == skbaddr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) skb['free_t'] = time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) tx_free_list.append(skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) del tx_xmit_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) def handle_skb_copy_datagram_iovec(event_info):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) (name, context, cpu, time, pid, comm, skbaddr, skblen) = event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) for i in range(len(rx_skb_list)):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) rec_data = rx_skb_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) if skbaddr == rec_data['skbaddr']:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) rec_data.update({'handle':"skb_copy_datagram_iovec",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 'comm':comm, 'pid':pid, 'comm_t':time})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) del rx_skb_list[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return