fasttrap.c (247049) | fasttrap.c (248983) |
---|---|
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 * | 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 247049 2013-02-20 17:55:17Z gibbs $ | 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 | 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 */ |
|
178 179#define FASTTRAP_TPOINTS_DEFAULT_SIZE 0x4000 180#define FASTTRAP_PROVIDERS_DEFAULT_SIZE 0x100 181#define FASTTRAP_PROCS_DEFAULT_SIZE 0x100 182 183#define FASTTRAP_PID_NAME "pid" 184 185fasttrap_hash_t fasttrap_tpoints; --- 126 unchanged lines hidden (view full) --- 312 */ 313/*ARGSUSED*/ 314static void 315fasttrap_pid_cleanup_cb(void *data) 316{ 317 fasttrap_provider_t **fpp, *fp; 318 fasttrap_bucket_t *bucket; 319 dtrace_provider_id_t provid; | 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; |
320 int i, later = 0; | 323 int i, later = 0, rval; |
321 322 static volatile int in = 0; 323 ASSERT(in == 0); 324 in = 1; 325 326 while (fasttrap_cleanup_work) { 327 fasttrap_cleanup_work = 0; 328 mtx_unlock(&fasttrap_cleanup_mtx); --- 44 unchanged lines hidden (view full) --- 373 * to unregister fails and this is a retired 374 * provider, increment our flag to try again 375 * pretty soon. If we've consumed more than 376 * half of our total permitted number of 377 * probes call dtrace_condense() to try to 378 * clean out the unenabled probes. 379 */ 380 provid = fp->ftp_provid; | 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; |
381 if (dtrace_unregister(provid) != 0) { | 384 if ((rval = dtrace_unregister(provid)) != 0) { |
382 if (fasttrap_total > fasttrap_max / 2) 383 (void) dtrace_condense(provid); | 385 if (fasttrap_total > fasttrap_max / 2) 386 (void) dtrace_condense(provid); |
387 388 if (rval == EAGAIN) 389 fp->ftp_marked = 1; 390 |
|
384 later += fp->ftp_marked; 385 fpp = &fp->ftp_next; 386 } else { 387 *fpp = fp->ftp_next; 388 fasttrap_provider_free(fp); 389 } 390 } 391 mutex_exit(&bucket->ftb_mtx); --- 11 unchanged lines hidden (view full) --- 403 * a second. This situation can occur in certain circumstances where 404 * providers cannot be unregistered even though they have no probes 405 * enabled because of an execution of dtrace -l or something similar. 406 * If the timeout has been disabled (set to 1 because we're trying 407 * to detach), we set fasttrap_cleanup_work to ensure that we'll 408 * get a chance to do that work if and when the timeout is reenabled 409 * (if detach fails). 410 */ | 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 */ |
411 if (later > 0 && callout_active(&fasttrap_timeout)) 412 callout_reset(&fasttrap_timeout, hz, &fasttrap_pid_cleanup_cb, 413 NULL); | 418 if (later > 0) { 419 if (callout_active(&fasttrap_timeout)) { 420 callout_reset(&fasttrap_timeout, hz, 421 &fasttrap_pid_cleanup_cb, NULL); 422 } 423 |
414 else if (later > 0) 415 fasttrap_cleanup_work = 1; | 424 else if (later > 0) 425 fasttrap_cleanup_work = 1; |
416 else { | 426 } else { |
417#if !defined(sun) 418 /* Nothing to be done for FreeBSD */ 419#endif 420 } 421 422 in = 0; 423} 424 --- 2096 unchanged lines hidden --- | 427#if !defined(sun) 428 /* Nothing to be done for FreeBSD */ 429#endif 430 } 431 432 in = 0; 433} 434 --- 2096 unchanged lines hidden --- |