qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 07/73] cpu: make per-CPU locks an alias of th


From: Emilio G. Cota
Subject: Re: [Qemu-devel] [PATCH v5 07/73] cpu: make per-CPU locks an alias of the BQL in TCG rr mode
Date: Fri, 14 Dec 2018 20:51:00 -0500
User-agent: Mutt/1.9.4 (2018-02-28)

On Thu, Dec 13, 2018 at 00:03:47 -0500, Emilio G. Cota wrote:
(snip)
> diff --git a/qom/cpu.c b/qom/cpu.c
> index aa15ea4af5..2ea5b1da08 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -371,7 +371,6 @@ static void cpu_common_initfn(Object *obj)
>      cpu->nr_cores = 1;
>      cpu->nr_threads = 1;
>  
> -    qemu_mutex_init(&cpu->lock);
>      qemu_cond_init(&cpu->cond);
>      QSIMPLEQ_INIT(&cpu->work_list);
>      QTAILQ_INIT(&cpu->breakpoints);

*ouch* this breaks user-mode, since we end up with cpu->lock == NULL.
I'm surprised that make check-qtest didn't pick this up--guess it's
all system-mode tests.

I've fixed this commit on github's v5 branch with the appended.

Thanks,

                Emilio
---
diff --git a/cpus.c b/cpus.c
index d8261903ac..9c6cd9b90f 100644
--- a/cpus.c
+++ b/cpus.c
@@ -2326,10 +2326,9 @@ void qemu_init_vcpu(CPUState *cpu)
      * cpu->lock is a standalone per-CPU lock.
      */
     if (qemu_is_tcg_rr()) {
+        qemu_mutex_destroy(cpu->lock);
+        g_free(cpu->lock);
         cpu->lock = &qemu_global_mutex;
-    } else {
-        cpu->lock = g_malloc(sizeof(*cpu->lock));
-        qemu_mutex_init(cpu->lock);
     }
 
     if (kvm_enabled()) {
diff --git a/qom/cpu.c b/qom/cpu.c
index 386b1e29dd..c4cb626393 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -367,6 +367,8 @@ static void cpu_common_initfn(Object *obj)
     cpu->nr_cores = 1;
     cpu->nr_threads = 1;
 
+    cpu->lock = g_new(QemuMutex, 1);
+    qemu_mutex_init(cpu->lock);
     qemu_cond_init(&cpu->cond);
     QSIMPLEQ_INIT(&cpu->work_list);
     QTAILQ_INIT(&cpu->breakpoints);



reply via email to

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