On 2 February 2015 at 10:03, Paolo Bonzini <pbonz...@redhat.com> wrote: >> You can't do this -- this code is a signal handler so it could >> get run at any time including while the list of CPUs is being >> updated. (This is why we have the exit_request flag in the >> first place rather than just setting the exit_request flag in >> each CPU...) > > Actually you can do this if you are careful. > > In particular, you can do it while you are under the big QEMU lock.
...but this is a signal handler, so we can't guarantee that the thread holds the big lock. > If > you are not, basically you have to treat the CPU list as RCU-protected, > and this is doable because the CPU object cannot be removed and added > back into the CPU list. > > Unfortunately RCU doesn't support QTAILQ, at least not yet, so you'd > have to convert the CPU list to QLIST. But the basic idea of this patch > can be done. ...and if we can iterate over CPU lists in signal handlers, the correct approach is probably to use the existing exit_request flag rather than adding another one. (Needs investigation to check and document semantics of that flag.) -- PMM