~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/scripts/python/net_dropmonitor.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/scripts/python/net_dropmonitor.py (Architecture i386) and /tools/perf/scripts/python/net_dropmonitor.py (Architecture ppc)


  1 # Monitor the system for dropped packets and p      1 # Monitor the system for dropped packets and proudce a report of drop locations and counts
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3                                                     3 
  4 from __future__ import print_function               4 from __future__ import print_function
  5                                                     5 
  6 import os                                           6 import os
  7 import sys                                          7 import sys
  8                                                     8 
  9 sys.path.append(os.environ['PERF_EXEC_PATH'] +      9 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 10         '/scripts/python/Perf-Trace-Util/lib/P     10         '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
 11                                                    11 
 12 from perf_trace_context import *                   12 from perf_trace_context import *
 13 from Core import *                                 13 from Core import *
 14 from Util import *                                 14 from Util import *
 15                                                    15 
 16 drop_log = {}                                      16 drop_log = {}
 17 kallsyms = []                                      17 kallsyms = []
 18                                                    18 
 19 def get_kallsyms_table():                          19 def get_kallsyms_table():
 20         global kallsyms                            20         global kallsyms
 21                                                    21 
 22         try:                                       22         try:
 23                 f = open("/proc/kallsyms", "r"     23                 f = open("/proc/kallsyms", "r")
 24         except:                                    24         except:
 25                 return                             25                 return
 26                                                    26 
 27         for line in f:                             27         for line in f:
 28                 loc = int(line.split()[0], 16)     28                 loc = int(line.split()[0], 16)
 29                 name = line.split()[2]             29                 name = line.split()[2]
 30                 kallsyms.append((loc, name))       30                 kallsyms.append((loc, name))
 31         kallsyms.sort()                            31         kallsyms.sort()
 32                                                    32 
 33 def get_sym(sloc):                                 33 def get_sym(sloc):
 34         loc = int(sloc)                            34         loc = int(sloc)
 35                                                    35 
 36         # Invariant: kallsyms[i][0] <= loc for     36         # Invariant: kallsyms[i][0] <= loc for all 0 <= i <= start
 37         #            kallsyms[i][0] > loc for      37         #            kallsyms[i][0] > loc for all end <= i < len(kallsyms)
 38         start, end = -1, len(kallsyms)             38         start, end = -1, len(kallsyms)
 39         while end != start + 1:                    39         while end != start + 1:
 40                 pivot = (start + end) // 2         40                 pivot = (start + end) // 2
 41                 if loc < kallsyms[pivot][0]:       41                 if loc < kallsyms[pivot][0]:
 42                         end = pivot                42                         end = pivot
 43                 else:                              43                 else:
 44                         start = pivot              44                         start = pivot
 45                                                    45 
 46         # Now (start == -1 or kallsyms[start][     46         # Now (start == -1 or kallsyms[start][0] <= loc)
 47         # and (start == len(kallsyms) - 1 or l     47         # and (start == len(kallsyms) - 1 or loc < kallsyms[start + 1][0])
 48         if start >= 0:                             48         if start >= 0:
 49                 symloc, name = kallsyms[start]     49                 symloc, name = kallsyms[start]
 50                 return (name, loc - symloc)        50                 return (name, loc - symloc)
 51         else:                                      51         else:
 52                 return (None, 0)                   52                 return (None, 0)
 53                                                    53 
 54 def print_drop_table():                            54 def print_drop_table():
 55         print("%25s %25s %25s" % ("LOCATION",      55         print("%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT"))
 56         for i in drop_log.keys():                  56         for i in drop_log.keys():
 57                 (sym, off) = get_sym(i)            57                 (sym, off) = get_sym(i)
 58                 if sym == None:                    58                 if sym == None:
 59                         sym = i                    59                         sym = i
 60                 print("%25s %25s %25s" % (sym,     60                 print("%25s %25s %25s" % (sym, off, drop_log[i]))
 61                                                    61 
 62                                                    62 
 63 def trace_begin():                                 63 def trace_begin():
 64         print("Starting trace (Ctrl-C to dump      64         print("Starting trace (Ctrl-C to dump results)")
 65                                                    65 
 66 def trace_end():                                   66 def trace_end():
 67         print("Gathering kallsyms data")           67         print("Gathering kallsyms data")
 68         get_kallsyms_table()                       68         get_kallsyms_table()
 69         print_drop_table()                         69         print_drop_table()
 70                                                    70 
 71 # called from perf, when it finds a correspond     71 # called from perf, when it finds a corresponding event
 72 def skb__kfree_skb(name, context, cpu, sec, ns     72 def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
 73                    skbaddr, location, protocol     73                    skbaddr, location, protocol, reason):
 74         slocation = str(location)                  74         slocation = str(location)
 75         try:                                       75         try:
 76                 drop_log[slocation] = drop_log     76                 drop_log[slocation] = drop_log[slocation] + 1
 77         except:                                    77         except:
 78                 drop_log[slocation] = 1            78                 drop_log[slocation] = 1
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php