diff options
author | jb <jb@FreeBSD.org> | 2008-05-25 01:44:58 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 2008-05-25 01:44:58 +0000 |
commit | 1c6ecc547ffaa812b2fe49de249c0123b4850038 (patch) | |
tree | d7817ab3980cddc07959538e125b84cd7009f965 /sys/kern | |
parent | 933221c70b19378787045078df471a91ad53325b (diff) | |
download | FreeBSD-src-1c6ecc547ffaa812b2fe49de249c0123b4850038.zip FreeBSD-src-1c6ecc547ffaa812b2fe49de249c0123b4850038.tar.gz |
Add the vtime (virtual time) hooks for DTrace.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sched_4bsd.c | 17 | ||||
-rw-r--r-- | sys/kern/sched_ule.c | 18 |
2 files changed, 35 insertions, 0 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index cefe4ac..a5768ec 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include "opt_hwpmc_hooks.h" #include "opt_sched.h" +#include "opt_kdtrace.h" #include <sys/param.h> #include <sys/systm.h> @@ -61,6 +62,12 @@ __FBSDID("$FreeBSD$"); #include <sys/pmckern.h> #endif +#ifdef KDTRACE_HOOKS +#include <sys/dtrace_bsd.h> +int dtrace_vtime_active; +dtrace_vtime_switch_func_t dtrace_vtime_switch_func; +#endif + /* * INVERSE_ESTCPU_WEIGHT is only suitable for statclock() frequencies in * the range 100-256 Hz (approximately). @@ -962,6 +969,16 @@ sched_switch(struct thread *td, struct thread *newtd, int flags) #endif /* I feel sleepy */ lock_profile_release_lock(&sched_lock.lock_object); +#ifdef KDTRACE_HOOKS + /* + * If DTrace has set the active vtime enum to anything + * other than INACTIVE (0), then it should have set the + * function to call. + */ + if (dtrace_vtime_active) + (*dtrace_vtime_switch_func)(newtd); +#endif + cpu_switch(td, newtd, td->td_lock); lock_profile_obtain_lock_success(&sched_lock.lock_object, 0, 0, __FILE__, __LINE__); diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 7fe80af..172f41a 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "opt_hwpmc_hooks.h" +#include "opt_kdtrace.h" #include "opt_sched.h" #include <sys/param.h> @@ -69,6 +70,12 @@ __FBSDID("$FreeBSD$"); #include <sys/pmckern.h> #endif +#ifdef KDTRACE_HOOKS +#include <sys/dtrace_bsd.h> +int dtrace_vtime_active; +dtrace_vtime_switch_func_t dtrace_vtime_switch_func; +#endif + #include <machine/cpu.h> #include <machine/smp.h> @@ -1823,6 +1830,17 @@ sched_switch(struct thread *td, struct thread *newtd, int flags) #endif lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object); TDQ_LOCKPTR(tdq)->mtx_lock = (uintptr_t)newtd; + +#ifdef KDTRACE_HOOKS + /* + * If DTrace has set the active vtime enum to anything + * other than INACTIVE (0), then it should have set the + * function to call. + */ + if (dtrace_vtime_active) + (*dtrace_vtime_switch_func)(newtd); +#endif + cpu_switch(td, newtd, mtx); /* * We may return from cpu_switch on a different cpu. However, |