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 --- 6 unchanged lines hidden (view full) --- 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 * Portions Copyright 2010 The FreeBSD Foundation 22 * |
23 * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c 248983 2013-04-01 19:13:46Z pfg $ |
24 */ 25 26/* 27 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31#if defined(sun) --- 138 unchanged lines hidden (view full) --- 170 * fasttrap.conf file. Each time a probe is created, fasttrap_total is 171 * incremented by the number of tracepoints that may be associated with that 172 * probe; fasttrap_total is capped at fasttrap_max. 173 */ 174#define FASTTRAP_MAX_DEFAULT 250000 175static uint32_t fasttrap_max; 176static uint32_t fasttrap_total; 177 |
178/* 179 * Copyright (c) 2011, Joyent, Inc. All rights reserved. 180 */ |
181 182#define FASTTRAP_TPOINTS_DEFAULT_SIZE 0x4000 183#define FASTTRAP_PROVIDERS_DEFAULT_SIZE 0x100 184#define FASTTRAP_PROCS_DEFAULT_SIZE 0x100 185 186#define FASTTRAP_PID_NAME "pid" 187 188fasttrap_hash_t fasttrap_tpoints; --- 126 unchanged lines hidden (view full) --- 315 */ 316/*ARGSUSED*/ 317static void 318fasttrap_pid_cleanup_cb(void *data) 319{ 320 fasttrap_provider_t **fpp, *fp; 321 fasttrap_bucket_t *bucket; 322 dtrace_provider_id_t provid; |
323 int i, later = 0, rval; |
324 325 static volatile int in = 0; 326 ASSERT(in == 0); 327 in = 1; 328 329 while (fasttrap_cleanup_work) { 330 fasttrap_cleanup_work = 0; 331 mtx_unlock(&fasttrap_cleanup_mtx); --- 44 unchanged lines hidden (view full) --- 376 * to unregister fails and this is a retired 377 * provider, increment our flag to try again 378 * pretty soon. If we've consumed more than 379 * half of our total permitted number of 380 * probes call dtrace_condense() to try to 381 * clean out the unenabled probes. 382 */ 383 provid = fp->ftp_provid; |
384 if ((rval = dtrace_unregister(provid)) != 0) { |
385 if (fasttrap_total > fasttrap_max / 2) 386 (void) dtrace_condense(provid); |
387 388 if (rval == EAGAIN) 389 fp->ftp_marked = 1; 390 |
391 later += fp->ftp_marked; 392 fpp = &fp->ftp_next; 393 } else { 394 *fpp = fp->ftp_next; 395 fasttrap_provider_free(fp); 396 } 397 } 398 mutex_exit(&bucket->ftb_mtx); --- 11 unchanged lines hidden (view full) --- 410 * a second. This situation can occur in certain circumstances where 411 * providers cannot be unregistered even though they have no probes 412 * enabled because of an execution of dtrace -l or something similar. 413 * If the timeout has been disabled (set to 1 because we're trying 414 * to detach), we set fasttrap_cleanup_work to ensure that we'll 415 * get a chance to do that work if and when the timeout is reenabled 416 * (if detach fails). 417 */ |
418 if (later > 0) { 419 if (callout_active(&fasttrap_timeout)) { 420 callout_reset(&fasttrap_timeout, hz, 421 &fasttrap_pid_cleanup_cb, NULL); 422 } 423 |
424 else if (later > 0) 425 fasttrap_cleanup_work = 1; |
426 } else { |
427#if !defined(sun) 428 /* Nothing to be done for FreeBSD */ 429#endif 430 } 431 432 in = 0; 433} 434 --- 2096 unchanged lines hidden --- |