On Thu, Nov 19, 2020 at 04:57:22PM +0000, Valentin Schneider wrote: > > On 19/11/20 16:09, Peter Zijlstra wrote: > > On Thu, Nov 19, 2020 at 01:13:20PM +0000, Will Deacon wrote: > > > >> 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