summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2017-04-14 14:44:06 +0000
committeravg <avg@FreeBSD.org>2017-04-14 14:44:06 +0000
commit46c16fab10beb56d41392051ebede7165b9c68a7 (patch)
tree91a2c9a2d232beb90b03fd28ba3650f8f3350518 /sys/kern
parent65fd7bd8b660f708971ec165e47d0e2ac6ec3e2b (diff)
downloadFreeBSD-src-46c16fab10beb56d41392051ebede7165b9c68a7.zip
FreeBSD-src-46c16fab10beb56d41392051ebede7165b9c68a7.tar.gz
MFC r315851: move thread switch tracing from mi_switch to sched_switch
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_synch.c19
-rw-r--r--sys/kern/sched_4bsd.c13
-rw-r--r--sys/kern/sched_ule.c15
3 files changed, 28 insertions, 19 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index c717a9a..e0b05d6 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -73,13 +73,6 @@ __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);
@@ -469,23 +462,11 @@ mi_switch(int flags, struct thread *newtd)
PCPU_SET(switchticks, ticks);
CTR4(KTR_PROC, "mi_switch: old thread %ld (td_sched %p, pid %ld, %s)",
td->td_tid, td->td_sched, td->td_proc->p_pid, td->td_name);
-#if (KTR_COMPILE & KTR_SCHED) != 0
- if (TD_IS_IDLETHREAD(td))
- KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "idle",
- "prio:%d", td->td_priority);
- else
- 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
SDT_PROBE0(sched, , , preempt);
#ifdef XEN
PT_UPDATES_FLUSH();
#endif
sched_switch(td, newtd, flags);
- 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, td->td_proc->p_pid, td->td_name);
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index eddb2d4..6fa9270 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -1008,6 +1008,16 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
MPASS(newtd->td_lock == &sched_lock);
}
+#if (KTR_COMPILE & KTR_SCHED) != 0
+ if (TD_IS_IDLETHREAD(td))
+ KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "idle",
+ "prio:%d", td->td_priority);
+ else
+ 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
+
if (td != newtd) {
#ifdef HWPMC_HOOKS
if (PMC_PROC_IS_USING_PMCS(td->td_proc))
@@ -1056,6 +1066,9 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
} else
SDT_PROBE0(sched, , , remain__cpu);
+ KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running",
+ "prio:%d", td->td_priority);
+
#ifdef SMP
if (td->td_flags & TDF_IDLETD)
CPU_SET(PCPU_GET(cpuid), &idle_cpus_mask);
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 41f15e9..43bbc13 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -1906,6 +1906,17 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
mtx = thread_lock_block(td);
tdq_load_rem(tdq, td);
}
+
+#if (KTR_COMPILE & KTR_SCHED) != 0
+ if (TD_IS_IDLETHREAD(td))
+ KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "idle",
+ "prio:%d", td->td_priority);
+ else
+ 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
+
/*
* We enter here with the thread blocked and assigned to the
* appropriate cpu run-queue or sleep-queue and with the current
@@ -1956,6 +1967,10 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
thread_unblock_switch(td, mtx);
SDT_PROBE0(sched, , , remain__cpu);
}
+
+ KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running",
+ "prio:%d", td->td_priority);
+
/*
* Assert that all went well and return.
*/
OpenPOWER on IntegriCloud