Re: [PATCH v3 07/14] sched: Introduce restrict_cpus_allowed_ptr() to limit task CPU affinity

From
Will Deacon <will@kernel.org>
Date
2020-11-19 19:26:20
Also in
linux-arch, lkml
Reply to
Valentin Schneider, 2020-11-19
On Thu, Nov 19, 2020 at 04:57:22PM +0000, Valentin Schneider wrote:
On 19/11/20 16:09, Peter Zijlstra wrote:
quoted
On Thu, Nov 19, 2020 at 01:13:20PM +0000, Will Deacon wrote:
quoted
Sure, but I was talking about what userspace sees, and I don't think it ever
sees CPUs that have been hotplugged off, right? That is, sched_getaffinity()
masks its result with the active_mask.
# for i in /sys/devices/system/cpu/cpu*/online; do echo -n $i ":"; cat $i; done
/sys/devices/system/cpu/cpu1/online :0
/sys/devices/system/cpu/cpu2/online :1
/sys/devices/system/cpu/cpu3/online :1
/sys/devices/system/cpu/cpu4/online :1
/sys/devices/system/cpu/cpu5/online :1
/sys/devices/system/cpu/cpu6/online :1
/sys/devices/system/cpu/cpu7/online :1

# grep Cpus_allowed /proc/self/status
Cpus_allowed:   ff
Cpus_allowed_list:      0-7


:-)
Harumph, so there is that...

$ while true; do continue; done &
$ PID=$!
$ taskset -pc 0-1 $PID
  pid 849's current affinity list: 0-5
  pid 849's new affinity list: 0,1
$ echo 0 > /sys/devices/system/cpu/cpu1/online
  [12578.545726] CPU1: shutdown
  [12578.548454] psci: CPU1 killed (polled 0 ms)
$ taskset -pc $PID
  pid 849's current affinity list: 0
$ cat /proc/$PID/status | grep Cpus
  Cpus_allowed:   03
  Cpus_allowed_list:      0-1
Yeah, I'm not sure this is worth tackling tbh. sched_getaffinity() does the
right thing, but poking around in /proc and /sys is always going to defeat
the illusion and I don't see what we gain in reporting CPUs on which the
task is _never_ going to run anyway. But I'll revise my stance on it being
identical to hotplug :) (I would've gotten away with it too, if it wasn't
for those pesky hackers).

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (52 messages) 52 messages, 4 authors, last reply 2020-11-23
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help