summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_synch.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2009-01-17 07:17:57 +0000
committerjeff <jeff@FreeBSD.org>2009-01-17 07:17:57 +0000
commit3d8d825555e01db8b5e675c6852c0b611791c3eb (patch)
treede5dcf2f543f8bc9f57e15ad2509863476bbe371 /sys/kern/kern_synch.c
parentc4410efa0c6a38771669b82f73318d656bd1edd6 (diff)
downloadFreeBSD-src-3d8d825555e01db8b5e675c6852c0b611791c3eb.zip
FreeBSD-src-3d8d825555e01db8b5e675c6852c0b611791c3eb.tar.gz
- Implement generic macros for producing KTR records that are compatible
with src/tools/sched/schedgraph.py. This allows developers to quickly create a graphical view of ktr data for any resource in the system. - Add sched_tdname() and the pcpu field 'name' for quickly and uniformly identifying records associated with a thread or cpu. - Reimplement the KTR_SCHED traces using the new generic facility. Obtained from: attilio Discussed with: jhb Sponsored by: Nokia
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r--sys/kern/kern_synch.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 53e3ced..bc539af 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -71,6 +71,13 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#endif
+#define KTDSTATE(td) \
+ (((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \
+ ((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \
+ ((td)->td_inhibitors & TDI_SWAPPED) != 0 ? "swapped" : \
+ ((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \
+ ((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding")
+
static void synch_setup(void *dummy);
SYSINIT(synch_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, synch_setup,
NULL);
@@ -425,25 +432,19 @@ mi_switch(int flags, struct thread *newtd)
td->td_tid, td->td_sched, p->p_pid, td->td_name);
#if (KTR_COMPILE & KTR_SCHED) != 0
if (TD_IS_IDLETHREAD(td))
- CTR3(KTR_SCHED, "mi_switch: %p(%s) prio %d idle",
- td, td->td_name, td->td_priority);
- else if (newtd != NULL)
- CTR5(KTR_SCHED,
- "mi_switch: %p(%s) prio %d preempted by %p(%s)",
- td, td->td_name, td->td_priority, newtd,
- newtd->td_name);
+ KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "idle",
+ "prio:%d", td->td_priority);
else
- CTR6(KTR_SCHED,
- "mi_switch: %p(%s) prio %d inhibit %d wmesg %s lock %s",
- td, td->td_name, td->td_priority,
- td->td_inhibitors, td->td_wmesg, td->td_lockname);
+ KTR_STATE3(KTR_SCHED, "thread", sched_tdname(td), KTDSTATE(td),
+ "prio:%d", td->td_priority, "wmesg:\"%s\"", td->td_wmesg,
+ "lockname:\"%s\"", td->td_lockname);
#endif
#ifdef XEN
PT_UPDATES_FLUSH();
#endif
sched_switch(td, newtd, flags);
- CTR3(KTR_SCHED, "mi_switch: running %p(%s) prio %d",
- td, td->td_name, td->td_priority);
+ KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running",
+ "prio:%d", td->td_priority);
CTR4(KTR_PROC, "mi_switch: new thread %ld (td_sched %p, pid %ld, %s)",
td->td_tid, td->td_sched, p->p_pid, td->td_name);
OpenPOWER on IntegriCloud