|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] RCU: reimplement RCU barrier to avoid deadlock
On 27/01/2020 18:56, Igor Druzhinin wrote: stop_machine_run() is used in a few places within Xen. Why is this a problem for rcu_barrier() and not for the other callers?The existing RCU barrier implementation is prone to a deadlock scenario due to IRQs being re-enabled inside stopmachine context. If due to a race IRQs are re-enabled on some of CPUs and softirqs are allowed to be processed in stopmachine, i.e. what currently happens in rcu_barrier(), timer interrupt is able to invoke TSC synchronization rendezvous. At this moment sending TSC synchronization IPI will stall waiting for other CPUs to synchronize while they in turn are waiting in stopmachine busy loop with IRQs disabled. To avoid the scenario above - reimplement rcu_barrier() in a way where IRQs are not being disabled at any moment. The proposed implementation is just a simplified and specialized version of stopmachine. The semantic of the call is preserved.
stop_machine_run() requires the interrupts to be enabled when called. Is this requirement still the same here? If so, can we document it and add an ASSERT? - atomic_t cpu_count = ATOMIC_INIT(0); - return stop_machine_run(rcu_barrier_action, &cpu_count, NR_CPUS); + unsigned int i; + + if ( !get_cpu_maps() ) + return -EBUSY; I realize this is also present in the current implementation. However, nobody seems to check the return of the barrier. What would happen if you continue without synchronizing the RCU? + + atomic_set(&rcu_barrier_cpu_count, 0); + atomic_set(&rcu_barrier_cpu_done, 0); + + for_each_online_cpu ( i ) + if ( i != smp_processor_id() ) + tasklet_schedule_on_cpu(&per_cpu(rcu_barrier_tasklet, i), i); + + rcu_barrier_action(NULL); + + while ( atomic_read(&rcu_barrier_cpu_done) != num_online_cpus() ) + cpu_relax(); + + put_cpu_maps(); + return 0; }/* Is batch a before batch b ? */ -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |