Module Name:    src
Committed By:   rin
Date:           Thu May 14 08:26:29 UTC 2020

Modified Files:
        src/sys/compat/linux/common: linux_sched.c

Log Message:
Fix previous; specify lwpid for curlpw in the case of pid == 0.

For linux_sys_sched_setaffinity, pid == 0 means the current thread.
On the other hand, for our native sys_sched_setaffinity, lid == 0
means all lwp's that belong to the process.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/compat/linux/common/linux_sched.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/compat/linux/common/linux_sched.c
diff -u src/sys/compat/linux/common/linux_sched.c:1.76 src/sys/compat/linux/common/linux_sched.c:1.77
--- src/sys/compat/linux/common/linux_sched.c:1.76	Wed Apr 29 01:55:18 2020
+++ src/sys/compat/linux/common/linux_sched.c	Thu May 14 08:26:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $	*/
+/*	$NetBSD: linux_sched.c,v 1.77 2020/05/14 08:26:29 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2019 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.77 2020/05/14 08:26:29 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -671,12 +671,14 @@ linux_sys_sched_setaffinity(struct lwp *
 	struct sys__sched_setaffinity_args ssa;
 	size_t size;
 	pid_t pid;
+	lwpid_t lid;
 
 	size = LINUX_CPU_MASK_SIZE;
 	if (SCARG(uap, len) < size)
 		return EINVAL;
 
-	if (SCARG(uap, pid) != 0) {
+	lid = SCARG(uap, pid);
+	if (lid != 0) {
 		/* Get the canonical PID for the process. */
 		mutex_enter(proc_lock);
 		struct proc *p = proc_find_lwpid(SCARG(uap, pid));
@@ -687,11 +689,12 @@ linux_sys_sched_setaffinity(struct lwp *
 		pid = p->p_pid;
 		mutex_exit(proc_lock);
 	} else {
-		pid = 0;
+		pid = curproc->p_pid;
+		lid = curlwp->l_lid;
 	}
 
 	SCARG(&ssa, pid) = pid;
-	SCARG(&ssa, lid) = SCARG(uap, pid);
+	SCARG(&ssa, lid) = lid;
 	SCARG(&ssa, size) = size;
 	SCARG(&ssa, cpuset) = (cpuset_t *)SCARG(uap, mask);
 

Reply via email to