Deleted Added
sdiff udiff text old ( 248752 ) new ( 248983 )
full compact
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

--- 4 unchanged lines hidden (view full) ---

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 * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c 248752 2013-03-26 20:17:08Z pfg $
22 */
23
24/*
25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29#pragma ident "%Z%%M% %I% %E% SMI"

--- 147 unchanged lines hidden (view full) ---

177int dtrace_msgdsize_max = 128;
178hrtime_t dtrace_chill_max = 500 * (NANOSEC / MILLISEC); /* 500 ms */
179hrtime_t dtrace_chill_interval = NANOSEC; /* 1000 ms */
180int dtrace_devdepth_max = 32;
181int dtrace_err_verbose;
182hrtime_t dtrace_deadman_interval = NANOSEC;
183hrtime_t dtrace_deadman_timeout = (hrtime_t)10 * NANOSEC;
184hrtime_t dtrace_deadman_user = (hrtime_t)30 * NANOSEC;
185
186/*
187 * DTrace External Variables
188 *
189 * As dtrace(7D) is a kernel module, any DTrace variables are obviously
190 * available to DTrace consumers via the backtick (`) syntax. One of these,
191 * dtrace_zero, is made deliberately so: it is provided as a source of
192 * well-known, zero-filled memory. While this variable is not documented,

--- 5 unchanged lines hidden (view full) ---

198 * DTrace Internal Variables
199 */
200#if defined(sun)
201static dev_info_t *dtrace_devi; /* device info */
202#endif
203#if defined(sun)
204static vmem_t *dtrace_arena; /* probe ID arena */
205static vmem_t *dtrace_minor; /* minor number arena */
206static taskq_t *dtrace_taskq; /* task queue */
207#else
208static struct unrhdr *dtrace_arena; /* Probe ID number. */
209#endif
210static dtrace_probe_t **dtrace_probes; /* array of all probes */
211static int dtrace_nprobes; /* number of probes */
212static dtrace_provider_t *dtrace_provider; /* provider list */
213static dtrace_meta_t *dtrace_meta_pid; /* user-land meta provider */
214static int dtrace_opens; /* number of opens */
215static int dtrace_helpers; /* number of helpers */

--- 329 unchanged lines hidden (view full) ---

545 (act)->dta_difo->dtdo_rtype.dtdt_kind == DIF_TYPE_STRING)
546
547/* Function prototype definitions: */
548static size_t dtrace_strlen(const char *, size_t);
549static dtrace_probe_t *dtrace_probe_lookup_id(dtrace_id_t id);
550static void dtrace_enabling_provide(dtrace_provider_t *);
551static int dtrace_enabling_match(dtrace_enabling_t *, int *);
552static void dtrace_enabling_matchall(void);
553static dtrace_state_t *dtrace_anon_grab(void);
554static uint64_t dtrace_helper(int, dtrace_mstate_t *,
555 dtrace_state_t *, uint64_t, uint64_t);
556static dtrace_helpers_t *dtrace_helpers_create(proc_t *);
557static void dtrace_buffer_drop(dtrace_buffer_t *);
558static intptr_t dtrace_buffer_reserve(dtrace_buffer_t *, size_t, size_t,
559 dtrace_state_t *, dtrace_mstate_t *);
560static int dtrace_state_option(dtrace_state_t *, dtrace_optid_t,
561 dtrace_optval_t);
562static int dtrace_ecb_create_enable(dtrace_probe_t *, void *);
563static void dtrace_helper_provider_destroy(dtrace_helper_provider_t *);
564uint16_t dtrace_load16(uintptr_t);
565uint32_t dtrace_load32(uintptr_t);

--- 7022 unchanged lines hidden (view full) ---

