PERFORCE change 132584 for review
John Birrell
jb at FreeBSD.org
Sat Jan 5 13:45:28 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=132584
Change 132584 by jb at jb_freebsd1 on 2008/01/05 21:44:43
Implement DTrace's virtual time.
Affected files ...
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_load.c#24 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_unload.c#20 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_vtime.c#3 edit
.. //depot/projects/dtrace/src/sys/kern/sched_4bsd.c#29 edit
.. //depot/projects/dtrace/src/sys/kern/sched_ule.c#22 edit
.. //depot/projects/dtrace/src/sys/sys/dtrace_bsd.h#11 edit
.. //depot/projects/dtrace/src/sys/sys/proc.h#29 edit
Differences ...
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_load.c#24 (text+ko) ====
@@ -50,10 +50,8 @@
/* Hook into the trap handler. */
dtrace_trap_func = dtrace_trap;
-#ifdef DOODAD
/* Hang our hook for thread switches. */
dtrace_vtime_switch_func = dtrace_vtime_switch;
-#endif
/*
* XXX This is a short term hack to avoid having to comment
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_unload.c#20 (text+ko) ====
@@ -163,10 +163,8 @@
* Reset our hook for thread switches, but ensure that vtime isn't
* active first.
*/
-#ifdef DOODAD
dtrace_vtime_active = 0;
dtrace_vtime_switch_func = NULL;
-#endif
/* Unhook from the trap handler. */
dtrace_trap_func = NULL;
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_vtime.c#3 (text+ko) ====
@@ -27,7 +27,6 @@
void
dtrace_vtime_enable(void)
{
-#ifdef DOODAD
dtrace_vtime_state_t state, nstate = 0;
do {
@@ -50,13 +49,11 @@
} while (dtrace_cas32((uint32_t *)&dtrace_vtime_active,
state, nstate) != state);
-#endif
}
void
dtrace_vtime_disable(void)
{
-#ifdef DOODAD
dtrace_vtime_state_t state, nstate = 0;
do {
@@ -79,34 +76,24 @@
} while (dtrace_cas32((uint32_t *)&dtrace_vtime_active,
state, nstate) != state);
-#endif
}
void
dtrace_vtime_switch(kthread_t *next)
{
-#ifdef DOODAD
dtrace_icookie_t cookie;
hrtime_t ts;
- if (tnf_tracing_active) {
- tnf_thread_switch(next);
-
- if (dtrace_vtime_active == DTRACE_VTIME_INACTIVE_TNF)
- return;
- }
-
cookie = dtrace_interrupt_disable();
ts = dtrace_gethrtime();
- if (curthread->td_dtrace_start != 0) {
- curthread->td_dtrace_vtime += ts - curthread->td_dtrace_start;
- curthread->td_dtrace_start = 0;
+ if (curthread->t_dtrace_start != 0) {
+ curthread->t_dtrace_vtime += ts - curthread->t_dtrace_start;
+ curthread->t_dtrace_start = 0;
}
if (next != NULL)
- next->td_dtrace_start = ts;
+ next->t_dtrace_start = ts;
dtrace_interrupt_enable(cookie);
-#endif
}
==== //depot/projects/dtrace/src/sys/kern/sched_4bsd.c#29 (text+ko) ====
@@ -59,6 +59,10 @@
#include <sys/pmckern.h>
#endif
+#ifdef KDTRACE_HOOKS
+#include <sys/dtrace_bsd.h>
+#endif
+
/*
* INVERSE_ESTCPU_WEIGHT is only suitable for statclock() frequencies in
* the range 100-256 Hz (approximately).
@@ -880,6 +884,16 @@
#endif
/* I feel sleepy */
lock_profile_release_lock(&sched_lock.lock_object);
+#ifdef KDTRACE
+ /*
+ * 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__);
==== //depot/projects/dtrace/src/sys/kern/sched_ule.c#22 (text+ko) ====
@@ -68,6 +68,10 @@
#include <sys/pmckern.h>
#endif
+#ifdef KDTRACE_HOOKS
+#include <sys/dtrace_bsd.h>
+#endif
+
#include <machine/cpu.h>
#include <machine/smp.h>
@@ -1896,6 +1900,17 @@
#endif
lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object);
TDQ_LOCKPTR(tdq)->mtx_lock = (uintptr_t)newtd;
+
+#ifdef KDTRACE
+ /*
+ * 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,
==== //depot/projects/dtrace/src/sys/sys/dtrace_bsd.h#11 (text+ko) ====
@@ -33,6 +33,7 @@
/* Forward definitions: */
struct trapframe;
+struct thread;
/*
* Cyclic clock function type definition used to hook the cyclic
@@ -65,6 +66,12 @@
/* Global variable in trap.c */
extern dtrace_invop_func_t dtrace_invop_func;
+/* Virtual time hook function type. */
+typedef void (*dtrace_vtime_switch_func_t)(struct thread *);
+
+extern int dtrace_vtime_active;
+extern dtrace_vtime_switch_func_t dtrace_vtime_switch_func;
+
/*
* Functions which allow the dtrace module to check that the kernel
* hooks have been compiled with sufficient space for it's private
==== //depot/projects/dtrace/src/sys/sys/proc.h#29 (text+ko) ====
@@ -445,11 +445,6 @@
#define TD_SET_RUNQ(td) (td)->td_state = TDS_RUNQ
#define TD_SET_CAN_RUN(td) (td)->td_state = TDS_CAN_RUN
-typedef void (*dtrace_vtime_switch_func_t)(struct thread *);
-
-extern int dtrace_vtime_active;
-extern dtrace_vtime_switch_func_t dtrace_vtime_switch_func;
-
/*
* An upcall is used when returning to userland. If a thread does not have
* an upcall on return to userland the thread exports its context and exits.
More information about the p4-projects
mailing list