aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/sched_4bsd.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2012-01-03 21:03:28 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2012-01-03 21:03:28 +0000
commit7e3a96ea37f3c6027428a7eda642399f13f18323 (patch)
tree89ea291cf034389fe88d6494a07b7354f8f61c8d /sys/kern/sched_4bsd.c
parent48a1e3f6247fccc93495140ab13b93cc7f6d7768 (diff)
downloadsrc-7e3a96ea37f3c6027428a7eda642399f13f18323.tar.gz
src-7e3a96ea37f3c6027428a7eda642399f13f18323.zip
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
Notes
Notes: svn path=/head/; revision=229429
Diffstat (limited to 'sys/kern/sched_4bsd.c')
-rw-r--r--sys/kern/sched_4bsd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index 0fd6481f9cfc..16cc033204e4 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -1572,14 +1572,14 @@ sched_throw(struct thread *td)
if (td == NULL) {
mtx_lock_spin(&sched_lock);
spinlock_exit();
+ PCPU_SET(switchtime, cpu_ticks());
+ PCPU_SET(switchticks, ticks);
} else {
lock_profile_release_lock(&sched_lock.lock_object);
MPASS(td->td_lock == &sched_lock);
}
mtx_assert(&sched_lock, MA_OWNED);
KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));
- PCPU_SET(switchtime, cpu_ticks());
- PCPU_SET(switchticks, ticks);
cpu_throw(td, choosethread()); /* doesn't return */
}