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
This commit is contained in:
John Baldwin
2025-12-08 11:15:20 -05:00
parent 0ff0c19e7f
commit 3f8ed605db
2 changed files with 13 additions and 4 deletions
+1 -4
View File
@@ -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;
+12
View File
@@ -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