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.
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.
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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* #pragma ident "@(#)profile.c 1.7 07/01/10 SMI" */
28 #if !defined(__APPLE__)
29 #include <sys/errno.h>
31 #include <sys/modctl.h>
33 #include <sys/systm.h>
35 #include <sys/sunddi.h>
36 #include <sys/cpuvar.h>
38 #include <sys/strsubr.h>
39 #include <sys/dtrace.h>
40 #include <sys/cyclic.h>
41 #include <sys/atomic.h>
45 #define _KERNEL /* Solaris vs. Darwin */
49 #include <kern/cpu_data.h>
50 #include <kern/thread.h>
51 #include <kern/assert.h>
52 #include <mach/thread_status.h>
54 #include <sys/param.h>
55 #include <sys/systm.h>
56 #include <sys/errno.h>
58 #include <sys/ioctl.h>
60 #include <sys/fcntl.h>
61 #include <miscfs/devfs/devfs.h>
63 #include <sys/dtrace.h>
64 #include <sys/dtrace_impl.h>
66 #include <sys/dtrace_glue.h>
68 #include <machine/pal_routines.h>
70 #if defined(__x86_64__)
71 extern x86_saved_state_t
*find_kern_regs(thread_t
);
73 #error Unknown architecture
77 #define ASSERT(x) do {} while(0)
79 extern void profile_init(void);
80 #endif /* __APPLE__ */
82 static dev_info_t
*profile_devi
;
83 static dtrace_provider_id_t profile_id
;
86 * Regardless of platform, the stack frames look like this in the case of the
95 * On x86, there are five frames from the generic interrupt code; further, the
96 * interrupted instruction appears as its own stack frame, giving us a total of
99 * On SPARC, the picture is further complicated because the compiler
100 * optimizes away tail-calls -- so the following frames are optimized away:
105 * This gives three frames. However, on DEBUG kernels, the cyclic_expire
106 * frame cannot be tail-call eliminated, yielding four frames in this case.
108 * All of the above constraints lead to the mess below. Yes, the profile
109 * provider should ideally figure this out on-the-fly by hitting one of its own
110 * probes and then walking its own stack trace. This is complicated, however,
111 * and the static definition doesn't seem to be overly brittle. Still, we
112 * allow for a manual override in case we get it completely wrong.
115 #if defined(__x86_64__)
116 #define PROF_ARTIFICIAL_FRAMES 9
118 #error Unknown architecture
121 #define PROF_NAMELEN 15
123 #define PROF_PROFILE 0
125 #define PROF_PREFIX_PROFILE "profile-"
126 #define PROF_PREFIX_TICK "tick-"
128 typedef struct profile_probe
{
129 char prof_name
[PROF_NAMELEN
];
132 hrtime_t prof_interval
;
133 cyclic_id_t prof_cyclic
;
136 typedef struct profile_probe_percpu
{
137 hrtime_t profc_expected
;
138 hrtime_t profc_interval
;
139 profile_probe_t
*profc_probe
;
140 } profile_probe_percpu_t
;
142 hrtime_t profile_interval_min
= NANOSEC
/ 5000; /* 5000 hz */
143 int profile_aframes
= 0; /* override */
145 static int profile_rates
[] = {
146 97, 199, 499, 997, 1999,
152 static int profile_ticks
[] = {
153 1, 10, 100, 500, 1000,
159 * profile_max defines the upper bound on the number of profile probes that
160 * can exist (this is to prevent malicious or clumsy users from exhausing
161 * system resources by creating a slew of profile probes). At mod load time,
162 * this gets its value from PROFILE_MAX_DEFAULT or profile-max-probes if it's
163 * present in the profile.conf file.
165 #define PROFILE_MAX_DEFAULT 1000 /* default max. number of probes */
166 static uint32_t profile_max
; /* maximum number of profile probes */
167 static uint32_t profile_total
; /* current number of profile probes */
170 profile_fire(void *arg
)
172 profile_probe_percpu_t
*pcpu
= arg
;
173 profile_probe_t
*prof
= pcpu
->profc_probe
;
176 late
= dtrace_gethrtime() - pcpu
->profc_expected
;
177 pcpu
->profc_expected
+= pcpu
->profc_interval
;
179 #if !defined(__APPLE__)
180 dtrace_probe(prof
->prof_id
, CPU
->cpu_profile_pc
,
181 CPU
->cpu_profile_upc
, late
, 0, 0);
183 #if defined(__x86_64__)
184 x86_saved_state_t
*kern_regs
= find_kern_regs(current_thread());
186 if (NULL
!= kern_regs
) {
187 /* Kernel was interrupted. */
188 dtrace_probe(prof
->prof_id
, saved_state64(kern_regs
)->isf
.rip
, 0x0, 0, 0, 0);
191 pal_register_cache_state(current_thread(), VALID
);
192 /* Possibly a user interrupt */
193 x86_saved_state_t
*tagged_regs
= (x86_saved_state_t
*)find_user_regs(current_thread());
195 if (NULL
== tagged_regs
) {
196 /* Too bad, so sad, no useful interrupt state. */
197 dtrace_probe(prof
->prof_id
, 0xcafebabe,
198 0x0, 0, 0, 0); /* XXX_BOGUS also see profile_usermode() below. */
199 } else if (is_saved_state64(tagged_regs
)) {
200 x86_saved_state64_t
*regs
= saved_state64(tagged_regs
);
202 dtrace_probe(prof
->prof_id
, 0x0, regs
->isf
.rip
, 0, 0, 0);
204 x86_saved_state32_t
*regs
= saved_state32(tagged_regs
);
206 dtrace_probe(prof
->prof_id
, 0x0, regs
->eip
, 0, 0, 0);
210 #error Unknown architecture
212 #endif /* __APPLE__ */
216 profile_tick(void *arg
)
218 profile_probe_t
*prof
= arg
;
220 #if !defined(__APPLE__)
221 dtrace_probe(prof
->prof_id
, CPU
->cpu_profile_pc
,
222 CPU
->cpu_profile_upc
, 0, 0, 0);
224 #if defined(__x86_64__)
225 x86_saved_state_t
*kern_regs
= find_kern_regs(current_thread());
227 if (NULL
!= kern_regs
) {
228 /* Kernel was interrupted. */
229 dtrace_probe(prof
->prof_id
, saved_state64(kern_regs
)->isf
.rip
, 0x0, 0, 0, 0);
231 pal_register_cache_state(current_thread(), VALID
);
232 /* Possibly a user interrupt */
233 x86_saved_state_t
*tagged_regs
= (x86_saved_state_t
*)find_user_regs(current_thread());
235 if (NULL
== tagged_regs
) {
236 /* Too bad, so sad, no useful interrupt state. */
237 dtrace_probe(prof
->prof_id
, 0xcafebabe,
238 0x0, 0, 0, 0); /* XXX_BOGUS also see profile_usermode() below. */
239 } else if (is_saved_state64(tagged_regs
)) {
240 x86_saved_state64_t
*regs
= saved_state64(tagged_regs
);
242 dtrace_probe(prof
->prof_id
, 0x0, regs
->isf
.rip
, 0, 0, 0);
244 x86_saved_state32_t
*regs
= saved_state32(tagged_regs
);
246 dtrace_probe(prof
->prof_id
, 0x0, regs
->eip
, 0, 0, 0);
250 #error Unknown architecture
252 #endif /* __APPLE__ */
256 profile_create(hrtime_t interval
, const char *name
, int kind
)
258 profile_probe_t
*prof
;
260 if (interval
< profile_interval_min
)
263 if (dtrace_probe_lookup(profile_id
, NULL
, NULL
, name
) != 0)
266 atomic_add_32(&profile_total
, 1);
267 if (profile_total
> profile_max
) {
268 atomic_add_32(&profile_total
, -1);
272 #if !defined(__APPLE__)
273 prof
= kmem_zalloc(sizeof (profile_probe_t
), KM_SLEEP
);
275 if (PROF_TICK
== kind
)
276 prof
= kmem_zalloc(sizeof (profile_probe_t
), KM_SLEEP
);
278 prof
= kmem_zalloc(sizeof (profile_probe_t
) + NCPU
*sizeof(profile_probe_percpu_t
), KM_SLEEP
);
279 #endif /* __APPLE__ */
280 (void) strlcpy(prof
->prof_name
, name
, sizeof(prof
->prof_name
));
281 prof
->prof_interval
= interval
;
282 prof
->prof_cyclic
= CYCLIC_NONE
;
283 prof
->prof_kind
= kind
;
284 prof
->prof_id
= dtrace_probe_create(profile_id
,
286 profile_aframes
? profile_aframes
: PROF_ARTIFICIAL_FRAMES
, prof
);
291 profile_provide(void *arg
, const dtrace_probedesc_t
*desc
)
293 #pragma unused(arg) /* __APPLE__ */
294 int i
, j
, rate
, kind
;
295 hrtime_t val
= 0, mult
= 1, len
;
296 const char *name
, *suffix
= NULL
;
298 #if !defined(__APPLE__)
303 { PROF_PREFIX_PROFILE
, PROF_PROFILE
},
304 { PROF_PREFIX_TICK
, PROF_TICK
},
312 { "ns", NANOSEC
/ NANOSEC
},
313 { "nsec", NANOSEC
/ NANOSEC
},
314 { "us", NANOSEC
/ MICROSEC
},
315 { "usec", NANOSEC
/ MICROSEC
},
316 { "ms", NANOSEC
/ MILLISEC
},
317 { "msec", NANOSEC
/ MILLISEC
},
318 { "s", NANOSEC
/ SEC
},
319 { "sec", NANOSEC
/ SEC
},
320 { "m", NANOSEC
* (hrtime_t
)60 },
321 { "min", NANOSEC
* (hrtime_t
)60 },
322 { "h", NANOSEC
* (hrtime_t
)(60 * 60) },
323 { "hour", NANOSEC
* (hrtime_t
)(60 * 60) },
324 { "d", NANOSEC
* (hrtime_t
)(24 * 60 * 60) },
325 { "day", NANOSEC
* (hrtime_t
)(24 * 60 * 60) },
334 { PROF_PREFIX_PROFILE
, PROF_PROFILE
},
335 { PROF_PREFIX_TICK
, PROF_TICK
},
343 { "ns", NANOSEC
/ NANOSEC
},
344 { "nsec", NANOSEC
/ NANOSEC
},
345 { "us", NANOSEC
/ MICROSEC
},
346 { "usec", NANOSEC
/ MICROSEC
},
347 { "ms", NANOSEC
/ MILLISEC
},
348 { "msec", NANOSEC
/ MILLISEC
},
349 { "s", NANOSEC
/ SEC
},
350 { "sec", NANOSEC
/ SEC
},
351 { "m", NANOSEC
* (hrtime_t
)60 },
352 { "min", NANOSEC
* (hrtime_t
)60 },
353 { "h", NANOSEC
* (hrtime_t
)(60 * 60) },
354 { "hour", NANOSEC
* (hrtime_t
)(60 * 60) },
355 { "d", NANOSEC
* (hrtime_t
)(24 * 60 * 60) },
356 { "day", NANOSEC
* (hrtime_t
)(24 * 60 * 60) },
360 #endif /* __APPLE__ */
364 char n
[PROF_NAMELEN
];
367 * If no description was provided, provide all of our probes.
369 #if !defined(__APPLE__)
370 for (i
= 0; i
< sizeof (profile_rates
) / sizeof (int); i
++) {
372 for (i
= 0; i
< (int)(sizeof (profile_rates
) / sizeof (int)); i
++) {
373 #endif /* __APPLE__ */
374 if ((rate
= profile_rates
[i
]) == 0)
377 (void) snprintf(n
, PROF_NAMELEN
, "%s%d",
378 PROF_PREFIX_PROFILE
, rate
);
379 profile_create(NANOSEC
/ rate
, n
, PROF_PROFILE
);
382 #if !defined(__APPLE__)
383 for (i
= 0; i
< sizeof (profile_ticks
) / sizeof (int); i
++) {
385 for (i
= 0; i
< (int)(sizeof (profile_ticks
) / sizeof (int)); i
++) {
386 #endif /* __APPLE__ */
387 if ((rate
= profile_ticks
[i
]) == 0)
390 (void) snprintf(n
, PROF_NAMELEN
, "%s%d",
391 PROF_PREFIX_TICK
, rate
);
392 profile_create(NANOSEC
/ rate
, n
, PROF_TICK
);
398 name
= desc
->dtpd_name
;
400 for (i
= 0; types
[i
].prefix
!= NULL
; i
++) {
401 len
= strlen(types
[i
].prefix
);
403 if (strncmp(name
, types
[i
].prefix
, len
) != 0)
408 if (types
[i
].prefix
== NULL
)
411 kind
= types
[i
].kind
;
412 j
= strlen(name
) - len
;
415 * We need to start before any time suffix.
417 for (j
= strlen(name
); j
>= len
; j
--) {
418 if (name
[j
] >= '0' && name
[j
] <= '9')
423 ASSERT(suffix
!= NULL
);
426 * Now determine the numerical value present in the probe name.
428 for (; j
>= len
; j
--) {
429 if (name
[j
] < '0' || name
[j
] > '9')
432 val
+= (name
[j
] - '0') * mult
;
433 mult
*= (hrtime_t
)10;
440 * Look-up the suffix to determine the multiplier.
442 for (i
= 0, mult
= 0; suffixes
[i
].name
!= NULL
; i
++) {
443 #if !defined(__APPLE__)
444 if (strcasecmp(suffixes
[i
].name
, suffix
) == 0) {
445 mult
= suffixes
[i
].mult
;
449 if (strncasecmp(suffixes
[i
].name
, suffix
, strlen(suffixes
[i
].name
) + 1) == 0) {
450 mult
= suffixes
[i
].mult
;
453 #endif /* __APPLE__ */
456 if (suffixes
[i
].name
== NULL
&& *suffix
!= '\0')
461 * The default is frequency-per-second.
468 profile_create(val
, name
, kind
);
473 profile_destroy(void *arg
, dtrace_id_t id
, void *parg
)
475 #pragma unused(arg,id) /* __APPLE__ */
476 profile_probe_t
*prof
= parg
;
478 ASSERT(prof
->prof_cyclic
== CYCLIC_NONE
);
479 #if !defined(__APPLE__)
480 kmem_free(prof
, sizeof (profile_probe_t
));
482 if (prof
->prof_kind
== PROF_TICK
)
483 kmem_free(prof
, sizeof (profile_probe_t
));
485 kmem_free(prof
, sizeof (profile_probe_t
) + NCPU
*sizeof(profile_probe_percpu_t
));
486 #endif /* __APPLE__ */
488 ASSERT(profile_total
>= 1);
489 atomic_add_32(&profile_total
, -1);
494 profile_online(void *arg
, dtrace_cpu_t
*cpu
, cyc_handler_t
*hdlr
, cyc_time_t
*when
)
496 #pragma unused(cpu) /* __APPLE__ */
497 profile_probe_t
*prof
= arg
;
498 profile_probe_percpu_t
*pcpu
;
500 #if !defined(__APPLE__)
501 pcpu
= kmem_zalloc(sizeof (profile_probe_percpu_t
), KM_SLEEP
);
503 pcpu
= ((profile_probe_percpu_t
*)(&(prof
[1]))) + cpu_number();
504 #endif /* __APPLE__ */
505 pcpu
->profc_probe
= prof
;
507 hdlr
->cyh_func
= profile_fire
;
508 hdlr
->cyh_arg
= pcpu
;
509 hdlr
->cyh_level
= CY_HIGH_LEVEL
;
511 when
->cyt_interval
= prof
->prof_interval
;
512 #if !defined(__APPLE__)
513 when
->cyt_when
= dtrace_gethrtime() + when
->cyt_interval
;
516 #endif /* __APPLE__ */
518 pcpu
->profc_expected
= when
->cyt_when
;
519 pcpu
->profc_interval
= when
->cyt_interval
;
524 profile_offline(void *arg
, dtrace_cpu_t
*cpu
, void *oarg
)
526 profile_probe_percpu_t
*pcpu
= oarg
;
528 ASSERT(pcpu
->profc_probe
== arg
);
529 #if !defined(__APPLE__)
530 kmem_free(pcpu
, sizeof (profile_probe_percpu_t
));
532 #pragma unused(pcpu,arg,cpu) /* __APPLE__ */
533 #endif /* __APPLE__ */
538 profile_enable(void *arg
, dtrace_id_t id
, void *parg
)
540 #pragma unused(arg,id) /* __APPLE__ */
541 profile_probe_t
*prof
= parg
;
542 cyc_omni_handler_t omni
;
546 ASSERT(prof
->prof_interval
!= 0);
547 ASSERT(MUTEX_HELD(&cpu_lock
));
549 if (prof
->prof_kind
== PROF_TICK
) {
550 hdlr
.cyh_func
= profile_tick
;
552 hdlr
.cyh_level
= CY_HIGH_LEVEL
;
554 when
.cyt_interval
= prof
->prof_interval
;
555 #if !defined(__APPLE__)
556 when
.cyt_when
= dtrace_gethrtime() + when
.cyt_interval
;
559 #endif /* __APPLE__ */
561 ASSERT(prof
->prof_kind
== PROF_PROFILE
);
562 omni
.cyo_online
= profile_online
;
563 omni
.cyo_offline
= profile_offline
;
567 #if !defined(__APPLE__)
568 if (prof
->prof_kind
== PROF_TICK
) {
569 prof
->prof_cyclic
= cyclic_add(&hdlr
, &when
);
571 prof
->prof_cyclic
= cyclic_add_omni(&omni
);
574 if (prof
->prof_kind
== PROF_TICK
) {
575 prof
->prof_cyclic
= cyclic_timer_add(&hdlr
, &when
);
577 prof
->prof_cyclic
= (cyclic_id_t
)cyclic_add_omni(&omni
); /* cast puns cyclic_id_list_t with cyclic_id_t */
579 #endif /* __APPLE__ */
585 profile_disable(void *arg
, dtrace_id_t id
, void *parg
)
587 profile_probe_t
*prof
= parg
;
589 ASSERT(prof
->prof_cyclic
!= CYCLIC_NONE
);
590 ASSERT(MUTEX_HELD(&cpu_lock
));
592 #if !defined(__APPLE__)
593 cyclic_remove(prof
->prof_cyclic
);
595 #pragma unused(arg,id)
596 if (prof
->prof_kind
== PROF_TICK
) {
597 cyclic_timer_remove(prof
->prof_cyclic
);
599 cyclic_remove_omni((cyclic_id_list_t
)prof
->prof_cyclic
); /* cast puns cyclic_id_list_t with cyclic_id_t */
601 #endif /* __APPLE__ */
602 prof
->prof_cyclic
= CYCLIC_NONE
;
605 #if !defined(__APPLE__)
608 profile_usermode(void *arg
, dtrace_id_t id
, void *parg
)
610 return (CPU
->cpu_profile_pc
== 0);
614 profile_usermode(void *arg
, dtrace_id_t id
, void *parg
)
616 #pragma unused(arg,id,parg)
617 return 1; /* XXX_BOGUS */
619 #endif /* __APPLE__ */
621 static dtrace_pattr_t profile_attr
= {
622 { DTRACE_STABILITY_EVOLVING
, DTRACE_STABILITY_EVOLVING
, DTRACE_CLASS_COMMON
},
623 { DTRACE_STABILITY_UNSTABLE
, DTRACE_STABILITY_UNSTABLE
, DTRACE_CLASS_UNKNOWN
},
624 { DTRACE_STABILITY_PRIVATE
, DTRACE_STABILITY_PRIVATE
, DTRACE_CLASS_UNKNOWN
},
625 { DTRACE_STABILITY_EVOLVING
, DTRACE_STABILITY_EVOLVING
, DTRACE_CLASS_COMMON
},
626 { DTRACE_STABILITY_EVOLVING
, DTRACE_STABILITY_EVOLVING
, DTRACE_CLASS_COMMON
},
629 static dtrace_pops_t profile_pops
= {
643 profile_attach(dev_info_t
*devi
, ddi_attach_cmd_t cmd
)
649 return (DDI_SUCCESS
);
651 return (DDI_FAILURE
);
654 #if !defined(__APPLE__)
655 if (ddi_create_minor_node(devi
, "profile", S_IFCHR
, 0,
656 DDI_PSEUDO
, NULL
) == DDI_FAILURE
||
657 dtrace_register("profile", &profile_attr
,
658 DTRACE_PRIV_KERNEL
| DTRACE_PRIV_USER
, NULL
,
659 &profile_pops
, NULL
, &profile_id
) != 0) {
660 ddi_remove_minor_node(devi
, NULL
);
661 return (DDI_FAILURE
);
664 profile_max
= ddi_getprop(DDI_DEV_T_ANY
, devi
, DDI_PROP_DONTPASS
,
665 "profile-max-probes", PROFILE_MAX_DEFAULT
);
667 if (ddi_create_minor_node(devi
, "profile", S_IFCHR
, 0,
668 DDI_PSEUDO
, 0) == DDI_FAILURE
||
669 dtrace_register("profile", &profile_attr
,
670 DTRACE_PRIV_KERNEL
| DTRACE_PRIV_USER
, NULL
,
671 &profile_pops
, NULL
, &profile_id
) != 0) {
672 ddi_remove_minor_node(devi
, NULL
);
673 return (DDI_FAILURE
);
676 profile_max
= PROFILE_MAX_DEFAULT
;
677 #endif /* __APPLE__ */
679 ddi_report_dev(devi
);
681 return (DDI_SUCCESS
);
684 #if !defined(__APPLE__)
686 profile_detach(dev_info_t
*devi
, ddi_detach_cmd_t cmd
)
692 return (DDI_SUCCESS
);
694 return (DDI_FAILURE
);
697 if (dtrace_unregister(profile_id
) != 0)
698 return (DDI_FAILURE
);
700 ddi_remove_minor_node(devi
, NULL
);
701 return (DDI_SUCCESS
);
706 profile_info(dev_info_t
*dip
, ddi_info_cmd_t infocmd
, void *arg
, void **result
)
711 case DDI_INFO_DEVT2DEVINFO
:
712 *result
= (void *)profile_devi
;
715 case DDI_INFO_DEVT2INSTANCE
:
727 profile_open(dev_t
*devp
, int flag
, int otyp
, cred_t
*cred_p
)
732 static struct cb_ops profile_cb_ops
= {
733 profile_open
, /* open */
735 nulldev
, /* strategy */
745 ddi_prop_op
, /* cb_prop_op */
747 D_NEW
| D_MP
/* Driver compatibility flag */
750 static struct dev_ops profile_ops
= {
751 DEVO_REV
, /* devo_rev, */
753 profile_info
, /* get_dev_info */
754 nulldev
, /* identify */
756 profile_attach
, /* attach */
757 profile_detach
, /* detach */
759 &profile_cb_ops
, /* driver operations */
760 NULL
, /* bus operations */
761 nodev
/* dev power */
765 * Module linkage information for the kernel.
767 static struct modldrv modldrv
= {
768 &mod_driverops
, /* module type (this is a pseudo driver) */
769 "Profile Interrupt Tracing", /* name of module */
770 &profile_ops
, /* driver ops */
773 static struct modlinkage modlinkage
= {
782 return (mod_install(&modlinkage
));
786 _info(struct modinfo
*modinfop
)
788 return (mod_info(&modlinkage
, modinfop
));
794 return (mod_remove(&modlinkage
));
797 d_open_t _profile_open
;
799 int _profile_open(dev_t dev
, int flags
, int devtype
, struct proc
*p
)
801 #pragma unused(dev,flags,devtype,p)
805 #define PROFILE_MAJOR -24 /* let the kernel pick the device number */
808 * A struct describing which functions will get invoked for certain
811 static struct cdevsw profile_cdevsw
=
813 _profile_open
, /* open */
814 eno_opcl
, /* close */
815 eno_rdwrt
, /* read */
816 eno_rdwrt
, /* write */
817 eno_ioctl
, /* ioctl */
818 (stop_fcn_t
*)nulldev
, /* stop */
819 (reset_fcn_t
*)nulldev
, /* reset */
821 eno_select
, /* select */
823 eno_strat
, /* strategy */
829 static int gProfileInited
= 0;
831 void profile_init( void )
833 if (0 == gProfileInited
)
835 int majdevno
= cdevsw_add(PROFILE_MAJOR
, &profile_cdevsw
);
838 printf("profile_init: failed to allocate a major number!\n");
843 profile_attach( (dev_info_t
*)(uintptr_t)majdevno
, DDI_ATTACH
);
847 panic("profile_init: called twice!\n");
850 #endif /* __APPLE__ */