]>
Commit | Line | Data |
---|---|---|
39236c6e A |
1 | /* |
2 | * Copyright (c) 2012 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
0a7de745 | 5 | * |
39236c6e A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
0a7de745 | 14 | * |
39236c6e A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
39236c6e A |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
0a7de745 | 25 | * |
39236c6e A |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ | |
28 | ||
29 | #include <kern/debug.h> | |
fe8ab488 | 30 | #include <kern/kalloc.h> |
39236c6e A |
31 | #include <sys/param.h> |
32 | #include <sys/mman.h> | |
33 | #include <sys/stat.h> | |
34 | #include <sys/sysctl.h> | |
35 | #include <libkern/libkern.h> | |
36 | #include <kern/assert.h> | |
37 | ||
38 | #include <kern/kpc.h> | |
39037602 | 39 | #include <sys/ktrace.h> |
39236c6e A |
40 | |
41 | #include <pexpert/pexpert.h> | |
8a3053a0 | 42 | #include <kperf/kperf.h> |
39236c6e A |
43 | |
44 | /* Various sysctl requests */ | |
45 | #define REQ_CLASSES (1) | |
46 | #define REQ_COUNTING (2) | |
47 | #define REQ_THREAD_COUNTING (3) | |
48 | #define REQ_CONFIG_COUNT (4) | |
49 | #define REQ_COUNTER_COUNT (5) | |
50 | #define REQ_THREAD_COUNTERS (6) | |
51 | #define REQ_COUNTERS (7) | |
52 | #define REQ_SHADOW_COUNTERS (8) | |
53 | #define REQ_CONFIG (9) | |
54 | #define REQ_PERIOD (10) | |
55 | #define REQ_ACTIONID (11) | |
fe8ab488 | 56 | #define REQ_SW_INC (14) |
3e170ce0 | 57 | #define REQ_PMU_VERSION (15) |
39236c6e A |
58 | |
59 | /* Type-munging casts */ | |
60 | typedef int (*getint_t)(void); | |
61 | typedef int (*setint_t)(int); | |
62 | ||
39236c6e A |
63 | static int kpc_initted = 0; |
64 | ||
c3c9b80d A |
65 | static LCK_GRP_DECLARE(sysctl_lckgrp, "kpc"); |
66 | static LCK_MTX_DECLARE(sysctl_lock, &sysctl_lckgrp); | |
5ba3f43e | 67 | |
d9a64523 A |
68 | /* |
69 | * Another element is needed to hold the CPU number when getting counter values. | |
70 | */ | |
71 | #define KPC_MAX_BUF_LEN (KPC_MAX_COUNTERS_COPIED + 1) | |
39236c6e A |
72 | |
73 | typedef int (*setget_func_t)(int); | |
74 | ||
39236c6e A |
75 | void |
76 | kpc_init(void) | |
77 | { | |
39236c6e | 78 | kpc_arch_init(); |
39236c6e A |
79 | |
80 | kpc_initted = 1; | |
81 | } | |
82 | ||
d9a64523 A |
83 | static uint64_t * |
84 | kpc_get_bigarray(uint32_t *size_out) | |
85 | { | |
86 | static uint64_t *bigarray = NULL; | |
87 | ||
88 | LCK_MTX_ASSERT(&sysctl_lock, LCK_MTX_ASSERT_OWNED); | |
89 | ||
90 | uint32_t size = kpc_get_counterbuf_size() + sizeof(uint64_t); | |
91 | *size_out = size; | |
92 | ||
93 | if (bigarray) { | |
94 | return bigarray; | |
95 | } | |
96 | ||
97 | /* | |
98 | * Another element is needed to hold the CPU number when getting counter | |
99 | * values. | |
100 | */ | |
f427ee49 A |
101 | bigarray = kheap_alloc_tag(KHEAP_DATA_BUFFERS, size, |
102 | Z_WAITOK, VM_KERN_MEMORY_DIAG); | |
d9a64523 A |
103 | assert(bigarray != NULL); |
104 | return bigarray; | |
105 | } | |
106 | ||
39236c6e A |
107 | /* abstract sysctl handlers */ |
108 | static int | |
109 | sysctl_get_int( struct sysctl_oid *oidp, struct sysctl_req *req, | |
0a7de745 | 110 | uint32_t value ) |
39236c6e A |
111 | { |
112 | int error = 0; | |
0a7de745 | 113 | |
39236c6e A |
114 | /* copy out the old value */ |
115 | error = sysctl_handle_int(oidp, &value, 0, req); | |
0a7de745 | 116 | |
39236c6e A |
117 | return error; |
118 | } | |
119 | ||
fe8ab488 A |
120 | static int |
121 | sysctl_set_int( struct sysctl_req *req, int (*set_func)(int)) | |
122 | { | |
123 | int error = 0; | |
124 | int value = 0; | |
0a7de745 A |
125 | |
126 | error = SYSCTL_IN( req, &value, sizeof(value)); | |
127 | if (error) { | |
fe8ab488 | 128 | return error; |
0a7de745 A |
129 | } |
130 | ||
fe8ab488 A |
131 | error = set_func( value ); |
132 | ||
133 | return error; | |
134 | } | |
135 | ||
39236c6e A |
136 | static int |
137 | sysctl_getset_int( struct sysctl_oid *oidp, struct sysctl_req *req, | |
0a7de745 | 138 | int (*get_func)(void), int (*set_func)(int)) |
39236c6e A |
139 | { |
140 | int error = 0; | |
141 | uint32_t value = 0; | |
0a7de745 | 142 | |
39236c6e A |
143 | /* get the old value and process it */ |
144 | value = get_func(); | |
145 | ||
146 | /* copy out the old value, get the new value */ | |
147 | error = sysctl_handle_int(oidp, &value, 0, req); | |
0a7de745 A |
148 | if (error || !req->newptr) { |
149 | return error; | |
150 | } | |
39236c6e A |
151 | |
152 | /* if that worked, and we're writing... */ | |
153 | error = set_func( value ); | |
154 | ||
155 | return error; | |
156 | } | |
157 | ||
fe8ab488 | 158 | |
39236c6e A |
159 | static int |
160 | sysctl_setget_int( struct sysctl_req *req, | |
0a7de745 | 161 | int (*setget_func)(int)) |
39236c6e A |
162 | { |
163 | int error = 0; | |
164 | int value = 0; | |
0a7de745 A |
165 | |
166 | error = SYSCTL_IN( req, &value, sizeof(value)); | |
167 | if (error) { | |
39236c6e | 168 | return error; |
0a7de745 A |
169 | } |
170 | ||
39236c6e A |
171 | value = setget_func(value); |
172 | ||
0a7de745 | 173 | error = SYSCTL_OUT( req, &value, sizeof(value)); |
39236c6e A |
174 | |
175 | return error; | |
176 | } | |
177 | ||
178 | static int | |
39236c6e | 179 | sysctl_kpc_get_counters(uint32_t counters, |
0a7de745 | 180 | uint32_t *size, void *buf) |
39236c6e A |
181 | { |
182 | uint64_t *ctr_buf = (uint64_t*)buf; | |
183 | int curcpu; | |
184 | uint32_t count; | |
185 | ||
186 | count = kpc_get_cpu_counters(counters & KPC_ALL_CPUS, | |
0a7de745 A |
187 | counters, |
188 | &curcpu, &ctr_buf[1]); | |
189 | if (!count) { | |
39236c6e | 190 | return EINVAL; |
0a7de745 | 191 | } |
39236c6e A |
192 | |
193 | ctr_buf[0] = curcpu; | |
194 | ||
0a7de745 | 195 | *size = (count + 1) * sizeof(uint64_t); |
39236c6e A |
196 | |
197 | return 0; | |
198 | } | |
199 | ||
0a7de745 | 200 | static int |
39236c6e | 201 | sysctl_kpc_get_shadow_counters(uint32_t counters, |
0a7de745 | 202 | uint32_t *size, void *buf) |
39236c6e A |
203 | { |
204 | uint64_t *ctr_buf = (uint64_t*)buf; | |
205 | int curcpu; | |
206 | uint32_t count; | |
207 | ||
208 | count = kpc_get_shadow_counters(counters & KPC_ALL_CPUS, | |
0a7de745 A |
209 | counters, |
210 | &curcpu, &ctr_buf[1]); | |
39236c6e | 211 | |
0a7de745 | 212 | if (!count) { |
39236c6e | 213 | return EINVAL; |
0a7de745 | 214 | } |
39236c6e A |
215 | |
216 | ctr_buf[0] = curcpu; | |
217 | ||
0a7de745 | 218 | *size = (count + 1) * sizeof(uint64_t); |
39236c6e A |
219 | |
220 | return 0; | |
221 | } | |
222 | ||
5ba3f43e | 223 | static int |
39236c6e | 224 | sysctl_kpc_get_thread_counters(uint32_t tid, |
0a7de745 | 225 | uint32_t *size, void *buf) |
39236c6e A |
226 | { |
227 | uint32_t count = *size / sizeof(uint64_t); | |
228 | int r; | |
229 | ||
0a7de745 | 230 | if (tid != 0) { |
39236c6e | 231 | return EINVAL; |
0a7de745 | 232 | } |
39236c6e A |
233 | |
234 | r = kpc_get_curthread_counters(&count, buf); | |
0a7de745 | 235 | if (!r) { |
39236c6e | 236 | *size = count * sizeof(uint64_t); |
0a7de745 | 237 | } |
39236c6e A |
238 | |
239 | return r; | |
5ba3f43e | 240 | } |
39236c6e A |
241 | |
242 | static int | |
243 | sysctl_kpc_get_config(uint32_t classes, void* buf) | |
244 | { | |
245 | return kpc_get_config( classes, buf ); | |
246 | } | |
247 | ||
248 | static int | |
249 | sysctl_kpc_set_config(uint32_t classes, void* buf) | |
250 | { | |
3e170ce0 | 251 | /* userspace cannot reconfigure the power class */ |
0a7de745 A |
252 | if (classes & KPC_CLASS_POWER_MASK) { |
253 | return EPERM; | |
254 | } | |
39236c6e A |
255 | return kpc_set_config( classes, buf); |
256 | } | |
257 | ||
258 | static int | |
259 | sysctl_kpc_get_period(uint32_t classes, void* buf) | |
260 | { | |
261 | return kpc_get_period( classes, buf ); | |
262 | } | |
263 | ||
264 | static int | |
265 | sysctl_kpc_set_period(uint32_t classes, void* buf) | |
266 | { | |
3e170ce0 | 267 | /* userspace cannot reconfigure the power class */ |
0a7de745 A |
268 | if (classes & KPC_CLASS_POWER_MASK) { |
269 | return EPERM; | |
270 | } | |
39236c6e A |
271 | return kpc_set_period( classes, buf); |
272 | } | |
273 | ||
274 | static int | |
275 | sysctl_kpc_get_actionid(uint32_t classes, void* buf) | |
276 | { | |
277 | return kpc_get_actionid( classes, buf ); | |
278 | } | |
279 | ||
280 | static int | |
281 | sysctl_kpc_set_actionid(uint32_t classes, void* buf) | |
282 | { | |
283 | return kpc_set_actionid( classes, buf); | |
284 | } | |
285 | ||
286 | ||
287 | static int | |
5ba3f43e | 288 | sysctl_get_bigarray(struct sysctl_req *req, |
0a7de745 | 289 | int (*get_fn)(uint32_t, uint32_t*, void*)) |
39236c6e | 290 | { |
d9a64523 A |
291 | uint32_t bufsize = 0; |
292 | uint64_t *buf = kpc_get_bigarray(&bufsize); | |
39236c6e A |
293 | uint32_t arg = 0; |
294 | ||
295 | /* get the argument */ | |
5ba3f43e A |
296 | int error = SYSCTL_IN(req, &arg, sizeof(arg)); |
297 | if (error) { | |
39236c6e A |
298 | return error; |
299 | } | |
300 | ||
d9a64523 | 301 | error = get_fn(arg, &bufsize, buf); |
5ba3f43e | 302 | if (!error) { |
d9a64523 | 303 | error = SYSCTL_OUT(req, buf, bufsize); |
5ba3f43e | 304 | } |
39236c6e A |
305 | |
306 | return error; | |
307 | } | |
308 | ||
309 | /* given a config word, how many bytes does it take? */ | |
310 | static int | |
311 | sysctl_config_size( uint32_t config ) | |
312 | { | |
313 | return kpc_get_config_count(config) * sizeof(kpc_config_t); | |
314 | } | |
315 | ||
316 | static int | |
317 | sysctl_counter_size( uint32_t classes ) | |
318 | { | |
319 | return kpc_get_counter_count(classes) * sizeof(uint64_t); | |
320 | } | |
321 | ||
322 | static int | |
323 | sysctl_actionid_size( uint32_t classes ) | |
324 | { | |
325 | return kpc_get_counter_count(classes) * sizeof(int32_t); | |
326 | } | |
327 | ||
328 | static int | |
5ba3f43e | 329 | sysctl_getset_bigarray(struct sysctl_req *req, int (*size_fn)(uint32_t arg), |
0a7de745 | 330 | int (*get_fn)(uint32_t, void*), int (*set_fn)(uint32_t, void*)) |
39236c6e A |
331 | { |
332 | int error = 0; | |
39236c6e A |
333 | uint64_t arg; |
334 | ||
d9a64523 A |
335 | uint32_t bufsize = 0; |
336 | uint64_t *buf = kpc_get_bigarray(&bufsize); | |
337 | ||
39236c6e | 338 | /* get the config word */ |
5ba3f43e A |
339 | error = SYSCTL_IN(req, &arg, sizeof(arg)); |
340 | if (error) { | |
39236c6e A |
341 | return error; |
342 | } | |
343 | ||
5ba3f43e A |
344 | /* Determine the size of registers to modify. */ |
345 | uint32_t regsize = size_fn((uint32_t)arg); | |
346 | if (regsize == 0 || regsize > bufsize) { | |
39236c6e | 347 | return EINVAL; |
5ba3f43e | 348 | } |
39236c6e | 349 | |
5ba3f43e A |
350 | /* if writing */ |
351 | if (req->newptr) { | |
352 | /* copy the rest -- SYSCTL_IN knows the copyin should be shifted */ | |
d9a64523 | 353 | error = SYSCTL_IN(req, buf, regsize); |
5ba3f43e A |
354 | |
355 | /* SYSCTL_IN failure means only need to read */ | |
356 | if (!error) { | |
d9a64523 | 357 | error = set_fn((uint32_t)arg, buf); |
5ba3f43e A |
358 | if (error) { |
359 | return error; | |
360 | } | |
39236c6e A |
361 | } |
362 | } | |
363 | ||
5ba3f43e A |
364 | /* if reading */ |
365 | if (req->oldptr) { | |
d9a64523 | 366 | error = get_fn((uint32_t)arg, buf); |
5ba3f43e A |
367 | if (error) { |
368 | return error; | |
369 | } | |
39236c6e | 370 | |
d9a64523 | 371 | error = SYSCTL_OUT(req, buf, regsize); |
39236c6e | 372 | } |
5ba3f43e | 373 | |
39236c6e A |
374 | return error; |
375 | } | |
376 | ||
39236c6e A |
377 | static int |
378 | kpc_sysctl SYSCTL_HANDLER_ARGS | |
379 | { | |
380 | int ret; | |
381 | ||
382 | // __unused struct sysctl_oid *unused_oidp = oidp; | |
383 | (void)arg2; | |
5ba3f43e | 384 | |
d9a64523 | 385 | if (!kpc_initted) { |
39236c6e | 386 | panic("kpc_init not called"); |
d9a64523 A |
387 | } |
388 | ||
389 | if (!kpc_supported) { | |
390 | return ENOTSUP; | |
391 | } | |
39236c6e | 392 | |
5ba3f43e | 393 | ktrace_lock(); |
39037602 | 394 | |
8a3053a0 | 395 | // Most sysctls require an access check, but a few are public. |
0a7de745 | 396 | switch ((uintptr_t) arg1) { |
8a3053a0 A |
397 | case REQ_CLASSES: |
398 | case REQ_CONFIG_COUNT: | |
399 | case REQ_COUNTER_COUNT: | |
400 | // These read-only sysctls are public. | |
401 | break; | |
402 | ||
403 | default: | |
404 | // Require kperf access to read or write anything else. | |
405 | // This is either root or the blessed pid. | |
39037602 | 406 | if ((ret = ktrace_read_check())) { |
5ba3f43e | 407 | ktrace_unlock(); |
8a3053a0 A |
408 | return ret; |
409 | } | |
410 | break; | |
411 | } | |
412 | ||
5ba3f43e | 413 | ktrace_unlock(); |
39037602 | 414 | |
5ba3f43e | 415 | lck_mtx_lock(&sysctl_lock); |
39236c6e A |
416 | |
417 | /* which request */ | |
0a7de745 | 418 | switch ((uintptr_t) arg1) { |
39236c6e A |
419 | case REQ_CLASSES: |
420 | ret = sysctl_get_int( oidp, req, | |
0a7de745 | 421 | kpc_get_classes()); |
39236c6e A |
422 | break; |
423 | case REQ_COUNTING: | |
424 | ret = sysctl_getset_int( oidp, req, | |
0a7de745 A |
425 | (getint_t)kpc_get_running, |
426 | (setint_t)kpc_set_running ); | |
39236c6e A |
427 | break; |
428 | case REQ_THREAD_COUNTING: | |
429 | ret = sysctl_getset_int( oidp, req, | |
0a7de745 A |
430 | (getint_t)kpc_get_thread_counting, |
431 | (setint_t)kpc_set_thread_counting ); | |
39236c6e A |
432 | break; |
433 | ||
434 | case REQ_CONFIG_COUNT: | |
435 | ret = sysctl_setget_int( req, | |
0a7de745 | 436 | (setget_func_t)kpc_get_config_count ); |
39236c6e A |
437 | break; |
438 | ||
439 | case REQ_COUNTER_COUNT: | |
440 | ret = sysctl_setget_int( req, | |
0a7de745 | 441 | (setget_func_t)kpc_get_counter_count ); |
39236c6e A |
442 | break; |
443 | ||
444 | ||
445 | case REQ_THREAD_COUNTERS: | |
446 | ret = sysctl_get_bigarray( req, sysctl_kpc_get_thread_counters ); | |
447 | break; | |
448 | ||
449 | case REQ_COUNTERS: | |
450 | ret = sysctl_get_bigarray( req, sysctl_kpc_get_counters ); | |
451 | break; | |
452 | ||
453 | case REQ_SHADOW_COUNTERS: | |
454 | ret = sysctl_get_bigarray( req, sysctl_kpc_get_shadow_counters ); | |
455 | break; | |
456 | ||
457 | case REQ_CONFIG: | |
458 | ret = sysctl_getset_bigarray( req, | |
0a7de745 A |
459 | sysctl_config_size, |
460 | sysctl_kpc_get_config, | |
461 | sysctl_kpc_set_config ); | |
39236c6e A |
462 | break; |
463 | ||
464 | case REQ_PERIOD: | |
465 | ret = sysctl_getset_bigarray( req, | |
0a7de745 A |
466 | sysctl_counter_size, |
467 | sysctl_kpc_get_period, | |
468 | sysctl_kpc_set_period ); | |
39236c6e A |
469 | break; |
470 | ||
471 | case REQ_ACTIONID: | |
472 | ret = sysctl_getset_bigarray( req, | |
0a7de745 A |
473 | sysctl_actionid_size, |
474 | sysctl_kpc_get_actionid, | |
475 | sysctl_kpc_set_actionid ); | |
39236c6e A |
476 | break; |
477 | ||
fe8ab488 A |
478 | |
479 | case REQ_SW_INC: | |
480 | ret = sysctl_set_int( req, (setget_func_t)kpc_set_sw_inc ); | |
5ba3f43e | 481 | break; |
fe8ab488 | 482 | |
3e170ce0 A |
483 | case REQ_PMU_VERSION: |
484 | ret = sysctl_get_int(oidp, req, kpc_get_pmu_version()); | |
485 | break; | |
486 | ||
39236c6e A |
487 | default: |
488 | ret = ENOENT; | |
489 | break; | |
490 | } | |
491 | ||
5ba3f43e A |
492 | lck_mtx_unlock(&sysctl_lock); |
493 | ||
39236c6e A |
494 | return ret; |
495 | } | |
496 | ||
497 | ||
498 | /*** sysctl definitions ***/ | |
499 | ||
500 | /* root kperf node */ | |
0a7de745 A |
501 | SYSCTL_NODE(, OID_AUTO, kpc, CTLFLAG_RW | CTLFLAG_LOCKED, 0, |
502 | "kpc"); | |
39236c6e A |
503 | |
504 | /* values */ | |
505 | SYSCTL_PROC(_kpc, OID_AUTO, classes, | |
0a7de745 A |
506 | CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
507 | (void*)REQ_CLASSES, | |
508 | sizeof(int), kpc_sysctl, "I", "Available classes"); | |
39236c6e A |
509 | |
510 | SYSCTL_PROC(_kpc, OID_AUTO, counting, | |
0a7de745 A |
511 | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
512 | (void*)REQ_COUNTING, | |
513 | sizeof(int), kpc_sysctl, "I", "PMCs counting"); | |
39236c6e A |
514 | |
515 | SYSCTL_PROC(_kpc, OID_AUTO, thread_counting, | |
0a7de745 A |
516 | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
517 | (void*)REQ_THREAD_COUNTING, | |
518 | sizeof(int), kpc_sysctl, "I", "Thread accumulation"); | |
39236c6e | 519 | |
3e170ce0 | 520 | SYSCTL_PROC(_kpc, OID_AUTO, pmu_version, |
0a7de745 A |
521 | CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
522 | (void *)REQ_PMU_VERSION, | |
523 | sizeof(int), kpc_sysctl, "I", "PMU version for hardware"); | |
3e170ce0 | 524 | |
39236c6e A |
525 | /* faux values */ |
526 | SYSCTL_PROC(_kpc, OID_AUTO, config_count, | |
0a7de745 A |
527 | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
528 | (void*)REQ_CONFIG_COUNT, | |
529 | sizeof(int), kpc_sysctl, "S", "Config count"); | |
39236c6e A |
530 | |
531 | SYSCTL_PROC(_kpc, OID_AUTO, counter_count, | |
0a7de745 A |
532 | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
533 | (void*)REQ_COUNTER_COUNT, | |
534 | sizeof(int), kpc_sysctl, "S", "Counter count"); | |
39236c6e | 535 | |
fe8ab488 | 536 | SYSCTL_PROC(_kpc, OID_AUTO, sw_inc, |
0a7de745 A |
537 | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
538 | (void*)REQ_SW_INC, | |
539 | sizeof(int), kpc_sysctl, "S", "Software increment"); | |
fe8ab488 | 540 | |
39236c6e A |
541 | /* arrays */ |
542 | SYSCTL_PROC(_kpc, OID_AUTO, thread_counters, | |
0a7de745 A |
543 | CTLFLAG_RD | CTLFLAG_WR | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
544 | (void*)REQ_THREAD_COUNTERS, | |
545 | sizeof(uint64_t), kpc_sysctl, | |
546 | "QU", "Current thread counters"); | |
39236c6e A |
547 | |
548 | SYSCTL_PROC(_kpc, OID_AUTO, counters, | |
0a7de745 A |
549 | CTLFLAG_RD | CTLFLAG_WR | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
550 | (void*)REQ_COUNTERS, | |
551 | sizeof(uint64_t), kpc_sysctl, | |
552 | "QU", "Current counters"); | |
39236c6e A |
553 | |
554 | SYSCTL_PROC(_kpc, OID_AUTO, shadow_counters, | |
0a7de745 A |
555 | CTLFLAG_RD | CTLFLAG_WR | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
556 | (void*)REQ_SHADOW_COUNTERS, | |
557 | sizeof(uint64_t), kpc_sysctl, | |
558 | "QU", "Current shadow counters"); | |
39236c6e A |
559 | |
560 | SYSCTL_PROC(_kpc, OID_AUTO, config, | |
0a7de745 A |
561 | CTLFLAG_RD | CTLFLAG_WR | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
562 | (void*)REQ_CONFIG, | |
563 | sizeof(uint64_t), kpc_sysctl, | |
564 | "QU", "Set counter configs"); | |
39236c6e A |
565 | |
566 | SYSCTL_PROC(_kpc, OID_AUTO, period, | |
0a7de745 A |
567 | CTLFLAG_RD | CTLFLAG_WR | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
568 | (void*)REQ_PERIOD, | |
569 | sizeof(uint64_t), kpc_sysctl, | |
570 | "QU", "Set counter periods"); | |
39236c6e A |
571 | |
572 | SYSCTL_PROC(_kpc, OID_AUTO, actionid, | |
0a7de745 A |
573 | CTLFLAG_RD | CTLFLAG_WR | CTLFLAG_ANYBODY | CTLFLAG_MASKED | CTLFLAG_LOCKED, |
574 | (void*)REQ_ACTIONID, | |
575 | sizeof(uint32_t), kpc_sysctl, | |
576 | "QU", "Set counter actionids"); | |
fe8ab488 A |
577 | |
578 |