Re: [Lse-tech] Re: [PATCH] cpusets+hotplug+preepmt broken

From: Nathan Lynch
Date: Fri May 13 2005 - 16:09:28 EST


> > In particular, in my view, locks should guard data. What data does
> > lock_cpu_hotplug() guard? I propose that it guards cpu_online_map.
> >
> > I recommend considering a different name for this lock. Perhaps
> > 'cpu_online_sem', instead of 'cpucontrol'? And perhaps the
> > lock_cpu_hotplug() should be renamed, to say 'lock_cpu_online'?
>
> No. CPU hotplug uses two different locking - see both lock_cpu_hotplug()
> and __stop_machine_run(). Anyone reading cpu_online_map with
> preemption disabled is safe from cpu hotplug even without taking
> any lock.

More precisely (I think), reading cpu_online_map with preemption
disabled guarantees that none of the cpus in the map will go offline
-- it does not prevent an online operation in progress (but most code
only cares about the former case). Also note that __stop_machine_run
is used only to offline a cpu.

The cpucontrol semaphore does not only protect cpu_online_map and
cpu_present_map, but also serializes cpu hotplug operations, so that
only one may be in progress at a time.

I've been mulling over submitting a Documentation/cpuhotplug.txt,
sounds like there's sufficient demand...

Nathan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/