qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] vcpu: join vcpu thread after it exiting


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2] vcpu: join vcpu thread after it exiting
Date: Thu, 1 Feb 2018 09:41:55 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 01/02/2018 06:04, linzhecheng wrote:
> As we create vcpu thread with QEMU_THREAD_JOINABLE mode,
> we should join it after it exiting to cleanup resources.
> 
> Signed-off-by: linzhecheng <address@hidden>
> 
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index f290f48..5cc1ba2 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -282,9 +282,9 @@ err:
>  
>  static int kvm_get_vcpu(KVMState *s, unsigned long vcpu_id)
>  {
> -    struct KVMParkedVcpu *cpu;
> +    struct KVMParkedVcpu *cpu, *next_cpu;
>  
> -    QLIST_FOREACH(cpu, &s->kvm_parked_vcpus, node) {
> +    QLIST_FOREACH_SAFE(cpu, &s->kvm_parked_vcpus, node, next_cpu) {
>          if (cpu->vcpu_id == vcpu_id) {
>              int kvm_fd;

This is not needed because removing the node results in an immediate
return..

> diff --git a/cpus.c b/cpus.c
> index 2cb0af9..1890bfe 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1205,6 +1205,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
>      cpu->created = false;
>      qemu_cond_signal(&qemu_cpu_cond);
>      qemu_mutex_unlock_iothread();
> +    rcu_unregister_thread();
>      return NULL;
>  }
>  
> @@ -1759,6 +1760,7 @@ void cpu_remove_sync(CPUState *cpu)
>      cpu_remove(cpu);
>      while (cpu->created) {
>          qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
> +        qemu_thread_join(cpu->thread);
>      }
>  }
>  
> 

Thanks.  There are other issues in qemu_*_cpu_thread_fn, I'll send a
more complete series shortly.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]