Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
kern_cpuset: allow using the explicit form of own pid/tid
Browse files Browse the repository at this point in the history
  • Loading branch information
valpackett committed Jul 2, 2020
1 parent e9979ca commit 5ef7056
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sys/kern/kern_cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,9 @@ kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which,
return (ECAPMODE);
if (which != CPU_WHICH_TID && which != CPU_WHICH_PID)
return (ECAPMODE);
if (id != -1)
if (id != -1 &&
!(which == CPU_WHICH_TID && id == curthread->td_tid) &&
!(which == CPU_WHICH_PID && id == curproc->p_pid))
return (ECAPMODE);
}
size = cpusetsize;
Expand Down Expand Up @@ -1862,7 +1864,9 @@ kern_cpuset_setaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which,
return (ECAPMODE);
if (which != CPU_WHICH_TID && which != CPU_WHICH_PID)
return (ECAPMODE);
if (id != -1)
if (id != -1 &&
!(which == CPU_WHICH_TID && id == curthread->td_tid) &&
!(which == CPU_WHICH_PID && id == curproc->p_pid))
return (ECAPMODE);
}
mask = malloc(cpusetsize, M_TEMP, M_WAITOK | M_ZERO);
Expand Down Expand Up @@ -1993,7 +1997,9 @@ kern_cpuset_getdomain(struct thread *td, cpulevel_t level, cpuwhich_t which,
return (ECAPMODE);
if (which != CPU_WHICH_TID && which != CPU_WHICH_PID)
return (ECAPMODE);
if (id != -1)
if (id != -1 &&
!(which == CPU_WHICH_TID && id == curthread->td_tid) &&
!(which == CPU_WHICH_PID && id == curproc->p_pid))
return (ECAPMODE);
}
mask = malloc(domainsetsize, M_TEMP, M_WAITOK | M_ZERO);
Expand Down Expand Up @@ -2128,7 +2134,9 @@ kern_cpuset_setdomain(struct thread *td, cpulevel_t level, cpuwhich_t which,
return (ECAPMODE);
if (which != CPU_WHICH_TID && which != CPU_WHICH_PID)
return (ECAPMODE);
if (id != -1)
if (id != -1 &&
!(which == CPU_WHICH_TID && id == curthread->td_tid) &&
!(which == CPU_WHICH_PID && id == curproc->p_pid))
return (ECAPMODE);
}
memset(&domain, 0, sizeof(domain));
Expand Down

0 comments on commit 5ef7056

Please sign in to comment.