]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/cddl/dev/profile/profile.c
arm64/acpi: Give the real PA limit to ACPI
[FreeBSD/FreeBSD.git] / sys / cddl / dev / profile / profile.c
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
22  *
23  * $FreeBSD$
24  *
25  */
26
27 /*
28  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
29  * Use is subject to license terms.
30  */
31
32 #include <sys/cdefs.h>
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/conf.h>
36 #include <sys/cpuvar.h>
37 #include <sys/endian.h>
38 #include <sys/fcntl.h>
39 #include <sys/filio.h>
40 #include <sys/kdb.h>
41 #include <sys/kernel.h>
42 #include <sys/kmem.h>
43 #include <sys/kthread.h>
44 #include <sys/limits.h>
45 #include <sys/linker.h>
46 #include <sys/lock.h>
47 #include <sys/malloc.h>
48 #include <sys/module.h>
49 #include <sys/mutex.h>
50 #include <sys/poll.h>
51 #include <sys/proc.h>
52 #include <sys/selinfo.h>
53 #include <sys/smp.h>
54 #include <sys/sysctl.h>
55 #include <sys/uio.h>
56 #include <sys/unistd.h>
57 #include <machine/cpu.h>
58 #include <machine/stdarg.h>
59
60 #include <sys/dtrace.h>
61 #include <sys/dtrace_bsd.h>
62
63 #define PROF_NAMELEN            15
64
65 #define PROF_PROFILE            0
66 #define PROF_TICK               1
67 #define PROF_PREFIX_PROFILE     "profile-"
68 #define PROF_PREFIX_TICK        "tick-"
69
70 /*
71  * Regardless of platform, there are five artificial frames in the case of the
72  * profile provider:
73  *
74  *      profile_fire
75  *      cyclic_expire
76  *      cyclic_fire
77  *      [ cbe ]
78  *      [ locore ]
79  *
80  * On amd64, there are two frames associated with locore:  one in locore, and
81  * another in common interrupt dispatch code.  (i386 has not been modified to
82  * use this common layer.)  Further, on i386, the interrupted instruction
83  * appears as its own stack frame.  All of this means that we need to add one
84  * frame for amd64, and then take one away for both amd64 and i386.
85  *
86  * On SPARC, the picture is further complicated because the compiler
87  * optimizes away tail-calls -- so the following frames are optimized away:
88  *
89  *      profile_fire
90  *      cyclic_expire
91  *
92  * This gives three frames.  However, on DEBUG kernels, the cyclic_expire
93  * frame cannot be tail-call eliminated, yielding four frames in this case.
94  *
95  * All of the above constraints lead to the mess below.  Yes, the profile
96  * provider should ideally figure this out on-the-fly by hiting one of its own
97  * probes and then walking its own stack trace.  This is complicated, however,
98  * and the static definition doesn't seem to be overly brittle.  Still, we
99  * allow for a manual override in case we get it completely wrong.
100  */
101 #ifdef __amd64
102 #define PROF_ARTIFICIAL_FRAMES  10
103 #else
104 #ifdef __i386
105 #define PROF_ARTIFICIAL_FRAMES  6
106 #else
107 #ifdef __sparc
108 #ifdef DEBUG
109 #define PROF_ARTIFICIAL_FRAMES  4
110 #else
111 #define PROF_ARTIFICIAL_FRAMES  3
112 #endif
113 #endif
114 #endif
115 #endif
116
117 #ifdef __mips
118 /*
119  * This value is bogus just to make module compilable on mips
120  */
121 #define PROF_ARTIFICIAL_FRAMES  3
122 #endif
123
124 #ifdef __powerpc__
125 /*
126  * This value is bogus just to make module compilable on powerpc
127  */
128 #define PROF_ARTIFICIAL_FRAMES  3
129 #endif
130
131 struct profile_probe_percpu;
132
133 #ifdef __mips
134 /* bogus */
135 #define PROF_ARTIFICIAL_FRAMES  3
136 #endif
137
138 #ifdef __arm__
139 #define PROF_ARTIFICIAL_FRAMES  3
140 #endif
141
142 #ifdef __aarch64__
143 /* TODO: verify */
144 #define PROF_ARTIFICIAL_FRAMES  10
145 #endif
146
147 #ifdef __riscv
148 /* TODO: verify */
149 #define PROF_ARTIFICIAL_FRAMES  10
150 #endif
151
152 typedef struct profile_probe {
153         char            prof_name[PROF_NAMELEN];
154         dtrace_id_t     prof_id;
155         int             prof_kind;
156 #ifdef illumos
157         hrtime_t        prof_interval;
158         cyclic_id_t     prof_cyclic;
159 #else
160         sbintime_t      prof_interval;
161         struct callout  prof_cyclic;
162         sbintime_t      prof_expected;
163         struct profile_probe_percpu **prof_pcpus;
164 #endif
165 } profile_probe_t;
166
167 typedef struct profile_probe_percpu {
168         hrtime_t        profc_expected;
169         hrtime_t        profc_interval;
170         profile_probe_t *profc_probe;
171 #ifdef __FreeBSD__
172         struct callout  profc_cyclic;
173 #endif
174 } profile_probe_percpu_t;
175
176 static d_open_t profile_open;
177 static int      profile_unload(void);
178 static void     profile_create(hrtime_t, char *, int);
179 static void     profile_destroy(void *, dtrace_id_t, void *);
180 static void     profile_enable(void *, dtrace_id_t, void *);
181 static void     profile_disable(void *, dtrace_id_t, void *);
182 static void     profile_load(void *);
183 static void     profile_provide(void *, dtrace_probedesc_t *);
184
185 static int profile_rates[] = {
186     97, 199, 499, 997, 1999,
187     4001, 4999, 0, 0, 0,
188     0, 0, 0, 0, 0,
189     0, 0, 0, 0, 0
190 };
191
192 static int profile_ticks[] = {
193     1, 10, 100, 500, 1000,
194     5000, 0, 0, 0, 0,
195     0, 0, 0, 0, 0
196 };
197
198 /*
199  * profile_max defines the upper bound on the number of profile probes that
200  * can exist (this is to prevent malicious or clumsy users from exhausing
201  * system resources by creating a slew of profile probes). At mod load time,
202  * this gets its value from PROFILE_MAX_DEFAULT or profile-max-probes if it's
203  * present in the profile.conf file.
204  */
205 #define PROFILE_MAX_DEFAULT     1000    /* default max. number of probes */
206 static uint32_t profile_max = PROFILE_MAX_DEFAULT;
207                                         /* maximum number of profile probes */
208 static uint32_t profile_total;          /* current number of profile probes */
209
210 static struct cdevsw profile_cdevsw = {
211         .d_version      = D_VERSION,
212         .d_open         = profile_open,
213         .d_name         = "profile",
214 };
215
216 static dtrace_pattr_t profile_attr = {
217 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
218 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
219 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
220 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
221 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
222 };
223
224 static dtrace_pops_t profile_pops = {
225         .dtps_provide =         profile_provide,
226         .dtps_provide_module =  NULL,
227         .dtps_enable =          profile_enable,
228         .dtps_disable =         profile_disable,
229         .dtps_suspend =         NULL,
230         .dtps_resume =          NULL,
231         .dtps_getargdesc =      NULL,
232         .dtps_getargval =       NULL,
233         .dtps_usermode =        NULL,
234         .dtps_destroy =         profile_destroy
235 };
236
237 static struct cdev              *profile_cdev;
238 static dtrace_provider_id_t     profile_id;
239 static hrtime_t                 profile_interval_min = NANOSEC / 5000;  /* 5000 hz */
240 static int                      profile_aframes = PROF_ARTIFICIAL_FRAMES;
241
242 SYSCTL_DECL(_kern_dtrace);
243 SYSCTL_NODE(_kern_dtrace, OID_AUTO, profile, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
244     "DTrace profile parameters");
245 SYSCTL_INT(_kern_dtrace_profile, OID_AUTO, aframes, CTLFLAG_RW, &profile_aframes,
246     0, "Skipped frames for profile provider");
247
248 static sbintime_t
249 nsec_to_sbt(hrtime_t nsec)
250 {
251         time_t sec;
252
253         /*
254          * We need to calculate nsec * 2^32 / 10^9
255          * Seconds and nanoseconds are split to avoid overflow.
256          */
257         sec = nsec / NANOSEC;
258         nsec = nsec % NANOSEC;
259         return (((sbintime_t)sec << 32) | ((sbintime_t)nsec << 32) / NANOSEC);
260 }
261
262 static hrtime_t
263 sbt_to_nsec(sbintime_t sbt)
264 {
265
266         return ((sbt >> 32) * NANOSEC +
267             (((uint32_t)sbt * (hrtime_t)NANOSEC) >> 32));
268 }
269
270 static void
271 profile_probe(profile_probe_t *prof, hrtime_t late)
272 {
273         struct thread *td;
274         struct trapframe *frame;
275         uintfptr_t pc, upc;
276
277         td = curthread;
278         pc = upc = 0;
279
280         /*
281          * td_intr_frame can be unset if this is a catch-up event upon waking up
282          * from idle sleep. This can only happen on a CPU idle thread. Use a
283          * representative arg0 value in this case so that one of the probe
284          * arguments is non-zero.
285          */
286         frame = td->td_intr_frame;
287         if (frame != NULL) {
288                 if (TRAPF_USERMODE(frame))
289                         upc = TRAPF_PC(frame);
290                 else
291                         pc = TRAPF_PC(frame);
292         } else if (TD_IS_IDLETHREAD(td))
293                 pc = (uintfptr_t)&cpu_idle;
294
295         dtrace_probe(prof->prof_id, pc, upc, late, 0, 0);
296 }
297
298 static void
299 profile_fire(void *arg)
300 {
301         profile_probe_percpu_t *pcpu = arg;
302         profile_probe_t *prof = pcpu->profc_probe;
303         hrtime_t late;
304
305         late = sbt_to_nsec(sbinuptime() - pcpu->profc_expected);
306
307         profile_probe(prof, late);
308         pcpu->profc_expected += pcpu->profc_interval;
309         callout_schedule_sbt_curcpu(&pcpu->profc_cyclic,
310             pcpu->profc_expected, 0, C_DIRECT_EXEC | C_ABSOLUTE);
311 }
312
313 static void
314 profile_tick(void *arg)
315 {
316         profile_probe_t *prof = arg;
317
318         profile_probe(prof, 0);
319         prof->prof_expected += prof->prof_interval;
320         callout_schedule_sbt(&prof->prof_cyclic,
321             prof->prof_expected, 0, C_DIRECT_EXEC | C_ABSOLUTE);
322 }
323
324 static void
325 profile_create(hrtime_t interval, char *name, int kind)
326 {
327         profile_probe_t *prof;
328
329         if (interval < profile_interval_min)
330                 return;
331
332         if (dtrace_probe_lookup(profile_id, NULL, NULL, name) != 0)
333                 return;
334
335         atomic_add_32(&profile_total, 1);
336         if (profile_total > profile_max) {
337                 atomic_add_32(&profile_total, -1);
338                 return;
339         }
340
341         prof = kmem_zalloc(sizeof (profile_probe_t), KM_SLEEP);
342         (void) strcpy(prof->prof_name, name);
343 #ifdef illumos
344         prof->prof_interval = interval;
345         prof->prof_cyclic = CYCLIC_NONE;
346 #else
347         prof->prof_interval = nsec_to_sbt(interval);
348         callout_init(&prof->prof_cyclic, 1);
349 #endif
350         prof->prof_kind = kind;
351         prof->prof_id = dtrace_probe_create(profile_id,
352             NULL, NULL, name,
353             profile_aframes, prof);
354 }
355
356 /*ARGSUSED*/
357 static void
358 profile_provide(void *arg, dtrace_probedesc_t *desc)
359 {
360         int i, j, rate, kind;
361         hrtime_t val = 0, mult = 1, len = 0;
362         char *name, *suffix = NULL;
363
364         const struct {
365                 char *prefix;
366                 int kind;
367         } types[] = {
368                 { PROF_PREFIX_PROFILE, PROF_PROFILE },
369                 { PROF_PREFIX_TICK, PROF_TICK },
370                 { 0, 0 }
371         };
372
373         const struct {
374                 char *name;
375                 hrtime_t mult;
376         } suffixes[] = {
377                 { "ns",         NANOSEC / NANOSEC },
378                 { "nsec",       NANOSEC / NANOSEC },
379                 { "us",         NANOSEC / MICROSEC },
380                 { "usec",       NANOSEC / MICROSEC },
381                 { "ms",         NANOSEC / MILLISEC },
382                 { "msec",       NANOSEC / MILLISEC },
383                 { "s",          NANOSEC / SEC },
384                 { "sec",        NANOSEC / SEC },
385                 { "m",          NANOSEC * (hrtime_t)60 },
386                 { "min",        NANOSEC * (hrtime_t)60 },
387                 { "h",          NANOSEC * (hrtime_t)(60 * 60) },
388                 { "hour",       NANOSEC * (hrtime_t)(60 * 60) },
389                 { "d",          NANOSEC * (hrtime_t)(24 * 60 * 60) },
390                 { "day",        NANOSEC * (hrtime_t)(24 * 60 * 60) },
391                 { "hz",         0 },
392                 { NULL }
393         };
394
395         if (desc == NULL) {
396                 char n[PROF_NAMELEN];
397
398                 /*
399                  * If no description was provided, provide all of our probes.
400                  */
401                 for (i = 0; i < sizeof (profile_rates) / sizeof (int); i++) {
402                         if ((rate = profile_rates[i]) == 0)
403                                 continue;
404
405                         (void) snprintf(n, PROF_NAMELEN, "%s%d",
406                             PROF_PREFIX_PROFILE, rate);
407                         profile_create(NANOSEC / rate, n, PROF_PROFILE);
408                 }
409
410                 for (i = 0; i < sizeof (profile_ticks) / sizeof (int); i++) {
411                         if ((rate = profile_ticks[i]) == 0)
412                                 continue;
413
414                         (void) snprintf(n, PROF_NAMELEN, "%s%d",
415                             PROF_PREFIX_TICK, rate);
416                         profile_create(NANOSEC / rate, n, PROF_TICK);
417                 }
418
419                 return;
420         }
421
422         name = desc->dtpd_name;
423
424         for (i = 0; types[i].prefix != NULL; i++) {
425                 len = strlen(types[i].prefix);
426
427                 if (strncmp(name, types[i].prefix, len) != 0)
428                         continue;
429                 break;
430         }
431
432         if (types[i].prefix == NULL)
433                 return;
434
435         kind = types[i].kind;
436         j = strlen(name) - len;
437
438         /*
439          * We need to start before any time suffix.
440          */
441         for (j = strlen(name); j >= len; j--) {
442                 if (name[j] >= '0' && name[j] <= '9')
443                         break;
444                 suffix = &name[j];
445         }
446
447         ASSERT(suffix != NULL);
448
449         /*
450          * Now determine the numerical value present in the probe name.
451          */
452         for (; j >= len; j--) {
453                 if (name[j] < '0' || name[j] > '9')
454                         return;
455
456                 val += (name[j] - '0') * mult;
457                 mult *= (hrtime_t)10;
458         }
459
460         if (val == 0)
461                 return;
462
463         /*
464          * Look-up the suffix to determine the multiplier.
465          */
466         for (i = 0, mult = 0; suffixes[i].name != NULL; i++) {
467                 if (strcasecmp(suffixes[i].name, suffix) == 0) {
468                         mult = suffixes[i].mult;
469                         break;
470                 }
471         }
472
473         if (suffixes[i].name == NULL && *suffix != '\0')
474                 return;
475
476         if (mult == 0) {
477                 /*
478                  * The default is frequency-per-second.
479                  */
480                 val = NANOSEC / val;
481         } else {
482                 val *= mult;
483         }
484
485         profile_create(val, name, kind);
486 }
487
488 /* ARGSUSED */
489 static void
490 profile_destroy(void *arg, dtrace_id_t id, void *parg)
491 {
492         profile_probe_t *prof = parg;
493
494 #ifdef illumos
495         ASSERT(prof->prof_cyclic == CYCLIC_NONE);
496 #else
497         ASSERT(!callout_active(&prof->prof_cyclic) && prof->prof_pcpus == NULL);
498 #endif
499         kmem_free(prof, sizeof (profile_probe_t));
500
501         ASSERT(profile_total >= 1);
502         atomic_add_32(&profile_total, -1);
503 }
504
505 #ifdef illumos
506 /*ARGSUSED*/
507 static void
508 profile_online(void *arg, cpu_t *cpu, cyc_handler_t *hdlr, cyc_time_t *when)
509 {
510         profile_probe_t *prof = arg;
511         profile_probe_percpu_t *pcpu;
512
513         pcpu = kmem_zalloc(sizeof (profile_probe_percpu_t), KM_SLEEP);
514         pcpu->profc_probe = prof;
515
516         hdlr->cyh_func = profile_fire;
517         hdlr->cyh_arg = pcpu;
518
519         when->cyt_interval = prof->prof_interval;
520         when->cyt_when = gethrtime() + when->cyt_interval;
521
522         pcpu->profc_expected = when->cyt_when;
523         pcpu->profc_interval = when->cyt_interval;
524 }
525
526 /*ARGSUSED*/
527 static void
528 profile_offline(void *arg, cpu_t *cpu, void *oarg)
529 {
530         profile_probe_percpu_t *pcpu = oarg;
531
532         ASSERT(pcpu->profc_probe == arg);
533         kmem_free(pcpu, sizeof (profile_probe_percpu_t));
534 }
535
536 /* ARGSUSED */
537 static void
538 profile_enable(void *arg, dtrace_id_t id, void *parg)
539 {
540         profile_probe_t *prof = parg;
541         cyc_omni_handler_t omni;
542         cyc_handler_t hdlr;
543         cyc_time_t when;
544
545         ASSERT(prof->prof_interval != 0);
546         ASSERT(MUTEX_HELD(&cpu_lock));
547
548         if (prof->prof_kind == PROF_TICK) {
549                 hdlr.cyh_func = profile_tick;
550                 hdlr.cyh_arg = prof;
551
552                 when.cyt_interval = prof->prof_interval;
553                 when.cyt_when = gethrtime() + when.cyt_interval;
554         } else {
555                 ASSERT(prof->prof_kind == PROF_PROFILE);
556                 omni.cyo_online = profile_online;
557                 omni.cyo_offline = profile_offline;
558                 omni.cyo_arg = prof;
559         }
560
561         if (prof->prof_kind == PROF_TICK) {
562                 prof->prof_cyclic = cyclic_add(&hdlr, &when);
563         } else {
564                 prof->prof_cyclic = cyclic_add_omni(&omni);
565         }
566 }
567
568 /* ARGSUSED */
569 static void
570 profile_disable(void *arg, dtrace_id_t id, void *parg)
571 {
572         profile_probe_t *prof = parg;
573
574         ASSERT(prof->prof_cyclic != CYCLIC_NONE);
575         ASSERT(MUTEX_HELD(&cpu_lock));
576
577         cyclic_remove(prof->prof_cyclic);
578         prof->prof_cyclic = CYCLIC_NONE;
579 }
580
581 #else
582
583 static void
584 profile_enable_omni(profile_probe_t *prof)
585 {
586         profile_probe_percpu_t *pcpu;
587         int cpu;
588
589         prof->prof_pcpus = kmem_zalloc((mp_maxid + 1) * sizeof(pcpu), KM_SLEEP);
590         CPU_FOREACH(cpu) {
591                 pcpu = kmem_zalloc(sizeof(profile_probe_percpu_t), KM_SLEEP);
592                 prof->prof_pcpus[cpu] = pcpu;
593                 pcpu->profc_probe = prof;
594                 pcpu->profc_expected = sbinuptime() + prof->prof_interval;
595                 pcpu->profc_interval = prof->prof_interval;
596                 callout_init(&pcpu->profc_cyclic, 1);
597                 callout_reset_sbt_on(&pcpu->profc_cyclic,
598                     pcpu->profc_expected, 0, profile_fire, pcpu,
599                     cpu, C_DIRECT_EXEC | C_ABSOLUTE);
600         }
601 }
602
603 static void
604 profile_disable_omni(profile_probe_t *prof)
605 {
606         profile_probe_percpu_t *pcpu;
607         int cpu;
608
609         ASSERT(prof->prof_pcpus != NULL);
610         CPU_FOREACH(cpu) {
611                 pcpu = prof->prof_pcpus[cpu];
612                 ASSERT(pcpu->profc_probe == prof);
613                 ASSERT(callout_active(&pcpu->profc_cyclic));
614                 callout_stop(&pcpu->profc_cyclic);
615                 callout_drain(&pcpu->profc_cyclic);
616                 kmem_free(pcpu, sizeof(profile_probe_percpu_t));
617         }
618         kmem_free(prof->prof_pcpus, (mp_maxid + 1) * sizeof(pcpu));
619         prof->prof_pcpus = NULL;
620 }
621
622 /* ARGSUSED */
623 static void
624 profile_enable(void *arg, dtrace_id_t id, void *parg)
625 {
626         profile_probe_t *prof = parg;
627
628         if (prof->prof_kind == PROF_TICK) {
629                 prof->prof_expected = sbinuptime() + prof->prof_interval;
630                 callout_reset_sbt(&prof->prof_cyclic,
631                     prof->prof_expected, 0, profile_tick, prof,
632                     C_DIRECT_EXEC | C_ABSOLUTE);
633         } else {
634                 ASSERT(prof->prof_kind == PROF_PROFILE);
635                 profile_enable_omni(prof);
636         }
637 }
638
639 /* ARGSUSED */
640 static void
641 profile_disable(void *arg, dtrace_id_t id, void *parg)
642 {
643         profile_probe_t *prof = parg;
644
645         if (prof->prof_kind == PROF_TICK) {
646                 ASSERT(callout_active(&prof->prof_cyclic));
647                 callout_stop(&prof->prof_cyclic);
648                 callout_drain(&prof->prof_cyclic);
649         } else {
650                 ASSERT(prof->prof_kind == PROF_PROFILE);
651                 profile_disable_omni(prof);
652         }
653 }
654 #endif
655
656 static void
657 profile_load(void *dummy)
658 {
659         /* Create the /dev/dtrace/profile entry. */
660         profile_cdev = make_dev(&profile_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
661             "dtrace/profile");
662
663         if (dtrace_register("profile", &profile_attr, DTRACE_PRIV_USER,
664             NULL, &profile_pops, NULL, &profile_id) != 0)
665                 return;
666 }
667
668
669 static int
670 profile_unload()
671 {
672         int error = 0;
673
674         if ((error = dtrace_unregister(profile_id)) != 0)
675                 return (error);
676
677         destroy_dev(profile_cdev);
678
679         return (error);
680 }
681
682 /* ARGSUSED */
683 static int
684 profile_modevent(module_t mod __unused, int type, void *data __unused)
685 {
686         int error = 0;
687
688         switch (type) {
689         case MOD_LOAD:
690                 break;
691
692         case MOD_UNLOAD:
693                 break;
694
695         case MOD_SHUTDOWN:
696                 break;
697
698         default:
699                 error = EOPNOTSUPP;
700                 break;
701
702         }
703         return (error);
704 }
705
706 /* ARGSUSED */
707 static int
708 profile_open(struct cdev *dev __unused, int oflags __unused, int devtype __unused, struct thread *td __unused)
709 {
710         return (0);
711 }
712
713 SYSINIT(profile_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, profile_load, NULL);
714 SYSUNINIT(profile_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, profile_unload, NULL);
715
716 DEV_MODULE(profile, profile_modevent, NULL);
717 MODULE_VERSION(profile, 1);
718 MODULE_DEPEND(profile, dtrace, 1, 1, 1);
719 MODULE_DEPEND(profile, opensolaris, 1, 1, 1);