On Wed, Jul 28, 2021 at 10:34:01AM +0200, Thomas Gleixner wrote: > On Wed, Jul 28 2021 at 01:32, Frederic Weisbecker wrote: > > On Tue, Jul 27, 2021 at 09:33:42PM +0200, Thomas Gleixner wrote: > >> On Tue, Jul 27 2021 at 10:23, Paul E. McKenney wrote: > >> > On Tue, Jul 27, 2021 at 06:38:15PM +0200, Sebastian Andrzej Siewior wrote: > >> >> One thing that has been overseen is that a task within a migrate-disable > >> >> region (as on PREEMPT_RT with disabled BH) is fully preemptible but may > >> >> not be migrated to another CPU which should be enough to guarantee that > >> >> rdp remains stable. > >> >> > >> >> Check also disabled migration of the task if the RCU data pointer is > >> >> from current CPU. Put the whole check within an SMP ifdef block since > >> >> without SMP there are not CPU migrations to worry about (also > >> >> task_struct::migration_disabled is missing). > >> >> > >> >> Cc: Frederic Weisbecker <frederic@xxxxxxxxxx> > >> >> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> > >> >> --- > >> >> I don't fully understand why the CPU-hotplug lock matters here but this > >> >> is beside the point ;) > >> > > >> > If I remember correctly, any attempt to change the offloaded state > >> > must hold off CPU-hotplug operations. So if the current thread is > >> > holding off CPU-hotplug operations, no other thread can be doing > >> > an offload or de-offload operation. > >> > >> It only prevents unplugging of a CPU, but not plugging a CPU. > > > > Hmm, but both _cpu_down() and _cpu_up() do cpus_write_lock(). > > What did I overlook? > > I meant, that preemption disable does not prevent plugging a CPU, but > the final unplug step is prevented because the stomp machine thread > cannot run. Similar for migrate_disable(). The final unplug step can > only happen when all non-pinned tasks have left the migrate disabled > section. Ah ok so that should be fine since we rely on cpu_hotplug_lock to protect against CPU hotplug here, preemption disabled is there for other purposes. Thanks.