Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_lockstat.c
Show All 39 Lines | |||||
/* | /* | ||||
* The following must match the type definition of dtrace_probe. It is | * The following must match the type definition of dtrace_probe. It is | ||||
* defined this way to avoid having to rely on CDDL code. | * defined this way to avoid having to rely on CDDL code. | ||||
*/ | */ | ||||
uint32_t lockstat_probemap[LS_NPROBES]; | uint32_t lockstat_probemap[LS_NPROBES]; | ||||
void (*lockstat_probe_func)(uint32_t, uintptr_t, uintptr_t, | void (*lockstat_probe_func)(uint32_t, uintptr_t, uintptr_t, | ||||
uintptr_t, uintptr_t, uintptr_t); | uintptr_t, uintptr_t, uintptr_t); | ||||
int lockstat_enabled = 0; | |||||
uint64_t | uint64_t | ||||
lockstat_nsecs(void) | lockstat_nsecs(void) | ||||
{ | { | ||||
struct bintime bt; | struct bintime bt; | ||||
uint64_t ns; | uint64_t ns; | ||||
if (!lockstat_enabled) | |||||
return (0); | |||||
binuptime(&bt); | binuptime(&bt); | ||||
ns = bt.sec * (uint64_t)1000000000; | ns = bt.sec * (uint64_t)1000000000; | ||||
ns += ((uint64_t)1000000000 * (uint32_t)(bt.frac >> 32)) >> 32; | ns += ((uint64_t)1000000000 * (uint32_t)(bt.frac >> 32)) >> 32; | ||||
return (ns); | return (ns); | ||||
} | } | ||||
#endif /* KDTRACE_HOOKS */ | #endif /* KDTRACE_HOOKS */ |