svn commit: r342237 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Wed Dec 19 20:29:53 UTC 2018


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;
 	}
 


More information about the svn-src-all mailing list