git: b35c6373910a - stable/15 - ruxreset: Add an inline function to reset all the stats in rusage_ext
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 Dec 2025 15:32:12 UTC
The branch stable/15 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=b35c6373910aef21bd01f7b52b4b58bd85ed306d
commit b35c6373910aef21bd01f7b52b4b58bd85ed306d
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-12-08 16:15:20 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-12-19 15:19:44 +0000
ruxreset: Add an inline function to reset all the stats in rusage_ext
Use it in proc0_post to reset per-process CPU usage.
Suggested by: olce
Reviewed by: olce, kib
Differential Revision: https://reviews.freebsd.org/D54049
(cherry picked from commit 3f8ed605dbd0ee211ce8fe59c0c072b916d6311c)
---
sys/kern/init_main.c | 5 +----
sys/sys/proc.h | 12 ++++++++++++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index a2898f75a795..3f3ebd386150 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -660,10 +660,7 @@ proc0_post(void *dummy __unused)
microuptime(&p->p_stats->p_start);
PROC_STATLOCK(p);
rufetch(p, &ru); /* Clears thread stats */
- p->p_rux.rux_runtime = 0;
- p->p_rux.rux_uticks = 0;
- p->p_rux.rux_sticks = 0;
- p->p_rux.rux_iticks = 0;
+ ruxreset(&p->p_rux);
PROC_STATUNLOCK(p);
FOREACH_THREAD_IN_PROC(p, td) {
td->td_runtime = 0;
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 81f0d41d6a6f..5142f67d0a42 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1326,6 +1326,18 @@ td_get_sched(struct thread *td)
return ((struct td_sched *)&td[1]);
}
+static __inline void
+ruxreset(struct rusage_ext *rux)
+{
+ rux->rux_runtime = 0;
+ rux->rux_uticks = 0;
+ rux->rux_sticks = 0;
+ rux->rux_iticks = 0;
+ rux->rux_uu = 0;
+ rux->rux_su = 0;
+ rux->rux_tu = 0;
+}
+
#define PROC_ID_PID 0
#define PROC_ID_GROUP 1
#define PROC_ID_SESSION 2