Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/dev/profile/profile.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/poll.h> | #include <sys/poll.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/selinfo.h> | #include <sys/selinfo.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sysctl.h> | |||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <sys/unistd.h> | #include <sys/unistd.h> | ||||
#include <machine/cpu.h> | #include <machine/cpu.h> | ||||
#include <machine/stdarg.h> | #include <machine/stdarg.h> | ||||
#include <sys/dtrace.h> | #include <sys/dtrace.h> | ||||
#include <sys/dtrace_bsd.h> | #include <sys/dtrace_bsd.h> | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
struct profile_probe_percpu; | struct profile_probe_percpu; | ||||
#ifdef __mips | #ifdef __mips | ||||
/* bogus */ | /* bogus */ | ||||
#define PROF_ARTIFICIAL_FRAMES 3 | #define PROF_ARTIFICIAL_FRAMES 3 | ||||
#endif | #endif | ||||
#ifdef __arm__ | #ifdef __arm__ | ||||
/* | #define PROF_ARTIFICIAL_FRAMES 3 | ||||
* At least on ARMv7, this appears to work quite well. | |||||
*/ | |||||
#define PROF_ARTIFICIAL_FRAMES 10 | |||||
#endif | #endif | ||||
#ifdef __aarch64__ | #ifdef __aarch64__ | ||||
/* TODO: verify */ | /* TODO: verify */ | ||||
#define PROF_ARTIFICIAL_FRAMES 10 | #define PROF_ARTIFICIAL_FRAMES 10 | ||||
#endif | #endif | ||||
typedef struct profile_probe { | typedef struct profile_probe { | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | static dtrace_pops_t profile_pops = { | ||||
NULL, | NULL, | ||||
NULL, | NULL, | ||||
profile_destroy | profile_destroy | ||||
}; | }; | ||||
static struct cdev *profile_cdev; | static struct cdev *profile_cdev; | ||||
static dtrace_provider_id_t profile_id; | static dtrace_provider_id_t profile_id; | ||||
static hrtime_t profile_interval_min = NANOSEC / 5000; /* 5000 hz */ | static hrtime_t profile_interval_min = NANOSEC / 5000; /* 5000 hz */ | ||||
static int profile_aframes = 0; /* override */ | static int profile_aframes = PROF_ARTIFICIAL_FRAMES; | ||||
SYSCTL_DECL(_kern_dtrace); | |||||
SYSCTL_NODE(_kern_dtrace, OID_AUTO, profile, CTLFLAG_RD, 0, "DTrace profile parameters"); | |||||
SYSCTL_UINT(_kern_dtrace_profile, OID_AUTO, aframes, CTLFLAG_RW, &profile_aframes, | |||||
stas: SYSCTL_INT? | |||||
0, "Skipped frames for profile provider"); | |||||
static sbintime_t | static sbintime_t | ||||
nsec_to_sbt(hrtime_t nsec) | nsec_to_sbt(hrtime_t nsec) | ||||
{ | { | ||||
time_t sec; | time_t sec; | ||||
/* | /* | ||||
* We need to calculate nsec * 2^32 / 10^9 | * We need to calculate nsec * 2^32 / 10^9 | ||||
* Seconds and nanoseconds are split to avoid overflow. | * Seconds and nanoseconds are split to avoid overflow. | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | #ifdef illumos | ||||
prof->prof_cyclic = CYCLIC_NONE; | prof->prof_cyclic = CYCLIC_NONE; | ||||
#else | #else | ||||
prof->prof_interval = nsec_to_sbt(interval); | prof->prof_interval = nsec_to_sbt(interval); | ||||
callout_init(&prof->prof_cyclic, 1); | callout_init(&prof->prof_cyclic, 1); | ||||
#endif | #endif | ||||
prof->prof_kind = kind; | prof->prof_kind = kind; | ||||
prof->prof_id = dtrace_probe_create(profile_id, | prof->prof_id = dtrace_probe_create(profile_id, | ||||
NULL, NULL, name, | NULL, NULL, name, | ||||
profile_aframes ? profile_aframes : PROF_ARTIFICIAL_FRAMES, prof); | profile_aframes, prof); | ||||
} | } | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
static void | static void | ||||
profile_provide(void *arg, dtrace_probedesc_t *desc) | profile_provide(void *arg, dtrace_probedesc_t *desc) | ||||
{ | { | ||||
int i, j, rate, kind; | int i, j, rate, kind; | ||||
hrtime_t val = 0, mult = 1, len = 0; | hrtime_t val = 0, mult = 1, len = 0; | ||||
▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines |
SYSCTL_INT?