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) # report time spent in compaction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # Licensed under the terms of the GNU GPL License version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) # testing:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) # 'echo 1 > /proc/sys/vm/compact_memory' to force compaction of all zones
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) import os
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) import sys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) import re
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) import signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) signal.signal(signal.SIGPIPE, signal.SIG_DFL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) usage = "usage: perf script report compaction-times.py -- [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) class popt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	DISP_DFL = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	DISP_PROC = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	DISP_PROC_VERBOSE=2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) class topt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	DISP_TIME = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	DISP_MIG = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	DISP_ISOLFREE = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	DISP_ISOLMIG = 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	DISP_ALL = 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) class comm_filter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	def __init__(self, re):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		self.re = re
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	def filter(self, pid, comm):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		m = self.re.search(comm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		return m == None or m.group() == ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) class pid_filter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	def __init__(self, low, high):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		self.low = (0 if low == "" else int(low))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		self.high = (0 if high == "" else int(high))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	def filter(self, pid, comm):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		return not (pid >= self.low and (self.high == 0 or pid <= self.high))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) def set_type(t):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	global opt_disp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	opt_disp = (t if opt_disp == topt.DISP_ALL else opt_disp|t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) def ns(sec, nsec):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	return (sec * 1000000000) + nsec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) def time(ns):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	return "%dns" % ns if opt_ns else "%dus" % (round(ns, -3) / 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) class pair:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	def __init__(self, aval, bval, alabel = None, blabel = None):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		self.alabel = alabel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		self.blabel = blabel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		self.aval = aval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		self.bval = bval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	def __add__(self, rhs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		self.aval += rhs.aval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		self.bval += rhs.bval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		return self
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	def __str__(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		return "%s=%d %s=%d" % (self.alabel, self.aval, self.blabel, self.bval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) class cnode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	def __init__(self, ns):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		self.ns = ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		self.migrated = pair(0, 0, "moved", "failed")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		self.fscan = pair(0,0, "scanned", "isolated")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		self.mscan = pair(0,0, "scanned", "isolated")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	def __add__(self, rhs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		self.ns += rhs.ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		self.migrated += rhs.migrated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		self.fscan += rhs.fscan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		self.mscan += rhs.mscan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		return self
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	def __str__(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		prev = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		s = "%s " % time(self.ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		if (opt_disp & topt.DISP_MIG):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			s += "migration: %s" % self.migrated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			prev = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		if (opt_disp & topt.DISP_ISOLFREE):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			s += "%sfree_scanner: %s" % (" " if prev else "", self.fscan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			prev = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (opt_disp & topt.DISP_ISOLMIG):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			s += "%smigration_scanner: %s" % (" " if prev else "", self.mscan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		return s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	def complete(self, secs, nsecs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		self.ns = ns(secs, nsecs) - self.ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	def increment(self, migrated, fscan, mscan):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		if (migrated != None):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			self.migrated += migrated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		if (fscan != None):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			self.fscan += fscan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		if (mscan != None):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			self.mscan += mscan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) class chead:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	heads = {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	val = cnode(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	fobj = None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	@classmethod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	def add_filter(cls, filter):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		cls.fobj = filter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	@classmethod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	def create_pending(cls, pid, comm, start_secs, start_nsecs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		filtered = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		try:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			head = cls.heads[pid]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			filtered = head.is_filtered()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		except KeyError:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			if cls.fobj != None:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				filtered = cls.fobj.filter(pid, comm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			head = cls.heads[pid] = chead(comm, pid, filtered)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		if not filtered:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			head.mark_pending(start_secs, start_nsecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	@classmethod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	def increment_pending(cls, pid, migrated, fscan, mscan):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		head = cls.heads[pid]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		if not head.is_filtered():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			if head.is_pending():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 				head.do_increment(migrated, fscan, mscan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 				sys.stderr.write("missing start compaction event for pid %d\n" % pid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	@classmethod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	def complete_pending(cls, pid, secs, nsecs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		head = cls.heads[pid]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		if not head.is_filtered():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			if head.is_pending():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 				head.make_complete(secs, nsecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 				sys.stderr.write("missing start compaction event for pid %d\n" % pid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	@classmethod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	def gen(cls):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		if opt_proc != popt.DISP_DFL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			for i in cls.heads:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				yield cls.heads[i]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	@classmethod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	def str(cls):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		return cls.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	def __init__(self, comm, pid, filtered):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		self.comm = comm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		self.pid = pid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		self.val = cnode(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		self.pending = None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		self.filtered = filtered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		self.list = []
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	def __add__(self, rhs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		self.ns += rhs.ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		self.val += rhs.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		return self
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	def mark_pending(self, secs, nsecs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		self.pending = cnode(ns(secs, nsecs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	def do_increment(self, migrated, fscan, mscan):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		self.pending.increment(migrated, fscan, mscan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	def make_complete(self, secs, nsecs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		self.pending.complete(secs, nsecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		chead.val += self.pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		if opt_proc != popt.DISP_DFL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			self.val += self.pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			if opt_proc == popt.DISP_PROC_VERBOSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				self.list.append(self.pending)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		self.pending = None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	def enumerate(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		if opt_proc == popt.DISP_PROC_VERBOSE and not self.is_filtered():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			for i, pelem in enumerate(self.list):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 				sys.stdout.write("%d[%s].%d: %s\n" % (self.pid, self.comm, i+1, pelem))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	def is_pending(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		return self.pending != None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	def is_filtered(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		return self.filtered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	def display(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		if not self.is_filtered():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			sys.stdout.write("%d[%s]: %s\n" % (self.pid, self.comm, self.val))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) def trace_end():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	sys.stdout.write("total: %s\n" % chead.str())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	for i in chead.gen():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		i.display(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		i.enumerate()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) def compaction__mm_compaction_migratepages(event_name, context, common_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	common_secs, common_nsecs, common_pid, common_comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	common_callchain, nr_migrated, nr_failed):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	chead.increment_pending(common_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		pair(nr_migrated, nr_failed), None, None)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	common_secs, common_nsecs, common_pid, common_comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	chead.increment_pending(common_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		None, pair(nr_scanned, nr_taken), None)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	common_secs, common_nsecs, common_pid, common_comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	chead.increment_pending(common_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		None, None, pair(nr_scanned, nr_taken))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) def compaction__mm_compaction_end(event_name, context, common_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	common_secs, common_nsecs, common_pid, common_comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	common_callchain, zone_start, migrate_start, free_start, zone_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	sync, status):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	chead.complete_pending(common_pid, common_secs, common_nsecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) def compaction__mm_compaction_begin(event_name, context, common_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	common_secs, common_nsecs, common_pid, common_comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	common_callchain, zone_start, migrate_start, free_start, zone_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	sync):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	chead.create_pending(common_pid, common_comm, common_secs, common_nsecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) def pr_help():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	global usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	sys.stdout.write(usage)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	sys.stdout.write("\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	sys.stdout.write("-h	display this help\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	sys.stdout.write("-p	display by process\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	sys.stdout.write("-pv	display by process (verbose)\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	sys.stdout.write("-t	display stall times only\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	sys.stdout.write("-m	display stats for migration\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	sys.stdout.write("-fs	display stats for free scanner\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	sys.stdout.write("-ms	display stats for migration scanner\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	sys.stdout.write("-u	display results in microseconds (default nanoseconds)\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) comm_re = None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) pid_re = None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) pid_regex = "^(\d*)-(\d*)$|^(\d*)$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) opt_proc = popt.DISP_DFL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) opt_disp = topt.DISP_ALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) opt_ns = True
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) argc = len(sys.argv) - 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if argc >= 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	pid_re = re.compile(pid_regex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	for i, opt in enumerate(sys.argv[1:]):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		if opt[0] == "-":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			if opt == "-h":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 				pr_help()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 				exit(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			elif opt == "-p":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 				opt_proc = popt.DISP_PROC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			elif opt == "-pv":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 				opt_proc = popt.DISP_PROC_VERBOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			elif opt == '-u':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 				opt_ns = False
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			elif opt == "-t":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 				set_type(topt.DISP_TIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			elif opt == "-m":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 				set_type(topt.DISP_MIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			elif opt == "-fs":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 				set_type(topt.DISP_ISOLFREE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 			elif opt == "-ms":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 				set_type(topt.DISP_ISOLMIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				sys.exit(usage)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		elif i == argc - 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			m = pid_re.search(opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			if m != None and m.group() != "":
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 				if m.group(3) != None:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 					f = pid_filter(m.group(3), m.group(3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 				else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 					f = pid_filter(m.group(1), m.group(2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 				try:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 					comm_re=re.compile(opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 				except:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 					sys.stderr.write("invalid regex '%s'" % opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 					sys.exit(usage)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 				f = comm_filter(comm_re)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			chead.add_filter(f)