7588 * Unregister the specified provider from the DTrace framework. This should
7589 * generally be called by DTrace providers in their detach(9E) entry point.
7590 */
7591int
7592dtrace_unregister(dtrace_provider_id_t id)
7593{
7594 dtrace_provider_t *old = (dtrace_provider_t *)id;
7595 dtrace_provider_t *prev = NULL;
7596 int i, self = 0;
7597 dtrace_probe_t *probe, *first = NULL;
7598
7599 if (old->dtpv_pops.dtps_enable ==
7600 (void (*)(void *, dtrace_id_t, void *))dtrace_nullop) {
7601 /*
7602 * If DTrace itself is the provider, we're called with locks
7603 * already held.
7604 */

--- 42 unchanged lines hidden (view full) ---

7647
7648 if (probe->dtpr_provider != old)
7649 continue;
7650
7651 if (probe->dtpr_ecb == NULL)
7652 continue;
7653
7654 /*
7655 * We have at least one ECB; we can't remove this provider.
7656 */
7657 if (!self) {
7658 mutex_exit(&dtrace_lock);
7659 mutex_exit(&mod_lock);
7660 mutex_exit(&dtrace_provider_lock);
7661 }
7662 return (EBUSY);
7663 }
7664
7665 /*
7666 * All of the probes for this provider are disabled; we can safely
7667 * remove all of them from their hash chains and from the probe array.
7668 */
7669 for (i = 0; i < dtrace_nprobes; i++) {
7670 if ((probe = dtrace_probes[i]) == NULL)

--- 80 unchanged lines hidden (view full) ---

7751 dtrace_provider_t *pvp = (dtrace_provider_t *)id;
7752
7753 ASSERT(pvp->dtpv_pops.dtps_enable !=
7754 (void (*)(void *, dtrace_id_t, void *))dtrace_nullop);
7755
7756 mutex_enter(&dtrace_provider_lock);
7757 mutex_enter(&dtrace_lock);
7758
7759 pvp->dtpv_defunct = 1;
7760
7761 mutex_exit(&dtrace_lock);
7762 mutex_exit(&dtrace_provider_lock);
7763}
7764
7765/*
7766 * Indicate whether or not DTrace has attached.
7767 */

--- 2946 unchanged lines hidden (view full) ---

10714 * the same CPU.
10715 */
10716static void
10717dtrace_buffer_switch(dtrace_buffer_t *buf)
10718{
10719 caddr_t tomax = buf->dtb_tomax;
10720 caddr_t xamot = buf->dtb_xamot;
10721 dtrace_icookie_t cookie;
10722
10723 ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
10724 ASSERT(!(buf->dtb_flags & DTRACEBUF_RING));
10725
10726 cookie = dtrace_interrupt_disable();
10727 buf->dtb_tomax = xamot;
10728 buf->dtb_xamot = tomax;
10729 buf->dtb_xamot_drops = buf->dtb_drops;
10730 buf->dtb_xamot_offset = buf->dtb_offset;
10731 buf->dtb_xamot_errors = buf->dtb_errors;
10732 buf->dtb_xamot_flags = buf->dtb_flags;
10733 buf->dtb_offset = 0;
10734 buf->dtb_drops = 0;
10735 buf->dtb_errors = 0;
10736 buf->dtb_flags &= ~(DTRACEBUF_ERROR | DTRACEBUF_DROPPED);
10737 dtrace_interrupt_enable(cookie);
10738}
10739
10740/*
10741 * Note: called from cross call context. This function activates a buffer
10742 * on a CPU. As with dtrace_buffer_switch(), the atomicity of the operation
10743 * is guaranteed by the disabling of interrupts.
10744 */

--- 472 unchanged lines hidden (view full) ---

11217
11218 if (buf->dtb_offset > buf->dtb_xamot_offset) {
11219 bzero(buf->dtb_tomax + buf->dtb_offset,
11220 buf->dtb_size - buf->dtb_offset);
11221 bzero(buf->dtb_tomax, buf->dtb_xamot_offset);
11222 }
11223}
11224
11225static void
11226dtrace_buffer_free(dtrace_buffer_t *bufs)
11227{
11228 int i;
11229
11230 for (i = 0; i < NCPU; i++) {
11231 dtrace_buffer_t *buf = &bufs[i];
11232

--- 455 unchanged lines hidden (view full) ---

11688 } while (all && (prv = prv->dtpv_next) != NULL);
11689
11690 mutex_exit(&dtrace_lock);
11691 dtrace_probe_provide(NULL, all ? NULL : prv);
11692 mutex_enter(&dtrace_lock);
11693}
11694
11695/*
11696 * DTrace DOF Functions
11697 */
11698/*ARGSUSED*/
11699static void
11700dtrace_dof_error(dof_hdr_t *dof, const char *str)
11701{
11702 if (dtrace_err_verbose)
11703 cmn_err(CE_WARN, "failed to process DOF: %s", str);

--- 3820 unchanged lines hidden (view full) ---

15524 state = dtrace_state_create(devp, cred_p);
15525#else
15526 state = dtrace_state_create(dev);
15527#if __FreeBSD_version < 800039
15528 dev->si_drv1 = state;
15529#else
15530 devfs_set_cdevpriv(state, dtrace_dtr);
15531#endif
15532#endif
15533
15534 mutex_exit(&cpu_lock);
15535
15536 if (state == NULL) {
15537#if defined(sun)
15538 if (--dtrace_opens == 0)
15539 (void) kdi_dtrace_set(KDI_DTSET_DTRACE_DEACTIVATE);

--- 71 unchanged lines hidden (view full) ---

15611 }
15612
15613 ASSERT(dtrace_opens > 0);
15614#if defined(sun)
15615 if (--dtrace_opens == 0)
15616 (void) kdi_dtrace_set(KDI_DTSET_DTRACE_DEACTIVATE);
15617#else
15618 --dtrace_opens;
15619#endif
15620
15621 mutex_exit(&dtrace_lock);
15622 mutex_exit(&cpu_lock);
15623
15624#if __FreeBSD_version < 800039
15625 /* Schedule this cloned device to be destroyed. */
15626 destroy_dev_sched(dev);

--- 1088 unchanged lines hidden ---