On 13/08/2018 18:38, Emilio G. Cota wrote: > This paves the way for implementing the CPU list with an RCU QLIST. > > Signed-off-by: Emilio G. Cota <c...@braap.org> > --- > cpus-common.c | 3 ++- > include/qom/cpu.h | 2 ++ > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/cpus-common.c b/cpus-common.c > index 59f751ecf9..6eaedae60b 100644 > --- a/cpus-common.c > +++ b/cpus-common.c > @@ -85,6 +85,7 @@ void cpu_list_add(CPUState *cpu) > assert(!cpu_index_auto_assigned); > } > QTAILQ_INSERT_TAIL(&cpus, cpu, node); > + cpu->in_cpu_list = true; > qemu_mutex_unlock(&qemu_cpu_list_lock); > > finish_safe_work(cpu); > @@ -93,7 +94,7 @@ void cpu_list_add(CPUState *cpu) > void cpu_list_remove(CPUState *cpu) > { > qemu_mutex_lock(&qemu_cpu_list_lock); > - if (!QTAILQ_IN_USE(cpu, node)) { > + if (!cpu->in_cpu_list) { > /* there is nothing to undo since cpu_exec_init() hasn't been called > */ > qemu_mutex_unlock(&qemu_cpu_list_lock); > return; > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index bd796579ee..aa555e27a7 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -411,6 +411,8 @@ struct CPUState { > > bool ignore_memory_transaction_failures; > > + bool in_cpu_list; /* protected by qemu_cpu_list_lock */ > + > /* Note that this is accessed at the start of every TB via a negative > offset from AREG0. Leave this field at the end so as to make the > (absolute value) offset as small as possible. This reduces code >
Reviewwed-by: Paolo Bonzini <pbonz...@redhat.com>