[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201119192550.GD4906@willie-the-truck>
Date: Thu, 19 Nov 2020 19:25:51 +0000
From: Will Deacon <will@...nel.org>
To: Valentin Schneider <valentin.schneider@....com>
Cc: Peter Zijlstra <peterz@...radead.org>,
linux-arm-kernel@...ts.infradead.org, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org,
Catalin Marinas <catalin.marinas@....com>,
Marc Zyngier <maz@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Morten Rasmussen <morten.rasmussen@....com>,
Qais Yousef <qais.yousef@....com>,
Suren Baghdasaryan <surenb@...gle.com>,
Quentin Perret <qperret@...gle.com>, Tejun Heo <tj@...nel.org>,
Li Zefan <lizefan@...wei.com>,
Johannes Weiner <hannes@...xchg.org>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
kernel-team@...roid.com
Subject: Re: [PATCH v3 07/14] sched: Introduce restrict_cpus_allowed_ptr() to
limit task CPU affinity
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
Powered by blists - more mailing lists