Skip to content

Commit 3f8ed60

Browse files
committed
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
1 parent 0ff0c19 commit 3f8ed60

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

sys/kern/init_main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,7 @@ proc0_post(void *dummy __unused)
660660
microuptime(&p->p_stats->p_start);
661661
PROC_STATLOCK(p);
662662
rufetch(p, &ru); /* Clears thread stats */
663-
p->p_rux.rux_runtime = 0;
664-
p->p_rux.rux_uticks = 0;
665-
p->p_rux.rux_sticks = 0;
666-
p->p_rux.rux_iticks = 0;
663+
ruxreset(&p->p_rux);
667664
PROC_STATUNLOCK(p);
668665
FOREACH_THREAD_IN_PROC(p, td) {
669666
td->td_runtime = 0;

sys/sys/proc.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,18 @@ td_get_sched(struct thread *td)
13261326
return ((struct td_sched *)&td[1]);
13271327
}
13281328

1329+
static __inline void
1330+
ruxreset(struct rusage_ext *rux)
1331+
{
1332+
rux->rux_runtime = 0;
1333+
rux->rux_uticks = 0;
1334+
rux->rux_sticks = 0;
1335+
rux->rux_iticks = 0;
1336+
rux->rux_uu = 0;
1337+
rux->rux_su = 0;
1338+
rux->rux_tu = 0;
1339+
}
1340+
13291341
#define PROC_ID_PID 0
13301342
#define PROC_ID_GROUP 1
13311343
#define PROC_ID_SESSION 2

0 commit comments

Comments
 (0)