xref: /xnu-10063.141.1/tests/kqworkloop_limits.c (revision d8b80295118ef25ac3a784134bcf95cd8e88109f)
1*d8b80295SApple OSS Distributions #include <darwintest.h>
2*d8b80295SApple OSS Distributions #include <mach/mach.h>
3*d8b80295SApple OSS Distributions #include <stdlib.h>
4*d8b80295SApple OSS Distributions #include <stdio.h>
5*d8b80295SApple OSS Distributions #include <sys/sysctl.h>
6*d8b80295SApple OSS Distributions #include <unistd.h>
7*d8b80295SApple OSS Distributions #include <darwintest_multiprocess.h>
8*d8b80295SApple OSS Distributions #include <spawn.h>
9*d8b80295SApple OSS Distributions #include <spawn_private.h>
10*d8b80295SApple OSS Distributions #include <libproc_internal.h>
11*d8b80295SApple OSS Distributions #include <signal.h>
12*d8b80295SApple OSS Distributions #include <string.h>
13*d8b80295SApple OSS Distributions 
14*d8b80295SApple OSS Distributions #include <err.h>
15*d8b80295SApple OSS Distributions #include <stdio.h>
16*d8b80295SApple OSS Distributions #include <sysexits.h>
17*d8b80295SApple OSS Distributions #include <stdbool.h>
18*d8b80295SApple OSS Distributions 
19*d8b80295SApple OSS Distributions #include "kqwl_rnServer.h"         // generated by MIG from rnserver.defs
20*d8b80295SApple OSS Distributions 
21*d8b80295SApple OSS Distributions #include <servers/bootstrap.h>
22*d8b80295SApple OSS Distributions #include <libproc_internal.h>       // proc*cpumon*()
23*d8b80295SApple OSS Distributions 
24*d8b80295SApple OSS Distributions T_GLOBAL_META(
25*d8b80295SApple OSS Distributions 	T_META_NAMESPACE("xnu.kevent"),
26*d8b80295SApple OSS Distributions 	T_META_RUN_CONCURRENTLY(TRUE),
27*d8b80295SApple OSS Distributions 	T_META_RADAR_COMPONENT_NAME("xnu"),
28*d8b80295SApple OSS Distributions 	T_META_RADAR_COMPONENT_VERSION("kevent"));
29*d8b80295SApple OSS Distributions 
30*d8b80295SApple OSS Distributions #define TEST_PROGRAM_NAME "./kqworkloop_limits_client"
31*d8b80295SApple OSS Distributions #define MAX_ARGV 5
32*d8b80295SApple OSS Distributions 
33*d8b80295SApple OSS Distributions extern char **environ;
34*d8b80295SApple OSS Distributions 
35*d8b80295SApple OSS Distributions static int
spawn_child_process_with_limits(int soft_limit,int hard_limit,int test_num)36*d8b80295SApple OSS Distributions spawn_child_process_with_limits(int soft_limit, int hard_limit, int test_num)
37*d8b80295SApple OSS Distributions {
38*d8b80295SApple OSS Distributions 	char *child_args[MAX_ARGV];
39*d8b80295SApple OSS Distributions 	int child_pid;
40*d8b80295SApple OSS Distributions 	posix_spawnattr_t attrs;
41*d8b80295SApple OSS Distributions 	int err;
42*d8b80295SApple OSS Distributions 
43*d8b80295SApple OSS Distributions 	/* Initialize posix_spawn attributes */
44*d8b80295SApple OSS Distributions 	posix_spawnattr_init(&attrs);
45*d8b80295SApple OSS Distributions 
46*d8b80295SApple OSS Distributions 	err = posix_spawnattr_set_kqworklooplimit_ext(&attrs, soft_limit, hard_limit);
47*d8b80295SApple OSS Distributions 	T_EXPECT_POSIX_SUCCESS(err, "posix_spawnattr_set_kqworklooplimit_ext");
48*d8b80295SApple OSS Distributions 
49*d8b80295SApple OSS Distributions 	char soft_limit_str[32];
50*d8b80295SApple OSS Distributions 	sprintf(soft_limit_str, "%d", soft_limit);
51*d8b80295SApple OSS Distributions 
52*d8b80295SApple OSS Distributions 	char hard_limit_str[32];
53*d8b80295SApple OSS Distributions 	sprintf(hard_limit_str, "%d", hard_limit);
54*d8b80295SApple OSS Distributions 
55*d8b80295SApple OSS Distributions 	char test_num_str[32];
56*d8b80295SApple OSS Distributions 	sprintf(test_num_str, "%d", test_num);
57*d8b80295SApple OSS Distributions 
58*d8b80295SApple OSS Distributions 	child_args[0] = TEST_PROGRAM_NAME;
59*d8b80295SApple OSS Distributions 	child_args[1] = soft_limit_str; // soft limit
60*d8b80295SApple OSS Distributions 	child_args[2] = hard_limit_str; // hard limit
61*d8b80295SApple OSS Distributions 	child_args[3] = test_num_str; // test num
62*d8b80295SApple OSS Distributions 	child_args[4] = NULL;
63*d8b80295SApple OSS Distributions 
64*d8b80295SApple OSS Distributions 	err = posix_spawn(&child_pid, child_args[0], NULL, &attrs, child_args, environ);
65*d8b80295SApple OSS Distributions 	T_EXPECT_POSIX_SUCCESS(err, "posix_spawn kqworkloop_limits_client");
66*d8b80295SApple OSS Distributions 	return child_pid;
67*d8b80295SApple OSS Distributions }
68*d8b80295SApple OSS Distributions 
69*d8b80295SApple OSS Distributions T_DECL(test_kqworkloop_soft_limit, "Allocate kqworkloops up to soft limit",
70*d8b80295SApple OSS Distributions     T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"), T_META_CHECK_LEAKS(false))
71*d8b80295SApple OSS Distributions {
72*d8b80295SApple OSS Distributions #if TARGET_OS_BRIDGE
73*d8b80295SApple OSS Distributions 	T_SKIP("Not running on target platforms");
74*d8b80295SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
75*d8b80295SApple OSS Distributions 
76*d8b80295SApple OSS Distributions 	int child_pid = spawn_child_process_with_limits(200, 0, 1);
77*d8b80295SApple OSS Distributions 
78*d8b80295SApple OSS Distributions 	int child_status;
79*d8b80295SApple OSS Distributions 	/* Wait for child and check for exception */
80*d8b80295SApple OSS Distributions 	if (-1 == waitpid(child_pid, &child_status, 0)) {
81*d8b80295SApple OSS Distributions 		T_FAIL("waitpid: child mia");
82*d8b80295SApple OSS Distributions 	}
83*d8b80295SApple OSS Distributions 
84*d8b80295SApple OSS Distributions 	if (WIFSIGNALED(child_status)) {
85*d8b80295SApple OSS Distributions 		T_FAIL("Child exited with signal = %d", WTERMSIG(child_status));
86*d8b80295SApple OSS Distributions 	}
87*d8b80295SApple OSS Distributions 
88*d8b80295SApple OSS Distributions 	T_ASSERT_EQ(WIFEXITED(child_status), 1, "Child exited normally with exit value %d", WEXITSTATUS(child_status));
89*d8b80295SApple OSS Distributions }
90*d8b80295SApple OSS Distributions 
91*d8b80295SApple OSS Distributions T_DECL(test_kqworkloop_hard_limit, "Allocate kqworkloops up to hard limit",
92*d8b80295SApple OSS Distributions     T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"), T_META_CHECK_LEAKS(false))
93*d8b80295SApple OSS Distributions {
94*d8b80295SApple OSS Distributions #if TARGET_OS_BRIDGE
95*d8b80295SApple OSS Distributions 	T_SKIP("Not running on target platforms");
96*d8b80295SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
97*d8b80295SApple OSS Distributions 
98*d8b80295SApple OSS Distributions 	int child_pid = spawn_child_process_with_limits(0, 500, 1);
99*d8b80295SApple OSS Distributions 
100*d8b80295SApple OSS Distributions 	int child_status;
101*d8b80295SApple OSS Distributions 	/* Wait for child and check for exception */
102*d8b80295SApple OSS Distributions 	if (-1 == waitpid(child_pid, &child_status, 0)) {
103*d8b80295SApple OSS Distributions 		T_FAIL("waitpid: child mia");
104*d8b80295SApple OSS Distributions 	}
105*d8b80295SApple OSS Distributions 
106*d8b80295SApple OSS Distributions 	T_ASSERT_EQ(WIFEXITED(child_status), 0, "Child did not exit normally");
107*d8b80295SApple OSS Distributions 
108*d8b80295SApple OSS Distributions 	if (WIFSIGNALED(child_status)) {
109*d8b80295SApple OSS Distributions 		T_ASSERT_EQ(child_status, 9, "Child exited with status = %x", child_status);
110*d8b80295SApple OSS Distributions 	}
111*d8b80295SApple OSS Distributions }
112*d8b80295SApple OSS Distributions 
113*d8b80295SApple OSS Distributions T_DECL(test_kqworkloop_soft_and_hard_limit, "Allocate kqworkloops with soft and hard limit",
114*d8b80295SApple OSS Distributions     T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"), T_META_CHECK_LEAKS(false))
115*d8b80295SApple OSS Distributions {
116*d8b80295SApple OSS Distributions #if TARGET_OS_BRIDGE
117*d8b80295SApple OSS Distributions 	T_SKIP("Not running on target platforms");
118*d8b80295SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
119*d8b80295SApple OSS Distributions 
120*d8b80295SApple OSS Distributions 	int child_pid = spawn_child_process_with_limits(250, 500, 1);
121*d8b80295SApple OSS Distributions 
122*d8b80295SApple OSS Distributions 	int child_status;
123*d8b80295SApple OSS Distributions 	/* Wait for child and check for exception */
124*d8b80295SApple OSS Distributions 	if (-1 == waitpid(child_pid, &child_status, 0)) {
125*d8b80295SApple OSS Distributions 		T_FAIL("waitpid: child mia");
126*d8b80295SApple OSS Distributions 	}
127*d8b80295SApple OSS Distributions 
128*d8b80295SApple OSS Distributions 	T_ASSERT_EQ(WIFEXITED(child_status), 0, "Child did not exit normally");
129*d8b80295SApple OSS Distributions 
130*d8b80295SApple OSS Distributions 	if (WIFSIGNALED(child_status)) {
131*d8b80295SApple OSS Distributions 		T_ASSERT_EQ(child_status, 9, "Child exited with status = %x", child_status);
132*d8b80295SApple OSS Distributions 	}
133*d8b80295SApple OSS Distributions }
134*d8b80295SApple OSS Distributions 
135*d8b80295SApple OSS Distributions // Tests which define a resource notify server and verify that the soft/hard
136*d8b80295SApple OSS Distributions // limit violations are correctly delivered to the server
137*d8b80295SApple OSS Distributions 
138*d8b80295SApple OSS Distributions typedef struct {
139*d8b80295SApple OSS Distributions 	mach_msg_header_t   header;
140*d8b80295SApple OSS Distributions 	mach_msg_body_t     body;
141*d8b80295SApple OSS Distributions 	mach_msg_port_descriptor_t port_descriptor;
142*d8b80295SApple OSS Distributions 	mach_msg_trailer_t  trailer;            // subtract this when sending
143*d8b80295SApple OSS Distributions } ipc_complex_message;
144*d8b80295SApple OSS Distributions 
145*d8b80295SApple OSS Distributions struct args {
146*d8b80295SApple OSS Distributions 	const char *progname;
147*d8b80295SApple OSS Distributions 	int verbose;
148*d8b80295SApple OSS Distributions 	int voucher;
149*d8b80295SApple OSS Distributions 	int num_msgs;
150*d8b80295SApple OSS Distributions 	const char *server_port_name;
151*d8b80295SApple OSS Distributions 	mach_port_t server_port;
152*d8b80295SApple OSS Distributions 	mach_port_t reply_port;
153*d8b80295SApple OSS Distributions 	int request_msg_size;
154*d8b80295SApple OSS Distributions 	void *request_msg;
155*d8b80295SApple OSS Distributions 	int reply_msg_size;
156*d8b80295SApple OSS Distributions 	void *reply_msg;
157*d8b80295SApple OSS Distributions 	uint32_t persona_id;
158*d8b80295SApple OSS Distributions 	long client_pid;
159*d8b80295SApple OSS Distributions };
160*d8b80295SApple OSS Distributions 
161*d8b80295SApple OSS Distributions void parse_args(struct args *args);
162*d8b80295SApple OSS Distributions void server_setup(struct args* args);
163*d8b80295SApple OSS Distributions void* exception_server_thread(void *arg);
164*d8b80295SApple OSS Distributions mach_port_t create_exception_port(void);
165*d8b80295SApple OSS Distributions static mach_port_t create_resource_notify_port(void);
166*d8b80295SApple OSS Distributions static ipc_complex_message icm_request = {};
167*d8b80295SApple OSS Distributions static ipc_complex_message icm_reply = {};
168*d8b80295SApple OSS Distributions static mach_port_t resource_notify_port = MACH_PORT_NULL;
169*d8b80295SApple OSS Distributions 
170*d8b80295SApple OSS Distributions #define TEST_TIMEOUT    10
171*d8b80295SApple OSS Distributions 
172*d8b80295SApple OSS Distributions void
setup_server_args(struct args * args)173*d8b80295SApple OSS Distributions setup_server_args(struct args *args)
174*d8b80295SApple OSS Distributions {
175*d8b80295SApple OSS Distributions 	args->server_port_name = "TEST_KQWORKLOOP_LIMITS";
176*d8b80295SApple OSS Distributions 	args->server_port = MACH_PORT_NULL;
177*d8b80295SApple OSS Distributions 	args->reply_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
178*d8b80295SApple OSS Distributions 	args->request_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
179*d8b80295SApple OSS Distributions 	args->reply_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
180*d8b80295SApple OSS Distributions 	args->request_msg = &icm_request;
181*d8b80295SApple OSS Distributions 	args->reply_msg = &icm_reply;
182*d8b80295SApple OSS Distributions }
183*d8b80295SApple OSS Distributions 
184*d8b80295SApple OSS Distributions /* Create a mach IPC listener which will respond to the client's message */
185*d8b80295SApple OSS Distributions void
server_setup(struct args * args)186*d8b80295SApple OSS Distributions server_setup(struct args *args)
187*d8b80295SApple OSS Distributions {
188*d8b80295SApple OSS Distributions 	kern_return_t ret;
189*d8b80295SApple OSS Distributions 	mach_port_t bsport;
190*d8b80295SApple OSS Distributions 
191*d8b80295SApple OSS Distributions 	ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
192*d8b80295SApple OSS Distributions 	    &args->server_port);
193*d8b80295SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(ret, "server: mach_port_allocate()");
194*d8b80295SApple OSS Distributions 
195*d8b80295SApple OSS Distributions 	ret = mach_port_insert_right(mach_task_self(), args->server_port, args->server_port,
196*d8b80295SApple OSS Distributions 	    MACH_MSG_TYPE_MAKE_SEND);
197*d8b80295SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(ret, "server: mach_port_insert_right()");
198*d8b80295SApple OSS Distributions 
199*d8b80295SApple OSS Distributions 	ret = task_get_bootstrap_port(mach_task_self(), &bsport);
200*d8b80295SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(ret, "server: task_get_bootstrap_port()");
201*d8b80295SApple OSS Distributions 
202*d8b80295SApple OSS Distributions 	ret = bootstrap_register(bsport, (const char *)args->server_port_name, args->server_port);
203*d8b80295SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(ret, "server: bootstrap_register()");
204*d8b80295SApple OSS Distributions 
205*d8b80295SApple OSS Distributions 	T_LOG("server: waiting for IPC messages from client on port '%s'.\n",
206*d8b80295SApple OSS Distributions 	    args->server_port_name);
207*d8b80295SApple OSS Distributions 
208*d8b80295SApple OSS Distributions 	/* Make the server port as the resource notify port */
209*d8b80295SApple OSS Distributions 	resource_notify_port = args->server_port;
210*d8b80295SApple OSS Distributions }
211*d8b80295SApple OSS Distributions 
212*d8b80295SApple OSS Distributions T_DECL(test_kqworkloop_hard_limit_with_resource_notify_port,
213*d8b80295SApple OSS Distributions     "Allocate kqworkloops up to hard limit and trigger notification",
214*d8b80295SApple OSS Distributions     T_META_IGNORECRASHES(".*kqworkloop_limits_client.*"), T_META_CHECK_LEAKS(false))
215*d8b80295SApple OSS Distributions {
216*d8b80295SApple OSS Distributions #if TARGET_OS_BRIDGE
217*d8b80295SApple OSS Distributions 	T_SKIP("Not running on target platforms");
218*d8b80295SApple OSS Distributions #endif /* TARGET_OS_BRIDGE */
219*d8b80295SApple OSS Distributions 	struct args*            server_args = (struct args*)malloc(sizeof(struct args));
220*d8b80295SApple OSS Distributions 
221*d8b80295SApple OSS Distributions 	/* Create the bootstrap port */
222*d8b80295SApple OSS Distributions 	setup_server_args(server_args);
223*d8b80295SApple OSS Distributions 	server_setup(server_args);
224*d8b80295SApple OSS Distributions 
225*d8b80295SApple OSS Distributions 	server_args->client_pid = spawn_child_process_with_limits(0, 500, 2);
226*d8b80295SApple OSS Distributions 
227*d8b80295SApple OSS Distributions 	T_LOG("server: Let's see if we can catch some kqworkloop leak");
228*d8b80295SApple OSS Distributions 
229*d8b80295SApple OSS Distributions 	kern_return_t kr = mach_msg_server_once(resource_notify_server, 4096, resource_notify_port, 0);
230*d8b80295SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_msg_server_once resource_notify_port");
231*d8b80295SApple OSS Distributions }
232*d8b80295SApple OSS Distributions 
233*d8b80295SApple OSS Distributions // MIG's resource_notify_server() expects receive_cpu_usage_triggers as well
234*d8b80295SApple OSS Distributions // This must match the definition in xnu's resource_notify.defs
235*d8b80295SApple OSS Distributions kern_return_t
receive_cpu_usage_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_cpu_nsecs,__unused int64_t observation_nsecs,__unused int64_t cpu_nsecs_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)236*d8b80295SApple OSS Distributions receive_cpu_usage_violation(__unused mach_port_t receiver,
237*d8b80295SApple OSS Distributions     __unused proc_name_t procname,
238*d8b80295SApple OSS Distributions     __unused pid_t pid,
239*d8b80295SApple OSS Distributions     __unused posix_path_t killed_proc_path,
240*d8b80295SApple OSS Distributions     __unused mach_timespec_t timestamp,
241*d8b80295SApple OSS Distributions     __unused int64_t observed_cpu_nsecs,
242*d8b80295SApple OSS Distributions     __unused int64_t observation_nsecs,
243*d8b80295SApple OSS Distributions     __unused int64_t cpu_nsecs_allowed,
244*d8b80295SApple OSS Distributions     __unused int64_t limit_window_nsecs,
245*d8b80295SApple OSS Distributions     __unused resource_notify_flags_t flags)
246*d8b80295SApple OSS Distributions {
247*d8b80295SApple OSS Distributions 	return KERN_FAILURE;
248*d8b80295SApple OSS Distributions }
249*d8b80295SApple OSS Distributions 
250*d8b80295SApple OSS Distributions kern_return_t
receive_cpu_wakes_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_cpu_wakes,__unused int64_t observation_nsecs,__unused int64_t cpu_wakes_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)251*d8b80295SApple OSS Distributions receive_cpu_wakes_violation(__unused mach_port_t receiver,
252*d8b80295SApple OSS Distributions     __unused proc_name_t procname,
253*d8b80295SApple OSS Distributions     __unused pid_t pid,
254*d8b80295SApple OSS Distributions     __unused posix_path_t killed_proc_path,
255*d8b80295SApple OSS Distributions     __unused mach_timespec_t timestamp,
256*d8b80295SApple OSS Distributions     __unused int64_t observed_cpu_wakes,
257*d8b80295SApple OSS Distributions     __unused int64_t observation_nsecs,
258*d8b80295SApple OSS Distributions     __unused int64_t cpu_wakes_allowed,
259*d8b80295SApple OSS Distributions     __unused int64_t limit_window_nsecs,
260*d8b80295SApple OSS Distributions     __unused resource_notify_flags_t flags)
261*d8b80295SApple OSS Distributions {
262*d8b80295SApple OSS Distributions 	return KERN_FAILURE;
263*d8b80295SApple OSS Distributions }
264*d8b80295SApple OSS Distributions 
265*d8b80295SApple OSS Distributions kern_return_t
receive_disk_writes_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_bytes_dirtied,__unused int64_t observation_nsecs,__unused int64_t bytes_dirtied_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)266*d8b80295SApple OSS Distributions receive_disk_writes_violation(__unused mach_port_t receiver,
267*d8b80295SApple OSS Distributions     __unused proc_name_t procname,
268*d8b80295SApple OSS Distributions     __unused pid_t pid,
269*d8b80295SApple OSS Distributions     __unused posix_path_t killed_proc_path,
270*d8b80295SApple OSS Distributions     __unused mach_timespec_t timestamp,
271*d8b80295SApple OSS Distributions     __unused int64_t observed_bytes_dirtied,
272*d8b80295SApple OSS Distributions     __unused int64_t observation_nsecs,
273*d8b80295SApple OSS Distributions     __unused int64_t bytes_dirtied_allowed,
274*d8b80295SApple OSS Distributions     __unused int64_t limit_window_nsecs,
275*d8b80295SApple OSS Distributions     __unused resource_notify_flags_t flags)
276*d8b80295SApple OSS Distributions {
277*d8b80295SApple OSS Distributions 	return KERN_FAILURE;
278*d8b80295SApple OSS Distributions }
279*d8b80295SApple OSS Distributions 
280*d8b80295SApple OSS Distributions kern_return_t
receive_port_space_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,__unused int64_t observed_ports,__unused int64_t ports_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)281*d8b80295SApple OSS Distributions receive_port_space_violation(__unused mach_port_t receiver,
282*d8b80295SApple OSS Distributions     __unused proc_name_t procname,
283*d8b80295SApple OSS Distributions     __unused pid_t pid,
284*d8b80295SApple OSS Distributions     __unused mach_timespec_t timestamp,
285*d8b80295SApple OSS Distributions     __unused int64_t observed_ports,
286*d8b80295SApple OSS Distributions     __unused int64_t ports_allowed,
287*d8b80295SApple OSS Distributions     __unused mach_port_t fatal_port,
288*d8b80295SApple OSS Distributions     __unused resource_notify_flags_t flags)
289*d8b80295SApple OSS Distributions {
290*d8b80295SApple OSS Distributions 	return KERN_FAILURE;
291*d8b80295SApple OSS Distributions }
292*d8b80295SApple OSS Distributions 
293*d8b80295SApple OSS Distributions kern_return_t
receive_file_descriptors_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,__unused int64_t observed_filedesc,__unused int64_t filedesc_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)294*d8b80295SApple OSS Distributions receive_file_descriptors_violation(__unused mach_port_t receiver,
295*d8b80295SApple OSS Distributions     __unused proc_name_t procname,
296*d8b80295SApple OSS Distributions     __unused pid_t pid,
297*d8b80295SApple OSS Distributions     __unused mach_timespec_t timestamp,
298*d8b80295SApple OSS Distributions     __unused int64_t observed_filedesc,
299*d8b80295SApple OSS Distributions     __unused int64_t filedesc_allowed,
300*d8b80295SApple OSS Distributions     __unused mach_port_t fatal_port,
301*d8b80295SApple OSS Distributions     __unused resource_notify_flags_t flags)
302*d8b80295SApple OSS Distributions {
303*d8b80295SApple OSS Distributions 	return KERN_FAILURE;
304*d8b80295SApple OSS Distributions }
305*d8b80295SApple OSS Distributions 
306*d8b80295SApple OSS Distributions kern_return_t
receive_kqworkloops_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,__unused int64_t observed_kqworkloops,__unused int64_t kqworkloops_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)307*d8b80295SApple OSS Distributions receive_kqworkloops_violation( __unused mach_port_t receiver,
308*d8b80295SApple OSS Distributions     __unused proc_name_t procname,
309*d8b80295SApple OSS Distributions     __unused pid_t pid,
310*d8b80295SApple OSS Distributions     __unused mach_timespec_t timestamp,
311*d8b80295SApple OSS Distributions     __unused int64_t observed_kqworkloops,
312*d8b80295SApple OSS Distributions     __unused int64_t kqworkloops_allowed,
313*d8b80295SApple OSS Distributions     __unused mach_port_t fatal_port,
314*d8b80295SApple OSS Distributions     __unused resource_notify_flags_t flags)
315*d8b80295SApple OSS Distributions {
316*d8b80295SApple OSS Distributions 	T_LOG("Received a notification on the resource notify port");
317*d8b80295SApple OSS Distributions 	T_LOG("kqworkloops_allowed = %lld, kqworkloops observed = %lld", kqworkloops_allowed, observed_kqworkloops);
318*d8b80295SApple OSS Distributions 	if (fatal_port) {
319*d8b80295SApple OSS Distributions 		mach_port_deallocate(mach_task_self(), fatal_port);
320*d8b80295SApple OSS Distributions 	}
321*d8b80295SApple OSS Distributions 	return KERN_SUCCESS;
322*d8b80295SApple OSS Distributions }
323