xref: /xnu-10002.81.5/tools/trace/kqtrace.lua (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions#!/usr/local/bin/luatrace -s
2*5e3eaea3SApple OSS Distributions
3*5e3eaea3SApple OSS Distributionstrace_eventname = function(codename, callback)
4*5e3eaea3SApple OSS Distributions	local debugid = trace.debugid(codename)
5*5e3eaea3SApple OSS Distributions	if debugid ~= 0 then
6*5e3eaea3SApple OSS Distributions		trace.single(debugid,callback)
7*5e3eaea3SApple OSS Distributions	else
8*5e3eaea3SApple OSS Distributions		printf("WARNING: Cannot locate debugid for '%s'\n", codename)
9*5e3eaea3SApple OSS Distributions	end
10*5e3eaea3SApple OSS Distributionsend
11*5e3eaea3SApple OSS Distributions
12*5e3eaea3SApple OSS Distributionsinitial_timestamp = 0
13*5e3eaea3SApple OSS Distributions
14*5e3eaea3SApple OSS Distributionsfunction event_prefix_string(buf, workq)
15*5e3eaea3SApple OSS Distributions	if initial_timestamp == 0 then
16*5e3eaea3SApple OSS Distributions		initial_timestamp = buf.timestamp
17*5e3eaea3SApple OSS Distributions	end
18*5e3eaea3SApple OSS Distributions	local secs = trace.convert_timestamp_to_nanoseconds(buf.timestamp - initial_timestamp) / 1000000000
19*5e3eaea3SApple OSS Distributions
20*5e3eaea3SApple OSS Distributions	local type
21*5e3eaea3SApple OSS Distributions	if trace.debugid_is_start(buf.debugid) then
22*5e3eaea3SApple OSS Distributions		type = "→"
23*5e3eaea3SApple OSS Distributions	elseif trace.debugid_is_end(buf.debugid) then
24*5e3eaea3SApple OSS Distributions		type = "←"
25*5e3eaea3SApple OSS Distributions	else
26*5e3eaea3SApple OSS Distributions		type = "↔"
27*5e3eaea3SApple OSS Distributions	end
28*5e3eaea3SApple OSS Distributions
29*5e3eaea3SApple OSS Distributions	proc = buf.command
30*5e3eaea3SApple OSS Distributions
31*5e3eaea3SApple OSS Distributions	local prefix = string.format("%s %6.9f %-17s [%05d.%06x] %-28s\t",
32*5e3eaea3SApple OSS Distributions		type, secs, proc, buf.pid, buf.threadid, buf.debugname)
33*5e3eaea3SApple OSS Distributions	if not workq then
34*5e3eaea3SApple OSS Distributions		prefix = prefix .. string.format(" 0x%16x", buf.arg1)
35*5e3eaea3SApple OSS Distributions	end
36*5e3eaea3SApple OSS Distributions
37*5e3eaea3SApple OSS Distributions	return prefix
38*5e3eaea3SApple OSS Distributionsend
39*5e3eaea3SApple OSS Distributions
40*5e3eaea3SApple OSS Distributionsfunction qos_string(qos)
41*5e3eaea3SApple OSS Distributions	if qos == 0 then
42*5e3eaea3SApple OSS Distributions		return "--"
43*5e3eaea3SApple OSS Distributions	elseif qos == 1 then
44*5e3eaea3SApple OSS Distributions		return "MT"
45*5e3eaea3SApple OSS Distributions	elseif qos == 2 then
46*5e3eaea3SApple OSS Distributions		return "BG"
47*5e3eaea3SApple OSS Distributions	elseif qos == 3 then
48*5e3eaea3SApple OSS Distributions		return "UT"
49*5e3eaea3SApple OSS Distributions	elseif qos == 4 then
50*5e3eaea3SApple OSS Distributions		return "DF"
51*5e3eaea3SApple OSS Distributions	elseif qos == 5 then
52*5e3eaea3SApple OSS Distributions		return "IN"
53*5e3eaea3SApple OSS Distributions	elseif qos == 6 then
54*5e3eaea3SApple OSS Distributions		return "UI"
55*5e3eaea3SApple OSS Distributions	elseif qos == 7 then
56*5e3eaea3SApple OSS Distributions		return "MG"
57*5e3eaea3SApple OSS Distributions	else
58*5e3eaea3SApple OSS Distributions		return string.format("??[0x%x]", qos)
59*5e3eaea3SApple OSS Distributions	end
60*5e3eaea3SApple OSS Distributionsend
61*5e3eaea3SApple OSS Distributions
62*5e3eaea3SApple OSS Distributionsfunction state_string(strings, state)
63*5e3eaea3SApple OSS Distributions	local str = ''
64*5e3eaea3SApple OSS Distributions	local first = true
65*5e3eaea3SApple OSS Distributions	for name, bit in pairs(strings) do
66*5e3eaea3SApple OSS Distributions		if (state & bit) == bit then
67*5e3eaea3SApple OSS Distributions			if not first then
68*5e3eaea3SApple OSS Distributions				str = str .. ' '
69*5e3eaea3SApple OSS Distributions			end
70*5e3eaea3SApple OSS Distributions			str = str .. name
71*5e3eaea3SApple OSS Distributions			first = false
72*5e3eaea3SApple OSS Distributions		end
73*5e3eaea3SApple OSS Distributions	end
74*5e3eaea3SApple OSS Distributions	return str
75*5e3eaea3SApple OSS Distributionsend
76*5e3eaea3SApple OSS Distributions
77*5e3eaea3SApple OSS Distributionskqrequest_state_strings = {
78*5e3eaea3SApple OSS Distributions	['WAKEUP'] = 1,
79*5e3eaea3SApple OSS Distributions}
80*5e3eaea3SApple OSS Distributions
81*5e3eaea3SApple OSS Distributionskqueue_state_strings = {
82*5e3eaea3SApple OSS Distributions	['SEL'] = 0x001,
83*5e3eaea3SApple OSS Distributions	['SLEEP'] = 0x002,
84*5e3eaea3SApple OSS Distributions	['PROCWAIT'] = 0x004,
85*5e3eaea3SApple OSS Distributions	['KEV32'] = 0x008,
86*5e3eaea3SApple OSS Distributions	['KEV64'] = 0x010,
87*5e3eaea3SApple OSS Distributions	['KEV_QOS'] = 0x020,
88*5e3eaea3SApple OSS Distributions	['WORKQ'] = 0x040,
89*5e3eaea3SApple OSS Distributions	['WORKLOOP'] = 0x080,
90*5e3eaea3SApple OSS Distributions	['PROCESSING'] = 0x100,
91*5e3eaea3SApple OSS Distributions	['DRAIN'] = 0x200,
92*5e3eaea3SApple OSS Distributions	['WAKEUP'] = 0x400,
93*5e3eaea3SApple OSS Distributions	['DYNAMIC'] = 0x800,
94*5e3eaea3SApple OSS Distributions	['R2K'] = 0x1000,
95*5e3eaea3SApple OSS Distributions	['TURNSTILE'] = 0x2000,
96*5e3eaea3SApple OSS Distributions}
97*5e3eaea3SApple OSS Distributions
98*5e3eaea3SApple OSS Distributionsknote_state_strings = {
99*5e3eaea3SApple OSS Distributions	['ACTIVE'] = 0x0001,
100*5e3eaea3SApple OSS Distributions	['QUEUED'] = 0x0002,
101*5e3eaea3SApple OSS Distributions	['DISABLED'] = 0x0004,
102*5e3eaea3SApple OSS Distributions	['DROPPING'] = 0x0008,
103*5e3eaea3SApple OSS Distributions	['LOCKED'] = 0x0010,
104*5e3eaea3SApple OSS Distributions	['POSTING'] = 0x0020,
105*5e3eaea3SApple OSS Distributions	['STAYACTIVE'] = 0x0040,
106*5e3eaea3SApple OSS Distributions	['DEFERDELETE'] = 0x0080,
107*5e3eaea3SApple OSS Distributions	['MERGE_QOS'] = 0x0100,
108*5e3eaea3SApple OSS Distributions	['REQVANISH'] = 0x0200,
109*5e3eaea3SApple OSS Distributions	['VANISHED'] = 0x0400,
110*5e3eaea3SApple OSS Distributions	['SUPPRESSED'] = 0x0800,
111*5e3eaea3SApple OSS Distributions}
112*5e3eaea3SApple OSS Distributions
113*5e3eaea3SApple OSS Distributionskevent_flags_strings = {
114*5e3eaea3SApple OSS Distributions	['ADD'] = 0x0001,
115*5e3eaea3SApple OSS Distributions	['DELETE'] = 0x0002,
116*5e3eaea3SApple OSS Distributions	['ENABLE'] = 0x0004,
117*5e3eaea3SApple OSS Distributions	['DISABLE'] = 0x0008,
118*5e3eaea3SApple OSS Distributions	['ONESHOT'] = 0x0010,
119*5e3eaea3SApple OSS Distributions	['CLEAR'] = 0x0020,
120*5e3eaea3SApple OSS Distributions	['RECEIPT'] = 0x0040,
121*5e3eaea3SApple OSS Distributions	['DISPATCH'] = 0x0080,
122*5e3eaea3SApple OSS Distributions	['UDATA_SPECIFIC'] = 0x0100,
123*5e3eaea3SApple OSS Distributions	['VANISHED'] = 0x0200,
124*5e3eaea3SApple OSS Distributions	['FLAG0'] = 0x1000,
125*5e3eaea3SApple OSS Distributions	['FLAG1'] = 0x2000,
126*5e3eaea3SApple OSS Distributions	['EOF'] = 0x8000,
127*5e3eaea3SApple OSS Distributions	['ERROR'] = 0x4000,
128*5e3eaea3SApple OSS Distributions}
129*5e3eaea3SApple OSS Distributions
130*5e3eaea3SApple OSS Distributionsfunction kevent_filter_string(filt)
131*5e3eaea3SApple OSS Distributions	if filt == -1 then
132*5e3eaea3SApple OSS Distributions		return 'READ'
133*5e3eaea3SApple OSS Distributions	elseif filt == -2 then
134*5e3eaea3SApple OSS Distributions		return 'WRITE'
135*5e3eaea3SApple OSS Distributions	elseif filt == -3 then
136*5e3eaea3SApple OSS Distributions		return 'AIO'
137*5e3eaea3SApple OSS Distributions	elseif filt == -4 then
138*5e3eaea3SApple OSS Distributions		return 'VNODE'
139*5e3eaea3SApple OSS Distributions	elseif filt == -5 then
140*5e3eaea3SApple OSS Distributions		return 'PROC'
141*5e3eaea3SApple OSS Distributions	elseif filt == -6 then
142*5e3eaea3SApple OSS Distributions		return 'SIGNAL'
143*5e3eaea3SApple OSS Distributions	elseif filt == -7 then
144*5e3eaea3SApple OSS Distributions		return 'TIMER'
145*5e3eaea3SApple OSS Distributions	elseif filt == -8 then
146*5e3eaea3SApple OSS Distributions		return 'MACHPORT'
147*5e3eaea3SApple OSS Distributions	elseif filt == -9 then
148*5e3eaea3SApple OSS Distributions		return 'FS'
149*5e3eaea3SApple OSS Distributions	elseif filt == -10 then
150*5e3eaea3SApple OSS Distributions		return 'USER'
151*5e3eaea3SApple OSS Distributions	-- -11 unused
152*5e3eaea3SApple OSS Distributions	elseif filt == -12 then
153*5e3eaea3SApple OSS Distributions		return 'VM'
154*5e3eaea3SApple OSS Distributions	elseif filt == -13 then
155*5e3eaea3SApple OSS Distributions		return 'SOCK'
156*5e3eaea3SApple OSS Distributions	elseif filt == -14 then
157*5e3eaea3SApple OSS Distributions		return 'MEMORYSTATUS'
158*5e3eaea3SApple OSS Distributions	elseif filt == -15 then
159*5e3eaea3SApple OSS Distributions		return 'EXCEPT'
160*5e3eaea3SApple OSS Distributions	elseif filt == -16 then
161*5e3eaea3SApple OSS Distributions		return 'NW_CHANNEL'
162*5e3eaea3SApple OSS Distributions	elseif filt == -17 then
163*5e3eaea3SApple OSS Distributions		return 'WORKLOOP'
164*5e3eaea3SApple OSS Distributions
165*5e3eaea3SApple OSS Distributions	elseif filt == 17 then
166*5e3eaea3SApple OSS Distributions		return 'KQREAD'
167*5e3eaea3SApple OSS Distributions	elseif filt == 18 then
168*5e3eaea3SApple OSS Distributions		return 'PIPE_N'
169*5e3eaea3SApple OSS Distributions	elseif filt == 19 then
170*5e3eaea3SApple OSS Distributions		return 'PIPE_R'
171*5e3eaea3SApple OSS Distributions	elseif filt == 20 then
172*5e3eaea3SApple OSS Distributions		return 'PIPE_W'
173*5e3eaea3SApple OSS Distributions	elseif filt == 21 then
174*5e3eaea3SApple OSS Distributions		return 'PTSD'
175*5e3eaea3SApple OSS Distributions	elseif filt == 22 then
176*5e3eaea3SApple OSS Distributions		return 'SOREAD'
177*5e3eaea3SApple OSS Distributions	elseif filt == 23 then
178*5e3eaea3SApple OSS Distributions		return 'SOWRITE'
179*5e3eaea3SApple OSS Distributions	elseif filt == 24 then
180*5e3eaea3SApple OSS Distributions		return 'SCK'
181*5e3eaea3SApple OSS Distributions	elseif filt == 25 then
182*5e3eaea3SApple OSS Distributions		return 'SOEXCEPT'
183*5e3eaea3SApple OSS Distributions	elseif filt == 26 then
184*5e3eaea3SApple OSS Distributions		return 'SPEC'
185*5e3eaea3SApple OSS Distributions	elseif filt == 27 then
186*5e3eaea3SApple OSS Distributions		return 'BPFREAD'
187*5e3eaea3SApple OSS Distributions	elseif filt == 28 then
188*5e3eaea3SApple OSS Distributions		return 'NECP_FD'
189*5e3eaea3SApple OSS Distributions	elseif filt == 29 then
190*5e3eaea3SApple OSS Distributions		return 'SKYWALK_CHANNEL_W'
191*5e3eaea3SApple OSS Distributions	elseif filt == 30 then
192*5e3eaea3SApple OSS Distributions		return 'SKYWALK_CHANNEL_R'
193*5e3eaea3SApple OSS Distributions	elseif filt == 31 then
194*5e3eaea3SApple OSS Distributions		return 'SKYWALK_CHANNEL_E'
195*5e3eaea3SApple OSS Distributions	elseif filt == 32 then
196*5e3eaea3SApple OSS Distributions		return 'FSEVENT'
197*5e3eaea3SApple OSS Distributions	elseif filt == 33 then
198*5e3eaea3SApple OSS Distributions		return 'VN'
199*5e3eaea3SApple OSS Distributions	elseif filt == 34 then
200*5e3eaea3SApple OSS Distributions		return 'TTY'
201*5e3eaea3SApple OSS Distributions	elseif filt == 35 then
202*5e3eaea3SApple OSS Distributions		return 'PTMX'
203*5e3eaea3SApple OSS Distributions	elseif filt == 36 then
204*5e3eaea3SApple OSS Distributions		return 'DETACHED'
205*5e3eaea3SApple OSS Distributions	else
206*5e3eaea3SApple OSS Distributions		return string.format('[%d]', filt)
207*5e3eaea3SApple OSS Distributions	end
208*5e3eaea3SApple OSS Distributionsend
209*5e3eaea3SApple OSS Distributions
210*5e3eaea3SApple OSS Distributions-- kqueue lifecycle
211*5e3eaea3SApple OSS Distributions
212*5e3eaea3SApple OSS Distributionsfunction processing_begin(workq)
213*5e3eaea3SApple OSS Distributions	return function(buf)
214*5e3eaea3SApple OSS Distributions		local prefix = event_prefix_string(buf, workq)
215*5e3eaea3SApple OSS Distributions		if trace.debugid_is_start(buf.debugid) then
216*5e3eaea3SApple OSS Distributions			local qos
217*5e3eaea3SApple OSS Distributions			if workq then
218*5e3eaea3SApple OSS Distributions				qos = buf.arg2
219*5e3eaea3SApple OSS Distributions			else
220*5e3eaea3SApple OSS Distributions				qos = buf.arg3
221*5e3eaea3SApple OSS Distributions			end
222*5e3eaea3SApple OSS Distributions			printf("%s QoS = %s\n", prefix, qos_string(qos))
223*5e3eaea3SApple OSS Distributions		else
224*5e3eaea3SApple OSS Distributions			printf("%s request thread = 0x%x, kqrequest state = %s\n", prefix,
225*5e3eaea3SApple OSS Distributions					buf.arg1, state_string(kqrequest_state_strings, buf.arg2))
226*5e3eaea3SApple OSS Distributions		end
227*5e3eaea3SApple OSS Distributions	end
228*5e3eaea3SApple OSS Distributionsend
229*5e3eaea3SApple OSS Distributions
230*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kq_processing_begin", processing_begin(false))
231*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwq_processing_begin", processing_begin(true))
232*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_processing_begin", processing_begin(false))
233*5e3eaea3SApple OSS Distributions
234*5e3eaea3SApple OSS Distributionsfunction processing_end(workq)
235*5e3eaea3SApple OSS Distributions	return function(buf)
236*5e3eaea3SApple OSS Distributions		local qos
237*5e3eaea3SApple OSS Distributions		if workq then
238*5e3eaea3SApple OSS Distributions			qos = buf.arg2
239*5e3eaea3SApple OSS Distributions		else
240*5e3eaea3SApple OSS Distributions			qos = buf.arg3
241*5e3eaea3SApple OSS Distributions		end
242*5e3eaea3SApple OSS Distributions		printf("%s QoS = %s\n", event_prefix_string(buf, workq), qos_string(qos))
243*5e3eaea3SApple OSS Distributions	end
244*5e3eaea3SApple OSS Distributionsend
245*5e3eaea3SApple OSS Distributions
246*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kq_processing_end", processing_end(false))
247*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwq_processing_end", processing_end(true))
248*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_processing_end", processing_end(false))
249*5e3eaea3SApple OSS Distributions
250*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwq_bind", function(buf)
251*5e3eaea3SApple OSS Distributions	printf("%s thread = 0x%x, QoS = %s, kqrequest state = %s\n",
252*5e3eaea3SApple OSS Distributions			event_prefix_string(buf, true), buf.arg1, qos_string(buf.arg3),
253*5e3eaea3SApple OSS Distributions			state_string(kqrequest_state_strings, buf.arg4))
254*5e3eaea3SApple OSS Distributionsend)
255*5e3eaea3SApple OSS Distributions
256*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwq_unbind", function(buf)
257*5e3eaea3SApple OSS Distributions	printf("%s thread = 0x%x, QoS = %s\n", event_prefix_string(buf, true),
258*5e3eaea3SApple OSS Distributions			buf.arg1, qos_string(buf.arg3))
259*5e3eaea3SApple OSS Distributionsend)
260*5e3eaea3SApple OSS Distributions
261*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_bind", function(buf)
262*5e3eaea3SApple OSS Distributions	qos = buf.arg3 & 0xff
263*5e3eaea3SApple OSS Distributions	duplicate = buf.arg3 & (1 << 8)
264*5e3eaea3SApple OSS Distributions	kqr_override_qos_delta = buf.arg4 >> 8
265*5e3eaea3SApple OSS Distributions	kqr_state = buf.arg4 & 0xff
266*5e3eaea3SApple OSS Distributions
267*5e3eaea3SApple OSS Distributions	printf("%s thread = 0x%x, QoS = %s, override QoS delta = %d, kqrequest state = %s%s\n",
268*5e3eaea3SApple OSS Distributions			event_prefix_string(buf, false), buf.arg2, qos_string(qos),
269*5e3eaea3SApple OSS Distributions			kqr_override_qos_delta,
270*5e3eaea3SApple OSS Distributions			state_string(kqrequest_state_strings, kqr_state),
271*5e3eaea3SApple OSS Distributions			duplicate and ", duplicate" or "")
272*5e3eaea3SApple OSS Distributionsend)
273*5e3eaea3SApple OSS Distributions
274*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_unbind", function(buf)
275*5e3eaea3SApple OSS Distributions	flags = buf.arg3
276*5e3eaea3SApple OSS Distributions	qos = buf.arg4
277*5e3eaea3SApple OSS Distributions
278*5e3eaea3SApple OSS Distributions	printf("%s thread = 0x%x, QoS = %s, flags = 0x%x\n", event_prefix_string(buf, false),
279*5e3eaea3SApple OSS Distributions			buf.arg2, qos_string(qos), flags)
280*5e3eaea3SApple OSS Distributionsend)
281*5e3eaea3SApple OSS Distributions
282*5e3eaea3SApple OSS Distributionsfunction thread_request(workq)
283*5e3eaea3SApple OSS Distributions	return function(buf)
284*5e3eaea3SApple OSS Distributions		printf("%s QoS = %s, kqrequest state = %s, override QoS delta = %d\n",
285*5e3eaea3SApple OSS Distributions				event_prefix_string(buf, workq), qos_string(buf.arg2),
286*5e3eaea3SApple OSS Distributions				state_string(kqrequest_state_strings, buf.arg3), buf.arg3 >> 8)
287*5e3eaea3SApple OSS Distributions	end
288*5e3eaea3SApple OSS Distributionsend
289*5e3eaea3SApple OSS Distributions
290*5e3eaea3SApple OSS Distributionsfunction thread_adjust(buf)
291*5e3eaea3SApple OSS Distributions	tid = buf.arg2
292*5e3eaea3SApple OSS Distributions	kqr_qos = buf.arg3 >> 8
293*5e3eaea3SApple OSS Distributions	new_qos = buf.arg3 & 0xff
294*5e3eaea3SApple OSS Distributions	kqr_qos_override = buf.arg4 >> 8
295*5e3eaea3SApple OSS Distributions	kqr_state = buf.arg4 & 0xff
296*5e3eaea3SApple OSS Distributions
297*5e3eaea3SApple OSS Distributions	printf("%s thread = 0x%x, old/new QoS = %s/%s, old/new override QoS delta = %d/%d, kqrequest state = %s\n",
298*5e3eaea3SApple OSS Distributions			event_prefix_string(buf, false),
299*5e3eaea3SApple OSS Distributions			tid,
300*5e3eaea3SApple OSS Distributions			qos_string(kqr_qos),
301*5e3eaea3SApple OSS Distributions			qos_string(new_qos),
302*5e3eaea3SApple OSS Distributions			kqr_qos_override,
303*5e3eaea3SApple OSS Distributions			new_qos - kqr_qos,
304*5e3eaea3SApple OSS Distributions			state_string(kqrequest_state_strings, kqr_state))
305*5e3eaea3SApple OSS Distributionsend
306*5e3eaea3SApple OSS Distributions
307*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwq_thread_request", thread_request(true))
308*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_thread_request", thread_request(false))
309*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_thread_adjust", thread_adjust)
310*5e3eaea3SApple OSS Distributions
311*5e3eaea3SApple OSS Distributionsfunction kevent_register(workq)
312*5e3eaea3SApple OSS Distributions	return function(buf)
313*5e3eaea3SApple OSS Distributions		printf("%s kevent udata = 0x%x, kevent filter = %s, kevent flags = %s\n",
314*5e3eaea3SApple OSS Distributions				event_prefix_string(buf, workq), buf.arg2,
315*5e3eaea3SApple OSS Distributions				kevent_filter_string(buf.arg4),
316*5e3eaea3SApple OSS Distributions				state_string(kevent_flags_strings, buf.arg3))
317*5e3eaea3SApple OSS Distributions	end
318*5e3eaea3SApple OSS Distributionsend
319*5e3eaea3SApple OSS Distributions
320*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kq_register", kevent_register(false))
321*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwq_register", kevent_register(true))
322*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_register", kevent_register(false))
323*5e3eaea3SApple OSS Distributions
324*5e3eaea3SApple OSS Distributionsfunction kevent_process(workq)
325*5e3eaea3SApple OSS Distributions	return function(buf)
326*5e3eaea3SApple OSS Distributions		printf("%s kevent ident = 0x%x, udata = 0x%x, kevent filter = %s, knote status = %s\n",
327*5e3eaea3SApple OSS Distributions				event_prefix_string(buf, workq), buf.arg3 >> 32, buf.arg2,
328*5e3eaea3SApple OSS Distributions				kevent_filter_string(buf.arg4),
329*5e3eaea3SApple OSS Distributions				state_string(knote_state_strings, buf.arg3 & 0xffffffff))
330*5e3eaea3SApple OSS Distributions	end
331*5e3eaea3SApple OSS Distributionsend
332*5e3eaea3SApple OSS Distributions
333*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kq_process", kevent_process(false))
334*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwq_process", kevent_process(true))
335*5e3eaea3SApple OSS Distributionstrace_eventname("KEVENT_kqwl_process", kevent_process(false))
336