From owner-svn-src-head@freebsd.org Wed Jun 20 11:42:07 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7142101418B; Wed, 20 Jun 2018 11:42:07 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 79460772E6; Wed, 20 Jun 2018 11:42:07 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5BCF221C9F; Wed, 20 Jun 2018 11:42:07 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5KBg7qU077244; Wed, 20 Jun 2018 11:42:07 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5KBg6vN077241; Wed, 20 Jun 2018 11:42:06 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201806201142.w5KBg6vN077241@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 20 Jun 2018 11:42:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335441 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 335441 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2018 11:42:08 -0000 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); }