proc0_post: Fix some locking issues
- Filter out PRS_NEW procs as rufetch() tries taking the thread lock which may not yet be initialized. - Hold PROC_LOCK to ensure stability of iterating the threads. - p_rux fields are protected by the process statlock as well. MFC after: 2 weeks Reviewed by: kib Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D15809
This commit is contained in:
parent
78bcf87e3e
commit
03bd1b693e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335183
@ -618,17 +618,23 @@ proc0_post(void *dummy __unused)
|
||||
*/
|
||||
sx_slock(&allproc_lock);
|
||||
FOREACH_PROC_IN_SYSTEM(p) {
|
||||
PROC_LOCK(p);
|
||||
if (p->p_state == PRS_NEW) {
|
||||
PROC_UNLOCK(p);
|
||||
continue;
|
||||
}
|
||||
microuptime(&p->p_stats->p_start);
|
||||
PROC_STATLOCK(p);
|
||||
rufetch(p, &ru); /* Clears thread stats */
|
||||
PROC_STATUNLOCK(p);
|
||||
p->p_rux.rux_runtime = 0;
|
||||
p->p_rux.rux_uticks = 0;
|
||||
p->p_rux.rux_sticks = 0;
|
||||
p->p_rux.rux_iticks = 0;
|
||||
PROC_STATUNLOCK(p);
|
||||
FOREACH_THREAD_IN_PROC(p, td) {
|
||||
td->td_runtime = 0;
|
||||
}
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
sx_sunlock(&allproc_lock);
|
||||
PCPU_SET(switchtime, cpu_ticks());
|
||||
|
Loading…
Reference in New Issue
Block a user