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:		bed4c52416 ("Implement RUSAGE_THREAD. Add td_rux...")
Differential Revision:	https://reviews.freebsd.org/D54040
This commit is contained in:
John Baldwin
2025-12-08 11:15:36 -05:00
parent 3f8ed605db
commit dafe50ebd8
+6 -2
View File
@@ -648,7 +648,8 @@ proc0_post(void *dummy __unused)
/*
* Now we can look at the time, having had a chance to verify the
* time from the filesystem. Pretend that proc0 started now.
* time from the filesystem. Pretend that all current threads
* started now.
*/
sx_slock(&allproc_lock);
FOREACH_PROC_IN_SYSTEM(p) {
@@ -661,10 +662,13 @@ proc0_post(void *dummy __unused)
PROC_STATLOCK(p);
rufetch(p, &ru); /* Clears thread stats */
ruxreset(&p->p_rux);
PROC_STATUNLOCK(p);
FOREACH_THREAD_IN_PROC(p, td) {
td->td_runtime = 0;
thread_lock(td);
ruxreset(&td->td_rux);
thread_unlock(td);
}
PROC_STATUNLOCK(p);
PROC_UNLOCK(p);
}
sx_sunlock(&allproc_lock);