dtrace_sysctl.c revision 273736
1179237Sjb/* 2179237Sjb * CDDL HEADER START 3179237Sjb * 4179237Sjb * The contents of this file are subject to the terms of the 5179237Sjb * Common Development and Distribution License (the "License"). 6179237Sjb * You may not use this file except in compliance with the License. 7179237Sjb * 8179237Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9179237Sjb * or http://www.opensolaris.org/os/licensing. 10179237Sjb * See the License for the specific language governing permissions 11179237Sjb * and limitations under the License. 12179237Sjb * 13179237Sjb * When distributing Covered Code, include this CDDL HEADER in each 14179237Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15179237Sjb * If applicable, add the following below this CDDL HEADER, with the 16179237Sjb * fields enclosed by brackets "[]" replaced with your own identifying 17179237Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 18179237Sjb * 19179237Sjb * CDDL HEADER END 20179237Sjb * 21179237Sjb * $FreeBSD: stable/10/sys/cddl/dev/dtrace/dtrace_sysctl.c 273736 2014-10-27 14:38:00Z hselasky $ 22179237Sjb * 23179237Sjb */ 24179237Sjb 25266102SmarkjSYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters"); 26266102Smarkj 27179237Sjbint dtrace_debug = 0; 28179237SjbTUNABLE_INT("debug.dtrace.debug", &dtrace_debug); 29179237SjbSYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); 30179237Sjb 31179237Sjb/* Report registered DTrace providers. */ 32179237Sjbstatic int 33179237Sjbsysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) 34179237Sjb{ 35179237Sjb char *p_name = NULL; 36179237Sjb dtrace_provider_t 37179237Sjb *prov = dtrace_provider; 38179237Sjb int error = 0; 39179237Sjb size_t len = 0; 40179237Sjb 41179237Sjb mutex_enter(&dtrace_provider_lock); 42179237Sjb mutex_enter(&dtrace_lock); 43179237Sjb 44179237Sjb /* Compute the length of the space-separated provider name string. */ 45179237Sjb while (prov != NULL) { 46179237Sjb len += strlen(prov->dtpv_name) + 1; 47179237Sjb prov = prov->dtpv_next; 48179237Sjb } 49179237Sjb 50179237Sjb if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL) 51179237Sjb error = ENOMEM; 52179237Sjb else { 53179237Sjb /* Start with an empty string. */ 54179237Sjb *p_name = '\0'; 55179237Sjb 56179237Sjb /* Point to the first provider again. */ 57179237Sjb prov = dtrace_provider; 58179237Sjb 59179237Sjb /* Loop through the providers, appending the names. */ 60179237Sjb while (prov != NULL) { 61179237Sjb if (prov != dtrace_provider) 62179237Sjb (void) strlcat(p_name, " ", len); 63179237Sjb 64179237Sjb (void) strlcat(p_name, prov->dtpv_name, len); 65179237Sjb 66179237Sjb prov = prov->dtpv_next; 67179237Sjb } 68179237Sjb } 69179237Sjb 70179237Sjb mutex_exit(&dtrace_lock); 71179237Sjb mutex_exit(&dtrace_provider_lock); 72179237Sjb 73179237Sjb if (p_name != NULL) { 74179237Sjb error = sysctl_handle_string(oidp, p_name, len, req); 75179237Sjb 76179237Sjb kmem_free(p_name, 0); 77179237Sjb } 78179237Sjb 79179237Sjb return (error); 80179237Sjb} 81179237Sjb 82179237SjbSYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD, 83266102Smarkj 0, 0, sysctl_dtrace_providers, "A", "available DTrace providers"); 84179237Sjb 85266102SmarkjSYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace parameters"); 86266102Smarkj 87273736ShselaskySYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW, 88266102Smarkj &dtrace_dof_maxsize, 0, "largest allowed DOF table"); 89266102Smarkj 90273736ShselaskySYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW, 91266102Smarkj &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions"); 92269520Smarkj 93269520SmarkjSYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max, 94269520Smarkj 0, "largest allowed argument to memstr(), 0 indicates no limit"); 95