lkml.org 
[lkml]   [2020]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v3 07/14] sched: Introduce restrict_cpus_allowed_ptr() to limit task CPU affinity
Date

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

\
 
 \ /
  Last update: 2020-11-19 18:01    [W:0.126 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site