summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2019-11-21 18:22:05 +0000
committerad <ad@NetBSD.org>2019-11-21 18:22:05 +0000
commit124e7015b7883a19f43d5faf3ff2c9f5a01e61ba (patch)
tree896a80e22d6a82d052ddcf210012d2c605bd43a8
parente557441e3cf801a53021930361226ed3732282c1 (diff)
lwp_create:
- Don't need to check for PK_SYSTEM when inheriting an affinity mask. - Inherit processor set ID under proc_lock, to sync with pset syscalls.
-rw-r--r--sys/kern/kern_lwp.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/sys/kern/kern_lwp.c b/sys/kern/kern_lwp.c
index a7aedbd0c96..fe5f4eb0b0d 100644
--- a/sys/kern/kern_lwp.c
+++ b/sys/kern/kern_lwp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lwp.c,v 1.209 2019/11/21 18:17:36 ad Exp $ */
+/* $NetBSD: kern_lwp.c,v 1.210 2019/11/21 18:22:05 ad Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.209 2019/11/21 18:17:36 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.210 2019/11/21 18:22:05 ad Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@@ -952,26 +952,18 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_t uaddr, int flags,
KASSERT(l2->l_affinity == NULL);
- if ((p2->p_flag & PK_SYSTEM) == 0) {
- /* Inherit the affinity mask. */
+ /* Inherit the affinity mask. */
+ if (l1->l_affinity) {
+ /*
+ * Note that we hold the state lock while inheriting
+ * the affinity to avoid race with sched_setaffinity().
+ */
+ lwp_lock(l1);
if (l1->l_affinity) {
- /*
- * Note that we hold the state lock while inheriting
- * the affinity to avoid race with sched_setaffinity().
- */
- lwp_lock(l1);
- if (l1->l_affinity) {
- kcpuset_use(l1->l_affinity);
- l2->l_affinity = l1->l_affinity;
- }
- lwp_unlock(l1);
+ kcpuset_use(l1->l_affinity);
+ l2->l_affinity = l1->l_affinity;
}
- lwp_lock(l2);
- /* Inherit a processor-set */
- l2->l_psid = l1->l_psid;
- /* Look for a CPU to start */
- l2->l_cpu = sched_takecpu(l2);
- lwp_unlock_to(l2, l2->l_cpu->ci_schedstate.spc_mutex);
+ lwp_unlock(l1);
}
mutex_exit(p2->p_lock);
@@ -979,6 +971,8 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_t uaddr, int flags,
mutex_enter(proc_lock);
LIST_INSERT_HEAD(&alllwp, l2, l_list);
+ /* Inherit a processor-set */
+ l2->l_psid = l1->l_psid;
mutex_exit(proc_lock);
SYSCALL_TIME_LWP_INIT(l2);