summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_ule.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-01-03 21:03:28 +0000
committerjhb <jhb@FreeBSD.org>2012-01-03 21:03:28 +0000
commitb759911211e03135d6bf5a0eaaf1f806eeeeff88 (patch)
tree89ea291cf034389fe88d6494a07b7354f8f61c8d /sys/kern/sched_ule.c
parent0c5a3f31efc71beb9a4e0e208ad135288a8142a5 (diff)
downloadFreeBSD-src-b759911211e03135d6bf5a0eaaf1f806eeeeff88.zip
FreeBSD-src-b759911211e03135d6bf5a0eaaf1f806eeeeff88.tar.gz
Some small fixes to CPU accounting for threads:
- Only initialize the per-cpu switchticks and switchtime in sched_throw() for the very first context switch on APs during boot. This avoids a small gap between the middle of thread_exit() and sched_throw() where time is not accounted to any thread. - In thread_exit(), update the timestamp bookkeeping to track the changes to mi_switch() introduced by td_rux so that the code once again matches the comment claiming it is mimicing mi_switch(). Specifically, only update the per-thread stats directly and depend on ruxagg() to update p_rux rather than adjusting p_rux directly. While here, move the timestamp bookkeeping as late in the function as possible. Reviewed by: bde, kib MFC after: 1 week
Diffstat (limited to 'sys/kern/sched_ule.c')
-rw-r--r--sys/kern/sched_ule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 87e3655..2065b9f 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -2587,6 +2587,8 @@ sched_throw(struct thread *td)
/* Correct spinlock nesting and acquire the correct lock. */
TDQ_LOCK(tdq);
spinlock_exit();
+ PCPU_SET(switchtime, cpu_ticks());
+ PCPU_SET(switchticks, ticks);
} else {
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
tdq_load_rem(tdq, td);
@@ -2595,8 +2597,6 @@ sched_throw(struct thread *td)
KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));
newtd = choosethread();
TDQ_LOCKPTR(tdq)->mtx_lock = (uintptr_t)newtd;
- PCPU_SET(switchtime, cpu_ticks());
- PCPU_SET(switchticks, ticks);
cpu_throw(td, newtd); /* doesn't return */
}
OpenPOWER on IntegriCloud