Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) # system call counts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) # (c) 2010, Tom Zanussi <tzanussi@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) # Licensed under the terms of the GNU GPL License version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) # Displays system-wide system call totals, broken down by syscall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) # If a [comm] arg is specified, only syscalls called by [comm] are displayed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) from __future__ import print_function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) import os
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) import sys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) sys.path.append(os.environ['PERF_EXEC_PATH'] + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) from perf_trace_context import *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) from Core import *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) from Util import syscall_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) usage = "perf script -s syscall-counts.py [comm]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) for_comm = None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) if len(sys.argv) > 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	sys.exit(usage)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if len(sys.argv) > 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	for_comm = sys.argv[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) syscalls = autodict()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) def trace_begin():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	print("Press control+C to stop and show the summary")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) def trace_end():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	print_syscall_totals()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) def raw_syscalls__sys_enter(event_name, context, common_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		common_secs, common_nsecs, common_pid, common_comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		common_callchain, id, args):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	if for_comm is not None:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		if common_comm != for_comm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 			return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	try:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		syscalls[id] += 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	except TypeError:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		syscalls[id] = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) def syscalls__sys_enter(event_name, context, common_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		common_secs, common_nsecs, common_pid, common_comm, id, args):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	raw_syscalls__sys_enter(**locals())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) def print_syscall_totals():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	if for_comm is not None:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		print("\nsyscall events for %s:\n" % (for_comm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		print("\nsyscall events:\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	print("%-40s  %10s" % ("event", "count"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	print("%-40s  %10s" % ("----------------------------------------",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 				"-----------"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	for id, val in sorted(syscalls.items(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 			key = lambda kv: (kv[1], kv[0]), reverse = True):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		print("%-40s  %10d" % (syscall_name(id), val))