Skip to content

Commit dafe50e

Browse files
committed
thread0: Clear td_rux stats in proc0_post
proc0_post aims to reset the CPU usage accounting for all threads and processes in the system to zero once the time of day is verified. However, not all of the per-thread stats were not being cleared, resulting in over-reported time for thread0 post-boot. Reviewed by: olce, kib, markj Fixes: bed4c52 ("Implement RUSAGE_THREAD. Add td_rux...") Differential Revision: https://reviews.freebsd.org/D54040
1 parent 3f8ed60 commit dafe50e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sys/kern/init_main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,8 @@ proc0_post(void *dummy __unused)
648648

649649
/*
650650
* Now we can look at the time, having had a chance to verify the
651-
* time from the filesystem. Pretend that proc0 started now.
651+
* time from the filesystem. Pretend that all current threads
652+
* started now.
652653
*/
653654
sx_slock(&allproc_lock);
654655
FOREACH_PROC_IN_SYSTEM(p) {
@@ -661,10 +662,13 @@ proc0_post(void *dummy __unused)
661662
PROC_STATLOCK(p);
662663
rufetch(p, &ru); /* Clears thread stats */
663664
ruxreset(&p->p_rux);
664-
PROC_STATUNLOCK(p);
665665
FOREACH_THREAD_IN_PROC(p, td) {
666666
td->td_runtime = 0;
667+
thread_lock(td);
668+
ruxreset(&td->td_rux);
669+
thread_unlock(td);
667670
}
671+
PROC_STATUNLOCK(p);
668672
PROC_UNLOCK(p);
669673
}
670674
sx_sunlock(&allproc_lock);

0 commit comments

Comments
 (0)