Module Name:    src
Committed By:   joerg
Date:           Sun Nov 10 23:39:03 UTC 2019

Modified Files:
        src/sys/kern: kern_lwp.c

Log Message:
Ensure that the second LWP of a new process uses a free LWP ID.
Document overflow behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/kern/kern_lwp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.206 src/sys/kern/kern_lwp.c:1.207
--- src/sys/kern/kern_lwp.c:1.206	Thu Nov  7 19:45:18 2019
+++ src/sys/kern/kern_lwp.c	Sun Nov 10 23:39:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.206 2019/11/07 19:45:18 joerg Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.207 2019/11/10 23:39:03 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.206 2019/11/07 19:45:18 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.207 2019/11/10 23:39:03 joerg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -904,6 +904,11 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_
 		l2->l_pflag |= LP_PIDLID;
 	} else if (p2->p_nlwps == 0) {
 		lid = l1->l_lid;
+		/*
+		 * Update next LWP ID, too. If this overflows to LID_SCAN,
+		 * the slow path of scanning will be used for the next LWP.
+		 */
+		p2->p_nlwpid = lid + 1;
 	} else {
 		lid = 0;
 	}

Reply via email to