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

TOMOYO Linux Cross Reference
Linux/tools/perf/scripts/python/sctop.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/sctop.py (Architecture mips) and /tools/perf/scripts/python/sctop.py (Architecture m68k)


  1 # system call top                                   1 # system call top
  2 # (c) 2010, Tom Zanussi <tzanussi@gmail.com>         2 # (c) 2010, Tom Zanussi <tzanussi@gmail.com>
  3 # Licensed under the terms of the GNU GPL Lice      3 # Licensed under the terms of the GNU GPL License version 2
  4 #                                                   4 #
  5 # Periodically displays system-wide system cal      5 # Periodically displays system-wide system call totals, broken down by
  6 # syscall.  If a [comm] arg is specified, only      6 # syscall.  If a [comm] arg is specified, only syscalls called by
  7 # [comm] are displayed. If an [interval] arg i      7 # [comm] are displayed. If an [interval] arg is specified, the display
  8 # will be refreshed every [interval] seconds.       8 # will be refreshed every [interval] seconds.  The default interval is
  9 # 3 seconds.                                        9 # 3 seconds.
 10                                                    10 
 11 from __future__ import print_function              11 from __future__ import print_function
 12                                                    12 
 13 import os, sys, time                               13 import os, sys, time
 14                                                    14 
 15 try:                                               15 try:
 16         import thread                              16         import thread
 17 except ImportError:                                17 except ImportError:
 18         import _thread as thread                   18         import _thread as thread
 19                                                    19 
 20 sys.path.append(os.environ['PERF_EXEC_PATH'] +     20 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 21         '/scripts/python/Perf-Trace-Util/lib/P     21         '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
 22                                                    22 
 23 from perf_trace_context import *                   23 from perf_trace_context import *
 24 from Core import *                                 24 from Core import *
 25 from Util import *                                 25 from Util import *
 26                                                    26 
 27 usage = "perf script -s sctop.py [comm] [inter     27 usage = "perf script -s sctop.py [comm] [interval]\n";
 28                                                    28 
 29 for_comm = None                                    29 for_comm = None
 30 default_interval = 3                               30 default_interval = 3
 31 interval = default_interval                        31 interval = default_interval
 32                                                    32 
 33 if len(sys.argv) > 3:                              33 if len(sys.argv) > 3:
 34         sys.exit(usage)                            34         sys.exit(usage)
 35                                                    35 
 36 if len(sys.argv) > 2:                              36 if len(sys.argv) > 2:
 37         for_comm = sys.argv[1]                     37         for_comm = sys.argv[1]
 38         interval = int(sys.argv[2])                38         interval = int(sys.argv[2])
 39 elif len(sys.argv) > 1:                            39 elif len(sys.argv) > 1:
 40         try:                                       40         try:
 41                 interval = int(sys.argv[1])        41                 interval = int(sys.argv[1])
 42         except ValueError:                         42         except ValueError:
 43                 for_comm = sys.argv[1]             43                 for_comm = sys.argv[1]
 44                 interval = default_interval        44                 interval = default_interval
 45                                                    45 
 46 syscalls = autodict()                              46 syscalls = autodict()
 47                                                    47 
 48 def trace_begin():                                 48 def trace_begin():
 49         thread.start_new_thread(print_syscall_     49         thread.start_new_thread(print_syscall_totals, (interval,))
 50         pass                                       50         pass
 51                                                    51 
 52 def raw_syscalls__sys_enter(event_name, contex     52 def raw_syscalls__sys_enter(event_name, context, common_cpu,
 53         common_secs, common_nsecs, common_pid,     53         common_secs, common_nsecs, common_pid, common_comm,
 54         common_callchain, id, args):               54         common_callchain, id, args):
 55         if for_comm is not None:                   55         if for_comm is not None:
 56                 if common_comm != for_comm:        56                 if common_comm != for_comm:
 57                         return                     57                         return
 58         try:                                       58         try:
 59                 syscalls[id] += 1                  59                 syscalls[id] += 1
 60         except TypeError:                          60         except TypeError:
 61                 syscalls[id] = 1                   61                 syscalls[id] = 1
 62                                                    62 
 63 def syscalls__sys_enter(event_name, context, c     63 def syscalls__sys_enter(event_name, context, common_cpu,
 64         common_secs, common_nsecs, common_pid,     64         common_secs, common_nsecs, common_pid, common_comm,
 65         id, args):                                 65         id, args):
 66         raw_syscalls__sys_enter(**locals())        66         raw_syscalls__sys_enter(**locals())
 67                                                    67 
 68 def print_syscall_totals(interval):                68 def print_syscall_totals(interval):
 69         while 1:                                   69         while 1:
 70                 clear_term()                       70                 clear_term()
 71                 if for_comm is not None:           71                 if for_comm is not None:
 72                         print("\nsyscall event     72                         print("\nsyscall events for %s:\n" % (for_comm))
 73                 else:                              73                 else:
 74                         print("\nsyscall event     74                         print("\nsyscall events:\n")
 75                                                    75 
 76                 print("%-40s  %10s" % ("event"     76                 print("%-40s  %10s" % ("event", "count"))
 77                 print("%-40s  %10s" %              77                 print("%-40s  %10s" %
 78                         ("--------------------     78                         ("----------------------------------------",
 79                         "----------"))             79                         "----------"))
 80                                                    80 
 81                 for id, val in sorted(syscalls     81                 for id, val in sorted(syscalls.items(),
 82                                 key = lambda k     82                                 key = lambda kv: (kv[1], kv[0]),
 83                                 reverse = True     83                                 reverse = True):
 84                         try:                       84                         try:
 85                                 print("%-40s       85                                 print("%-40s  %10d" % (syscall_name(id), val))
 86                         except TypeError:          86                         except TypeError:
 87                                 pass               87                                 pass
 88                 syscalls.clear()                   88                 syscalls.clear()
 89                 time.sleep(interval)               89                 time.sleep(interval)
                                                      

~ [ 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