Instead of using hand-rolled loops where not needed switch them

to FOREACH_PROC_IN_SYSTEM() to have a single pattern to look for.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D15916
This commit is contained in:
Bjoern A. Zeeb 2018-06-20 11:42:06 +00:00
parent c30e5927b6
commit 7938a4425a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335441
3 changed files with 4 additions and 8 deletions

View File

@ -2286,7 +2286,7 @@ prison_remove_one(struct prison *pr)
* Kill all processes unfortunate enough to be attached to this prison.
*/
sx_slock(&allproc_lock);
LIST_FOREACH(p, &allproc, p_list) {
FOREACH_PROC_IN_SYSTEM(p) {
PROC_LOCK(p);
if (p->p_state != PRS_NEW && p->p_ucred &&
p->p_ucred->cr_prison == pr)

View File

@ -3176,7 +3176,7 @@ resume_all_proc(void)
}
}
/* Did the loop above missed any stopped process ? */
LIST_FOREACH(p, &allproc, p_list) {
FOREACH_PROC_IN_SYSTEM(p) {
/* No need for proc lock. */
if ((p->p_flag & P_TOTAL_STOP) != 0)
goto again;

View File

@ -580,14 +580,12 @@ kdb_thr_first(void)
struct proc *p;
struct thread *thr;
p = LIST_FIRST(&allproc);
while (p != NULL) {
FOREACH_PROC_IN_SYSTEM(p) {
if (p->p_flag & P_INMEM) {
thr = FIRST_THREAD_IN_PROC(p);
if (thr != NULL)
return (thr);
}
p = LIST_NEXT(p, p_list);
}
return (NULL);
}
@ -597,11 +595,9 @@ kdb_thr_from_pid(pid_t pid)
{
struct proc *p;
p = LIST_FIRST(&allproc);
while (p != NULL) {
FOREACH_PROC_IN_SYSTEM(p) {
if (p->p_flag & P_INMEM && p->p_pid == pid)
return (FIRST_THREAD_IN_PROC(p));
p = LIST_NEXT(p, p_list);
}
return (NULL);
}