Patchwork [qom-next,35/59] cpu: Move queued_work_{first, last} to CPUState

login
register
mail settings
Submitter Andreas Färber
Date May 23, 2012, 3:07 a.m.
Message ID <1337742502-28565-36-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/160860/
State New
Headers show

Comments

Andreas Färber - May 23, 2012, 3:07 a.m.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 cpu-defs.h         |    1 -
 cpus.c             |   19 ++++++++++---------
 include/qemu/cpu.h |    1 +
 3 files changed, 11 insertions(+), 10 deletions(-)

Patch

diff --git a/cpu-defs.h b/cpu-defs.h
index 7c68c39..54807f5 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -205,7 +205,6 @@  typedef struct CPUWatchpoint {
     /* user data */                                                     \
     void *opaque;                                                       \
                                                                         \
-    struct qemu_work_item *queued_work_first, *queued_work_last;        \
     const char *cpu_model_str;                                          \
     struct KVMState *kvm_state;                                         \
     struct kvm_run *kvm_run;                                            \
diff --git a/cpus.c b/cpus.c
index 3873da1..e493218 100644
--- a/cpus.c
+++ b/cpus.c
@@ -437,7 +437,7 @@  static bool cpu_thread_is_idle(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
 
-    if (cpu->stop || env->queued_work_first) {
+    if (cpu->stop || cpu->queued_work_first != NULL) {
         return false;
     }
     if (cpu->stopped || !runstate_is_running()) {
@@ -654,12 +654,12 @@  void run_on_cpu(CPUArchState *env, void (*func)(void *data), void *data)
 
     wi.func = func;
     wi.data = data;
-    if (!env->queued_work_first) {
-        env->queued_work_first = &wi;
+    if (cpu->queued_work_first == NULL) {
+        cpu->queued_work_first = &wi;
     } else {
-        env->queued_work_last->next = &wi;
+        cpu->queued_work_last->next = &wi;
     }
-    env->queued_work_last = &wi;
+    cpu->queued_work_last = &wi;
     wi.next = NULL;
     wi.done = false;
 
@@ -674,18 +674,19 @@  void run_on_cpu(CPUArchState *env, void (*func)(void *data), void *data)
 
 static void flush_queued_work(CPUArchState *env)
 {
+    CPUState *cpu = ENV_GET_CPU(env);
     struct qemu_work_item *wi;
 
-    if (!env->queued_work_first) {
+    if (cpu->queued_work_first == NULL) {
         return;
     }
 
-    while ((wi = env->queued_work_first)) {
-        env->queued_work_first = wi->next;
+    while ((wi = cpu->queued_work_first)) {
+        cpu->queued_work_first = wi->next;
         wi->func(wi->data);
         wi->done = true;
     }
-    env->queued_work_last = NULL;
+    cpu->queued_work_last = NULL;
     qemu_cond_broadcast(&qemu_work_cond);
 }
 
diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
index bfeb224..eea6175 100644
--- a/include/qemu/cpu.h
+++ b/include/qemu/cpu.h
@@ -70,6 +70,7 @@  struct CPUState {
     HANDLE hThread;
 #endif
     struct QemuCond *halt_cond;
+    struct qemu_work_item *queued_work_first, *queued_work_last;
     bool thread_kicked;
     bool created;
     bool stop;