summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
authorrin <rin@NetBSD.org>2020-05-14 08:26:29 +0000
committerrin <rin@NetBSD.org>2020-05-14 08:26:29 +0000
commitcbd76471b30cc902020cf7b407d23b76f86b39ae (patch)
treeb54efec04ae9ffee6540794e448e7e52f8e44755 /sys/compat/linux
parentdf929ba679ad16754c96da50f83305413ee93c01 (diff)
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.
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/common/linux_sched.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/compat/linux/common/linux_sched.c b/sys/compat/linux/common/linux_sched.c
index fcfffc1257c..29e3dc75894 100644
--- a/sys/compat/linux/common/linux_sched.c
+++ b/sys/compat/linux/common/linux_sched.c
@@ -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 *l, const struct linux_sys_sched_setaffin
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 *l, const struct linux_sys_sched_setaffin
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);