On 29/01/2015 16:52, Peter Maydell wrote:
>> > +    CPU_FOREACH(cpu) {
>> > +        cpu->exit_loop_request = 1;
>> > +    }
>> >  }
> 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.  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.

Paolo

Reply via email to