[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 24/37] Refactor cpu_has_work/any_cpu_has_work in cpu
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [PATCH 24/37] Refactor cpu_has_work/any_cpu_has_work in cpus.c |
Date: |
Mon, 14 Feb 2011 13:22:53 -0200 |
From: Jan Kiszka <address@hidden>
Avoid duplicate use of the function name cpu_has_work, it's confusing,
also their scope. Refactor cpu_has_work to cpu_thread_is_idle and do the
same with any_cpu_has_work.
Signed-off-by: Jan Kiszka <address@hidden>
Signed-off-by: Marcelo Tosatti <address@hidden>
---
cpus.c | 43 +++++++++++++++++++++++--------------------
1 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/cpus.c b/cpus.c
index d54ec7d..e963208 100644
--- a/cpus.c
+++ b/cpus.c
@@ -137,29 +137,30 @@ static int cpu_can_run(CPUState *env)
return 1;
}
-static int cpu_has_work(CPUState *env)
+static bool cpu_thread_is_idle(CPUState *env)
{
- if (env->stop)
- return 1;
- if (env->queued_work_first)
- return 1;
- if (env->stopped || !vm_running)
- return 0;
- if (!env->halted)
- return 1;
- if (qemu_cpu_has_work(env))
- return 1;
- return 0;
+ if (env->stop || env->queued_work_first) {
+ return false;
+ }
+ if (env->stopped || !vm_running) {
+ return true;
+ }
+ if (!env->halted || qemu_cpu_has_work(env)) {
+ return false;
+ }
+ return true;
}
-static int any_cpu_has_work(void)
+static bool all_cpu_threads_idle(void)
{
CPUState *env;
- for (env = first_cpu; env != NULL; env = env->next_cpu)
- if (cpu_has_work(env))
- return 1;
- return 0;
+ for (env = first_cpu; env != NULL; env = env->next_cpu) {
+ if (!cpu_thread_is_idle(env)) {
+ return false;
+ }
+ }
+ return true;
}
static void cpu_debug_handler(CPUState *env)
@@ -743,8 +744,9 @@ static void qemu_tcg_wait_io_event(void)
{
CPUState *env;
- while (!any_cpu_has_work())
+ while (all_cpu_threads_idle()) {
qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000);
+ }
qemu_mutex_unlock(&qemu_global_mutex);
@@ -765,8 +767,9 @@ static void qemu_tcg_wait_io_event(void)
static void qemu_kvm_wait_io_event(CPUState *env)
{
- while (!cpu_has_work(env))
+ while (cpu_thread_is_idle(env)) {
qemu_cond_timedwait(env->halt_cond, &qemu_global_mutex, 1000);
+ }
qemu_kvm_eat_signals(env);
qemu_wait_io_event_common(env);
@@ -1070,7 +1073,7 @@ bool cpu_exec_all(void)
}
}
exit_request = 0;
- return any_cpu_has_work();
+ return !all_cpu_threads_idle();
}
void set_numa_modes(void)
--
1.7.4
- [Qemu-devel] [PATCH 00/37] [PULL] qemu-kvm.git uq/master queue, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 29/37] kvm: Separate TCG from KVM cpu execution, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 05/37] Leave inner main_loop faster on pending requests, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 24/37] Refactor cpu_has_work/any_cpu_has_work in cpus.c,
Marcelo Tosatti <=
- [Qemu-devel] [PATCH 25/37] Fix a few coding style violations in cpus.c, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 32/37] kvm: x86: Catch and report failing IRQ and NMI injections, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 01/37] Prevent abortion on multiple VCPU kicks, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 18/37] Introduce VCPU self-signaling service, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 27/37] Refactor debug and vmstop request interface, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 06/37] Flatten the main loop, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 21/37] kvm: Leave kvm_cpu_exec directly after KVM_EXIT_SHUTDOWN, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 33/37] kvm: Remove unneeded memory slot reservation, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 10/37] kvm: Provide sigbus services arch-independently, Marcelo Tosatti, 2011/02/14
- [Qemu-devel] [PATCH 26/37] Improve vm_stop reason declarations, Marcelo Tosatti, 2011/02/14