[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] qom: use cpu->in_cpu_list instead of QTAILQ
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] qom: use cpu->in_cpu_list instead of QTAILQ_IN_USE |
Date: |
Tue, 14 Aug 2018 08:26:49 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
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 <address@hidden>
> ---
> 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 <address@hidden>