Date: Wed, 19 Dec 2018 20:29:52 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342237 - head/sys/kern Message-ID: <201812192029.wBJKTqNE074563@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Wed Dec 19 20:29:52 2018 New Revision: 342237 URL: https://svnweb.freebsd.org/changeset/base/342237 Log: Microoptimize corner case of ID bitmap handling. Prior to the change we would avoidably test more possibly used IDs. While here update the comment: there is no pidchecked variable anymore. Modified: head/sys/kern/kern_fork.c Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Wed Dec 19 20:27:26 2018 (r342236) +++ head/sys/kern/kern_fork.c Wed Dec 19 20:29:52 2018 (r342237) @@ -238,19 +238,18 @@ extern bitstr_t proc_id_grpidmap; extern bitstr_t proc_id_sessidmap; extern bitstr_t proc_id_reapmap; +/* + * Find an unused process ID + * + * If RFHIGHPID is set (used during system boot), do not allocate + * low-numbered pids. + */ static int fork_findpid(int flags) { pid_t result; int trypid; - /* - * Find an unused process ID. We remember a range of unused IDs - * ready to use (from lastpid+1 through pidchecked-1). - * - * If RFHIGHPID is set (used during system boot), do not allocate - * low-numbered pids. - */ trypid = lastpid + 1; if (flags & RFHIGHPID) { if (trypid < 10) @@ -280,7 +279,7 @@ retry: if (bit_test(&proc_id_grpidmap, result) || bit_test(&proc_id_sessidmap, result) || bit_test(&proc_id_reapmap, result)) { - trypid++; + trypid = result + 1; goto retry; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812192029.wBJKTqNE074563>