Re: get_online_cpus() from a preemptible() context (bug?)

From: Peter Zijlstra
Date: Mon Nov 06 2017 - 05:40:48 EST


On Mon, Nov 06, 2017 at 11:32:12AM +0100, Peter Zijlstra wrote:
> On Fri, Nov 03, 2017 at 02:45:45PM +0000, James Morse wrote:
> > Hi Thomas, Peter,
> >
> > I'm trying to work out what stops a thread being pre-empted and migrated between
> > calling get_online_cpus() and put_online_cpus().

Nothing; why would you think it would? All those functions guarantee is
that any CPU observed as being online says online (and its converse,
that a CPU observed as being offline, says offline, although less people
care about that one).

That is; it serializes against CPU hotplug, nothing else.