Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Dec 2025 15:32:41 +0000
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: cdad10ea780f - stable/14 - thread0: Clear td_rux stats in proc0_post
Message-ID:  <69457019.45401.2994adf1@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=cdad10ea780f9b2f4d49a073a07709b2ceb9d59a

commit cdad10ea780f9b2f4d49a073a07709b2ceb9d59a
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-12-08 16:15:36 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-12-19 15:19:41 +0000

    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:          bed4c5241663 ("Implement RUSAGE_THREAD. Add td_rux...")
    Differential Revision:  https://reviews.freebsd.org/D54040
    (cherry picked from commit dafe50ebd874ca3ccd5908c441cee9f478c501f0)
---
 sys/kern/init_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 47707b4068ad..51a6e7e7d909 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -650,7 +650,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) {
@@ -663,10 +664,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);


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69457019.45401.2994adf1>