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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user