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]
25 static int dtrace_verbose_ioctl;
26 SYSCTL_INT(_debug_dtrace, OID_AUTO, verbose_ioctl, CTLFLAG_RW,
27 &dtrace_verbose_ioctl, 0, "log DTrace ioctls");
29 #define DTRACE_IOCTL_PRINTF(fmt, ...) if (dtrace_verbose_ioctl) printf(fmt, ## __VA_ARGS__ )
32 dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
36 dof_helper_t *dhp = NULL;
37 dof_hdr_t *dof = NULL;
40 case DTRACEHIOC_ADDDOF:
41 dhp = (dof_helper_t *)addr;
42 /* XXX all because dofhp_dof is 64 bit */
43 addr = (caddr_t)(vm_offset_t)dhp->dofhp_dof;
46 dof = dtrace_dof_copyin((intptr_t)addr, &rval);
51 mutex_enter(&dtrace_lock);
52 if ((rval = dtrace_helper_slurp((dof_hdr_t *)dof, dhp)) != -1) {
55 copyout(dhp, addr, sizeof(*dhp));
61 mutex_exit(&dtrace_lock);
63 case DTRACEHIOC_REMOVE:
64 mutex_enter(&dtrace_lock);
65 rval = dtrace_helper_destroygen((int)*addr);
66 mutex_exit(&dtrace_lock);
78 dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
79 int flags __unused, struct thread *td)
81 dtrace_state_t *state;
82 devfs_get_cdevpriv((void **) &state);
88 if (state->dts_anon) {
89 ASSERT(dtrace_anon.dta_state == NULL);
90 state = state->dts_anon;
94 case DTRACEIOC_AGGDESC: {
95 dtrace_aggdesc_t **paggdesc = (dtrace_aggdesc_t **) addr;
96 dtrace_aggdesc_t aggdesc;
98 dtrace_aggregation_t *agg;
101 dtrace_recdesc_t *lrec;
106 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_AGGDESC\n",__func__,__LINE__);
108 if (copyin((void *) *paggdesc, &aggdesc, sizeof (aggdesc)) != 0)
111 mutex_enter(&dtrace_lock);
113 if ((agg = dtrace_aggid2agg(state, aggdesc.dtagd_id)) == NULL) {
114 mutex_exit(&dtrace_lock);
118 aggdesc.dtagd_epid = agg->dtag_ecb->dte_epid;
120 nrecs = aggdesc.dtagd_nrecs;
121 aggdesc.dtagd_nrecs = 0;
123 offs = agg->dtag_base;
124 lrec = &agg->dtag_action.dta_rec;
125 aggdesc.dtagd_size = lrec->dtrd_offset + lrec->dtrd_size - offs;
127 for (act = agg->dtag_first; ; act = act->dta_next) {
128 ASSERT(act->dta_intuple ||
129 DTRACEACT_ISAGG(act->dta_kind));
132 * If this action has a record size of zero, it
133 * denotes an argument to the aggregating action.
134 * Because the presence of this record doesn't (or
135 * shouldn't) affect the way the data is interpreted,
136 * we don't copy it out to save user-level the
137 * confusion of dealing with a zero-length record.
139 if (act->dta_rec.dtrd_size == 0) {
140 ASSERT(agg->dtag_hasarg);
144 aggdesc.dtagd_nrecs++;
146 if (act == &agg->dtag_action)
151 * Now that we have the size, we need to allocate a temporary
152 * buffer in which to store the complete description. We need
153 * the temporary buffer to be able to drop dtrace_lock()
154 * across the copyout(), below.
156 size = sizeof (dtrace_aggdesc_t) +
157 (aggdesc.dtagd_nrecs * sizeof (dtrace_recdesc_t));
159 buf = kmem_alloc(size, KM_SLEEP);
160 dest = (uintptr_t)buf;
162 bcopy(&aggdesc, (void *)dest, sizeof (aggdesc));
163 dest += offsetof(dtrace_aggdesc_t, dtagd_rec[0]);
165 for (act = agg->dtag_first; ; act = act->dta_next) {
166 dtrace_recdesc_t rec = act->dta_rec;
169 * See the comment in the above loop for why we pass
170 * over zero-length records.
172 if (rec.dtrd_size == 0) {
173 ASSERT(agg->dtag_hasarg);
180 rec.dtrd_offset -= offs;
181 bcopy(&rec, (void *)dest, sizeof (rec));
182 dest += sizeof (dtrace_recdesc_t);
184 if (act == &agg->dtag_action)
188 mutex_exit(&dtrace_lock);
190 if (copyout(buf, (void *) *paggdesc, dest - (uintptr_t)buf) != 0) {
191 kmem_free(buf, size);
195 kmem_free(buf, size);
198 case DTRACEIOC_AGGSNAP:
199 case DTRACEIOC_BUFSNAP: {
200 dtrace_bufdesc_t **pdesc = (dtrace_bufdesc_t **) addr;
201 dtrace_bufdesc_t desc;
203 dtrace_buffer_t *buf;
205 dtrace_debug_output();
207 if (copyin((void *) *pdesc, &desc, sizeof (desc)) != 0)
210 DTRACE_IOCTL_PRINTF("%s(%d): %s curcpu %d cpu %d\n",
212 cmd == DTRACEIOC_AGGSNAP ?
213 "DTRACEIOC_AGGSNAP":"DTRACEIOC_BUFSNAP",
214 curcpu, desc.dtbd_cpu);
216 if (desc.dtbd_cpu >= NCPU)
218 if (pcpu_find(desc.dtbd_cpu) == NULL)
221 mutex_enter(&dtrace_lock);
223 if (cmd == DTRACEIOC_BUFSNAP) {
224 buf = &state->dts_buffer[desc.dtbd_cpu];
226 buf = &state->dts_aggbuffer[desc.dtbd_cpu];
229 if (buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL)) {
230 size_t sz = buf->dtb_offset;
232 if (state->dts_activity != DTRACE_ACTIVITY_STOPPED) {
233 mutex_exit(&dtrace_lock);
238 * If this buffer has already been consumed, we're
239 * going to indicate that there's nothing left here
242 if (buf->dtb_flags & DTRACEBUF_CONSUMED) {
243 mutex_exit(&dtrace_lock);
247 desc.dtbd_errors = 0;
248 desc.dtbd_oldest = 0;
251 if (copyout(&desc, (void *) *pdesc, sz) != 0)
258 * If this is a ring buffer that has wrapped, we want
259 * to copy the whole thing out.
261 if (buf->dtb_flags & DTRACEBUF_WRAPPED) {
262 dtrace_buffer_polish(buf);
266 if (copyout(buf->dtb_tomax, desc.dtbd_data, sz) != 0) {
267 mutex_exit(&dtrace_lock);
272 desc.dtbd_drops = buf->dtb_drops;
273 desc.dtbd_errors = buf->dtb_errors;
274 desc.dtbd_oldest = buf->dtb_xamot_offset;
275 desc.dtbd_timestamp = dtrace_gethrtime();
277 mutex_exit(&dtrace_lock);
279 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
282 buf->dtb_flags |= DTRACEBUF_CONSUMED;
287 if (buf->dtb_tomax == NULL) {
288 ASSERT(buf->dtb_xamot == NULL);
289 mutex_exit(&dtrace_lock);
293 cached = buf->dtb_tomax;
294 ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
296 dtrace_xcall(desc.dtbd_cpu,
297 (dtrace_xcall_t)dtrace_buffer_switch, buf);
299 state->dts_errors += buf->dtb_xamot_errors;
302 * If the buffers did not actually switch, then the cross call
303 * did not take place -- presumably because the given CPU is
304 * not in the ready set. If this is the case, we'll return
307 if (buf->dtb_tomax == cached) {
308 ASSERT(buf->dtb_xamot != cached);
309 mutex_exit(&dtrace_lock);
313 ASSERT(cached == buf->dtb_xamot);
315 DTRACE_IOCTL_PRINTF("%s(%d): copyout the buffer snapshot\n",__func__,__LINE__);
318 * We have our snapshot; now copy it out.
320 if (copyout(buf->dtb_xamot, desc.dtbd_data,
321 buf->dtb_xamot_offset) != 0) {
322 mutex_exit(&dtrace_lock);
326 desc.dtbd_size = buf->dtb_xamot_offset;
327 desc.dtbd_drops = buf->dtb_xamot_drops;
328 desc.dtbd_errors = buf->dtb_xamot_errors;
329 desc.dtbd_oldest = 0;
330 desc.dtbd_timestamp = buf->dtb_switched;
332 mutex_exit(&dtrace_lock);
334 DTRACE_IOCTL_PRINTF("%s(%d): copyout buffer desc: size %zd drops %lu errors %lu\n",__func__,__LINE__,(size_t) desc.dtbd_size,(u_long) desc.dtbd_drops,(u_long) desc.dtbd_errors);
337 * Finally, copy out the buffer description.
339 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
344 case DTRACEIOC_CONF: {
347 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_CONF\n",__func__,__LINE__);
349 bzero(&conf, sizeof (conf));
350 conf.dtc_difversion = DIF_VERSION;
351 conf.dtc_difintregs = DIF_DIR_NREGS;
352 conf.dtc_diftupregs = DIF_DTR_NREGS;
353 conf.dtc_ctfmodel = CTF_MODEL_NATIVE;
355 *((dtrace_conf_t *) addr) = conf;
359 case DTRACEIOC_DOFGET: {
360 dof_hdr_t **pdof = (dof_hdr_t **) addr;
361 dof_hdr_t hdr, *dof = *pdof;
365 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_DOFGET\n",__func__,__LINE__);
367 if (copyin((void *)dof, &hdr, sizeof (hdr)) != 0)
370 mutex_enter(&dtrace_lock);
371 dof = dtrace_dof_create(state);
372 mutex_exit(&dtrace_lock);
374 len = MIN(hdr.dofh_loadsz, dof->dofh_loadsz);
375 rval = copyout(dof, (void *) *pdof, len);
376 dtrace_dof_destroy(dof);
378 return (rval == 0 ? 0 : EFAULT);
380 case DTRACEIOC_ENABLE: {
381 dof_hdr_t *dof = NULL;
382 dtrace_enabling_t *enab = NULL;
383 dtrace_vstate_t *vstate;
386 dtrace_enable_io_t *p = (dtrace_enable_io_t *) addr;
388 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_ENABLE\n",__func__,__LINE__);
391 * If a NULL argument has been passed, we take this as our
392 * cue to reevaluate our enablings.
394 if (p->dof == NULL) {
395 dtrace_enabling_matchall();
400 if ((dof = dtrace_dof_copyin((uintptr_t) p->dof, &rval)) == NULL)
403 mutex_enter(&cpu_lock);
404 mutex_enter(&dtrace_lock);
405 vstate = &state->dts_vstate;
407 if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE) {
408 mutex_exit(&dtrace_lock);
409 mutex_exit(&cpu_lock);
410 dtrace_dof_destroy(dof);
414 if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, B_TRUE) != 0) {
415 mutex_exit(&dtrace_lock);
416 mutex_exit(&cpu_lock);
417 dtrace_dof_destroy(dof);
421 if ((rval = dtrace_dof_options(dof, state)) != 0) {
422 dtrace_enabling_destroy(enab);
423 mutex_exit(&dtrace_lock);
424 mutex_exit(&cpu_lock);
425 dtrace_dof_destroy(dof);
429 if ((err = dtrace_enabling_match(enab, &p->n_matched)) == 0) {
430 err = dtrace_enabling_retain(enab);
432 dtrace_enabling_destroy(enab);
435 mutex_exit(&cpu_lock);
436 mutex_exit(&dtrace_lock);
437 dtrace_dof_destroy(dof);
441 case DTRACEIOC_EPROBE: {
442 dtrace_eprobedesc_t **pepdesc = (dtrace_eprobedesc_t **) addr;
443 dtrace_eprobedesc_t epdesc;
445 dtrace_action_t *act;
451 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_EPROBE\n",__func__,__LINE__);
453 if (copyin((void *)*pepdesc, &epdesc, sizeof (epdesc)) != 0)
456 mutex_enter(&dtrace_lock);
458 if ((ecb = dtrace_epid2ecb(state, epdesc.dtepd_epid)) == NULL) {
459 mutex_exit(&dtrace_lock);
463 if (ecb->dte_probe == NULL) {
464 mutex_exit(&dtrace_lock);
468 epdesc.dtepd_probeid = ecb->dte_probe->dtpr_id;
469 epdesc.dtepd_uarg = ecb->dte_uarg;
470 epdesc.dtepd_size = ecb->dte_size;
472 nrecs = epdesc.dtepd_nrecs;
473 epdesc.dtepd_nrecs = 0;
474 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
475 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
478 epdesc.dtepd_nrecs++;
482 * Now that we have the size, we need to allocate a temporary
483 * buffer in which to store the complete description. We need
484 * the temporary buffer to be able to drop dtrace_lock()
485 * across the copyout(), below.
487 size = sizeof (dtrace_eprobedesc_t) +
488 (epdesc.dtepd_nrecs * sizeof (dtrace_recdesc_t));
490 buf = kmem_alloc(size, KM_SLEEP);
491 dest = (uintptr_t)buf;
493 bcopy(&epdesc, (void *)dest, sizeof (epdesc));
494 dest += offsetof(dtrace_eprobedesc_t, dtepd_rec[0]);
496 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
497 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
503 bcopy(&act->dta_rec, (void *)dest,
504 sizeof (dtrace_recdesc_t));
505 dest += sizeof (dtrace_recdesc_t);
508 mutex_exit(&dtrace_lock);
510 if (copyout(buf, (void *) *pepdesc, dest - (uintptr_t)buf) != 0) {
511 kmem_free(buf, size);
515 kmem_free(buf, size);
518 case DTRACEIOC_FORMAT: {
519 dtrace_fmtdesc_t *fmt = (dtrace_fmtdesc_t *) addr;
523 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_FORMAT\n",__func__,__LINE__);
525 mutex_enter(&dtrace_lock);
527 if (fmt->dtfd_format == 0 ||
528 fmt->dtfd_format > state->dts_nformats) {
529 mutex_exit(&dtrace_lock);
534 * Format strings are allocated contiguously and they are
535 * never freed; if a format index is less than the number
536 * of formats, we can assert that the format map is non-NULL
537 * and that the format for the specified index is non-NULL.
539 ASSERT(state->dts_formats != NULL);
540 str = state->dts_formats[fmt->dtfd_format - 1];
543 len = strlen(str) + 1;
545 if (len > fmt->dtfd_length) {
546 fmt->dtfd_length = len;
548 if (copyout(str, fmt->dtfd_string, len) != 0) {
549 mutex_exit(&dtrace_lock);
554 mutex_exit(&dtrace_lock);
559 processorid_t *cpuid = (processorid_t *) addr;
561 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_GO\n",__func__,__LINE__);
563 rval = dtrace_state_go(state, cpuid);
567 case DTRACEIOC_PROBEARG: {
568 dtrace_argdesc_t *desc = (dtrace_argdesc_t *) addr;
569 dtrace_probe_t *probe;
570 dtrace_provider_t *prov;
572 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROBEARG\n",__func__,__LINE__);
574 if (desc->dtargd_id == DTRACE_IDNONE)
577 if (desc->dtargd_ndx == DTRACE_ARGNONE)
580 mutex_enter(&dtrace_provider_lock);
582 mutex_enter(&mod_lock);
584 mutex_enter(&dtrace_lock);
586 if (desc->dtargd_id > dtrace_nprobes) {
587 mutex_exit(&dtrace_lock);
589 mutex_exit(&mod_lock);
591 mutex_exit(&dtrace_provider_lock);
595 if ((probe = dtrace_probes[desc->dtargd_id - 1]) == NULL) {
596 mutex_exit(&dtrace_lock);
598 mutex_exit(&mod_lock);
600 mutex_exit(&dtrace_provider_lock);
604 mutex_exit(&dtrace_lock);
606 prov = probe->dtpr_provider;
608 if (prov->dtpv_pops.dtps_getargdesc == NULL) {
610 * There isn't any typed information for this probe.
611 * Set the argument number to DTRACE_ARGNONE.
613 desc->dtargd_ndx = DTRACE_ARGNONE;
615 desc->dtargd_native[0] = '\0';
616 desc->dtargd_xlate[0] = '\0';
617 desc->dtargd_mapping = desc->dtargd_ndx;
619 prov->dtpv_pops.dtps_getargdesc(prov->dtpv_arg,
620 probe->dtpr_id, probe->dtpr_arg, desc);
624 mutex_exit(&mod_lock);
626 mutex_exit(&dtrace_provider_lock);
630 case DTRACEIOC_PROBEMATCH:
631 case DTRACEIOC_PROBES: {
632 dtrace_probedesc_t *p_desc = (dtrace_probedesc_t *) addr;
633 dtrace_probe_t *probe = NULL;
634 dtrace_probekey_t pkey;
641 DTRACE_IOCTL_PRINTF("%s(%d): %s\n",__func__,__LINE__,
642 cmd == DTRACEIOC_PROBEMATCH ?
643 "DTRACEIOC_PROBEMATCH":"DTRACEIOC_PROBES");
645 p_desc->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
646 p_desc->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
647 p_desc->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
648 p_desc->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
651 * Before we attempt to match this probe, we want to give
652 * all providers the opportunity to provide it.
654 if (p_desc->dtpd_id == DTRACE_IDNONE) {
655 mutex_enter(&dtrace_provider_lock);
656 dtrace_probe_provide(p_desc, NULL);
657 mutex_exit(&dtrace_provider_lock);
661 if (cmd == DTRACEIOC_PROBEMATCH) {
662 dtrace_probekey(p_desc, &pkey);
663 pkey.dtpk_id = DTRACE_IDNONE;
666 dtrace_cred2priv(td->td_ucred, &priv, &uid, &zoneid);
668 mutex_enter(&dtrace_lock);
670 if (cmd == DTRACEIOC_PROBEMATCH) {
671 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
672 if ((probe = dtrace_probes[i - 1]) != NULL &&
673 (m = dtrace_match_probe(probe, &pkey,
674 priv, uid, zoneid)) != 0)
679 mutex_exit(&dtrace_lock);
684 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
685 if ((probe = dtrace_probes[i - 1]) != NULL &&
686 dtrace_match_priv(probe, priv, uid, zoneid))
692 mutex_exit(&dtrace_lock);
696 dtrace_probe_description(probe, p_desc);
697 mutex_exit(&dtrace_lock);
701 case DTRACEIOC_PROVIDER: {
702 dtrace_providerdesc_t *pvd = (dtrace_providerdesc_t *) addr;
703 dtrace_provider_t *pvp;
705 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROVIDER\n",__func__,__LINE__);
707 pvd->dtvd_name[DTRACE_PROVNAMELEN - 1] = '\0';
708 mutex_enter(&dtrace_provider_lock);
710 for (pvp = dtrace_provider; pvp != NULL; pvp = pvp->dtpv_next) {
711 if (strcmp(pvp->dtpv_name, pvd->dtvd_name) == 0)
715 mutex_exit(&dtrace_provider_lock);
720 bcopy(&pvp->dtpv_priv, &pvd->dtvd_priv, sizeof (dtrace_ppriv_t));
721 bcopy(&pvp->dtpv_attr, &pvd->dtvd_attr, sizeof (dtrace_pattr_t));
725 case DTRACEIOC_REPLICATE: {
726 dtrace_repldesc_t *desc = (dtrace_repldesc_t *) addr;
727 dtrace_probedesc_t *match = &desc->dtrpd_match;
728 dtrace_probedesc_t *create = &desc->dtrpd_create;
731 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_REPLICATE\n",__func__,__LINE__);
733 match->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
734 match->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
735 match->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
736 match->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
738 create->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
739 create->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
740 create->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
741 create->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
743 mutex_enter(&dtrace_lock);
744 err = dtrace_enabling_replicate(state, match, create);
745 mutex_exit(&dtrace_lock);
749 case DTRACEIOC_STATUS: {
750 dtrace_status_t *stat = (dtrace_status_t *) addr;
751 dtrace_dstate_t *dstate;
755 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STATUS\n",__func__,__LINE__);
758 * See the comment in dtrace_state_deadman() for the reason
759 * for setting dts_laststatus to INT64_MAX before setting
760 * it to the correct value.
762 state->dts_laststatus = INT64_MAX;
763 dtrace_membar_producer();
764 state->dts_laststatus = dtrace_gethrtime();
766 bzero(stat, sizeof (*stat));
768 mutex_enter(&dtrace_lock);
770 if (state->dts_activity == DTRACE_ACTIVITY_INACTIVE) {
771 mutex_exit(&dtrace_lock);
775 if (state->dts_activity == DTRACE_ACTIVITY_DRAINING)
776 stat->dtst_exiting = 1;
778 nerrs = state->dts_errors;
779 dstate = &state->dts_vstate.dtvs_dynvars;
781 for (i = 0; i < NCPU; i++) {
783 if (pcpu_find(i) == NULL)
786 dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[i];
788 stat->dtst_dyndrops += dcpu->dtdsc_drops;
789 stat->dtst_dyndrops_dirty += dcpu->dtdsc_dirty_drops;
790 stat->dtst_dyndrops_rinsing += dcpu->dtdsc_rinsing_drops;
792 if (state->dts_buffer[i].dtb_flags & DTRACEBUF_FULL)
795 nerrs += state->dts_buffer[i].dtb_errors;
797 for (j = 0; j < state->dts_nspeculations; j++) {
798 dtrace_speculation_t *spec;
799 dtrace_buffer_t *buf;
801 spec = &state->dts_speculations[j];
802 buf = &spec->dtsp_buffer[i];
803 stat->dtst_specdrops += buf->dtb_xamot_drops;
807 stat->dtst_specdrops_busy = state->dts_speculations_busy;
808 stat->dtst_specdrops_unavail = state->dts_speculations_unavail;
809 stat->dtst_stkstroverflows = state->dts_stkstroverflows;
810 stat->dtst_dblerrors = state->dts_dblerrors;
812 (state->dts_activity == DTRACE_ACTIVITY_KILLED);
813 stat->dtst_errors = nerrs;
815 mutex_exit(&dtrace_lock);
819 case DTRACEIOC_STOP: {
821 processorid_t *cpuid = (processorid_t *) addr;
823 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STOP\n",__func__,__LINE__);
825 mutex_enter(&dtrace_lock);
826 rval = dtrace_state_stop(state, cpuid);
827 mutex_exit(&dtrace_lock);