summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_synch.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2008-01-10 22:11:20 +0000
committerrwatson <rwatson@FreeBSD.org>2008-01-10 22:11:20 +0000
commitf261f9865b0f750ea6f3b27feebcf093412d9dbf (patch)
tree521eeaf16fcaaa04187cb36d5416f01065cdf9a3 /sys/kern/kern_synch.c
parent2fdbb8b316f250eccd5656acc19a211e94e5c7b3 (diff)
downloadFreeBSD-src-f261f9865b0f750ea6f3b27feebcf093412d9dbf.zip
FreeBSD-src-f261f9865b0f750ea6f3b27feebcf093412d9dbf.tar.gz
Don't zero td_runtime when billing thread CPU usage to the process;
maintain a separate td_incruntime to hold unbilled CPU usage for the thread that has the previous properties of td_runtime. When thread information is requested using the thread monitoring sysctls, export thread td_runtime instead of process rusage runtime in kinfo_proc. This restores the display of individual ithread and other kernel thread CPU usage since inception in ps -H and top -SH, as well for libthr user threads, valuable debugging information lost with the move to try kthreads since they are no longer independent processes. There is universal agreement that we should rewrite the process and thread export sysctls, but this commit gets things going a bit better in the mean time. Likewise, there are resevations about the continued validity of statclock given the speed of modern processors. Reviewed by: attilio, emaste, jhb, julian
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r--sys/kern/kern_synch.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 9d02497..ad13c2b 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -371,7 +371,7 @@ wakeup_one(ident)
void
mi_switch(int flags, struct thread *newtd)
{
- uint64_t new_switchtime;
+ uint64_t runtime, new_switchtime;
struct thread *td;
struct proc *p;
@@ -409,7 +409,9 @@ mi_switch(int flags, struct thread *newtd)
* thread was running, and add that to its total so far.
*/
new_switchtime = cpu_ticks();
- td->td_runtime += new_switchtime - PCPU_GET(switchtime);
+ runtime = new_switchtime - PCPU_GET(switchtime);
+ td->td_runtime += runtime;
+ td->td_incruntime += runtime;
PCPU_SET(switchtime, new_switchtime);
td->td_generation++; /* bump preempt-detect counter */
PCPU_INC(cnt.v_swtch);
OpenPOWER on IntegriCloud