1 /* $NetBSD: dtrace_anon.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License, Version 1.0 only 7 * (the "License"). You may not use this file except in compliance 8 * with the License. 9 * 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * or http://www.opensolaris.org/os/licensing. 12 * See the License for the specific language governing permissions 13 * and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 * 23 * $FreeBSD: src/sys/cddl/dev/dtrace/dtrace_anon.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ 24 */ 25 26 /* 27 * DTrace Anonymous Enabling Functions 28 */ 29 static void 30 dtrace_anon_init(void *dummy) 31 { 32 dtrace_state_t *state = NULL; 33 dtrace_enabling_t *enab; 34 35 mutex_enter(&cpu_lock); 36 mutex_enter(&dtrace_provider_lock); 37 mutex_enter(&dtrace_lock); 38 39 dtrace_anon_property(); 40 41 mutex_exit(&cpu_lock); 42 43 /* 44 * If there are already providers, we must ask them to provide their 45 * probes, and then match any anonymous enabling against them. Note 46 * that there should be no other retained enablings at this time: 47 * the only retained enablings at this time should be the anonymous 48 * enabling. 49 */ 50 if (dtrace_anon.dta_enabling != NULL) { 51 ASSERT(dtrace_retained == dtrace_anon.dta_enabling); 52 53 dtrace_enabling_provide(NULL); 54 state = dtrace_anon.dta_state; 55 56 /* 57 * We couldn't hold cpu_lock across the above call to 58 * dtrace_enabling_provide(), but we must hold it to actually 59 * enable the probes. We have to drop all of our locks, pick 60 * up cpu_lock, and regain our locks before matching the 61 * retained anonymous enabling. 62 */ 63 mutex_exit(&dtrace_lock); 64 mutex_exit(&dtrace_provider_lock); 65 66 mutex_enter(&cpu_lock); 67 mutex_enter(&dtrace_provider_lock); 68 mutex_enter(&dtrace_lock); 69 70 if ((enab = dtrace_anon.dta_enabling) != NULL) 71 (void) dtrace_enabling_match(enab, NULL); 72 73 mutex_exit(&cpu_lock); 74 } 75 76 mutex_exit(&dtrace_provider_lock); 77 mutex_exit(&dtrace_lock); 78 79 if (state != NULL) { 80 /* 81 * If we created any anonymous state, set it going now. 82 */ 83 (void) dtrace_state_go(state, &dtrace_anon.dta_beganon); 84 } 85 } 86