lockstat.h revision fb81f5532aeec22da92ae11861736f38ef47528a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_LOCKSTAT_H
#define _SYS_LOCKSTAT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#define LS_MUTEX_ENTER_ACQUIRE 0
#define LS_MUTEX_ENTER_BLOCK 1
#define LS_MUTEX_ENTER_SPIN 2
#define LS_MUTEX_EXIT_RELEASE 3
#define LS_MUTEX_DESTROY_RELEASE 4
#define LS_MUTEX_TRYENTER_ACQUIRE 5
#define LS_LOCK_SET_ACQUIRE 6
#define LS_LOCK_SET_SPIN 7
#define LS_LOCK_SET_SPL_ACQUIRE 8
#define LS_LOCK_SET_SPL_SPIN 9
#define LS_LOCK_TRY_ACQUIRE 10
#define LS_LOCK_CLEAR_RELEASE 11
#define LS_LOCK_CLEAR_SPLX_RELEASE 12
#define LS_CLOCK_UNLOCK_RELEASE 13
#define LS_RW_ENTER_ACQUIRE 14
#define LS_RW_ENTER_BLOCK 15
#define LS_RW_EXIT_RELEASE 16
#define LS_RW_TRYENTER_ACQUIRE 17
#define LS_RW_TRYUPGRADE_UPGRADE 18
#define LS_RW_DOWNGRADE_DOWNGRADE 19
#define LS_THREAD_LOCK_ACQUIRE 20
#define LS_THREAD_LOCK_SPIN 21
#define LS_THREAD_LOCK_HIGH_ACQUIRE 22
#define LS_THREAD_LOCK_HIGH_SPIN 23
#define LS_TURNSTILE_INTERLOCK_SPIN 24
#define LS_NPROBES 25
#define LS_MUTEX_ENTER "mutex_enter"
#define LS_MUTEX_EXIT "mutex_exit"
#define LS_MUTEX_DESTROY "mutex_destroy"
#define LS_MUTEX_TRYENTER "mutex_tryenter"
#define LS_LOCK_SET "lock_set"
#define LS_LOCK_SET_SPL "lock_set_spl"
#define LS_LOCK_TRY "lock_try"
#define LS_LOCK_CLEAR "lock_clear"
#define LS_LOCK_CLEAR_SPLX "lock_clear_splx"
#define LS_CLOCK_UNLOCK "CLOCK_UNLOCK"
#define LS_RW_ENTER "rw_enter"
#define LS_RW_EXIT "rw_exit"
#define LS_RW_TRYENTER "rw_tryenter"
#define LS_RW_TRYUPGRADE "rw_tryupgrade"
#define LS_RW_DOWNGRADE "rw_downgrade"
#define LS_THREAD_LOCK "thread_lock"
#define LS_THREAD_LOCK_HIGH "thread_lock_high"
#define LS_ACQUIRE "acquire"
#define LS_RELEASE "release"
#define LS_SPIN "spin"
#define LS_BLOCK "block"
#define LS_UPGRADE "upgrade"
#define LS_DOWNGRADE "downgrade"
#define LS_TYPE_ADAPTIVE "adaptive"
#define LS_TYPE_SPIN "spin"
#define LS_TYPE_THREAD "thread"
#define LS_TYPE_RW "rw"
#ifndef _ASM
#include <sys/inttypes.h>
#ifdef _KERNEL
/*
* Platform-independent kernel support for the lockstat driver.
*/
extern int lockstat_active_threads(void);
extern int lockstat_depth(void);
extern void lockstat_hot_patch(void);
/*
* Macros to record lockstat probes.
*/
/* used for 32 bit systems to avoid overflow */
#if defined(_ILP32)
#else
#define CLAMP32(x) (x)
#endif
if (lockstat_probemap[(probe)]) { \
dtrace_id_t id; \
curthread->t_lockstat++; \
membar_enter(); \
curthread->t_lockstat--; \
}
/*
* Return timestamp for start of busy-waiting (for spin probes)
*/
#define LOCKSTAT_START_TIME(probe) ( \
)
/*
* Record elapsed time since LOCKSTAT_START_TIME was called if the
* probe is enabled at start and end, else return 0. t_start must
* be the value returned by LOCKSTAT_START_TIME.
*/
if (lockstat_probemap[(probe)]) { \
dtrace_id_t id; \
curthread->t_lockstat++; \
membar_enter(); \
if (t_spin) { \
} \
0, 0, 0); \
} \
curthread->t_lockstat--; \
}
#endif /* _KERNEL */
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_LOCKSTAT_H */