Date: Wed, 20 Jun 2018 11:42:06 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335441 - head/sys/kern Message-ID: <201806201142.w5KBg6vN077241@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bz Date: Wed Jun 20 11:42:06 2018 New Revision: 335441 URL: https://svnweb.freebsd.org/changeset/base/335441 Log: 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 Modified: head/sys/kern/kern_jail.c head/sys/kern/kern_proc.c head/sys/kern/subr_kdb.c Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Wed Jun 20 11:13:10 2018 (r335440) +++ head/sys/kern/kern_jail.c Wed Jun 20 11:42:06 2018 (r335441) @@ -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) Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Wed Jun 20 11:13:10 2018 (r335440) +++ head/sys/kern/kern_proc.c Wed Jun 20 11:42:06 2018 (r335441) @@ -3176,7 +3176,7 @@ again: } } /* 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; Modified: head/sys/kern/subr_kdb.c ============================================================================== --- head/sys/kern/subr_kdb.c Wed Jun 20 11:13:10 2018 (r335440) +++ head/sys/kern/subr_kdb.c Wed Jun 20 11:42:06 2018 (r335441) @@ -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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806201142.w5KBg6vN077241>