From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: [PATCH v2 02/15] Refactor cpu_has_work/any_cpu_has_work in cpus.c
Date: Wed, 09 Feb 2011 16:29:37 +0100 [thread overview]
Message-ID: <4D52B2E1.70806@siemens.com> (raw)
In-Reply-To: <1e7a4f5097aafb5da844c1b9ff8661539d0d10e8.1297077506.git.jan.kiszka@siemens.com>
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 <jan.kiszka@siemens.com>
---
Changes in v2:
- renaming: cpu_thread_is_idle and all_cpu_threads_idle
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.1
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH v2 02/15] Refactor cpu_has_work/any_cpu_has_work in cpus.c
Date: Wed, 09 Feb 2011 16:29:37 +0100 [thread overview]
Message-ID: <4D52B2E1.70806@siemens.com> (raw)
In-Reply-To: <1e7a4f5097aafb5da844c1b9ff8661539d0d10e8.1297077506.git.jan.kiszka@siemens.com>
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 <jan.kiszka@siemens.com>
---
Changes in v2:
- renaming: cpu_thread_is_idle and all_cpu_threads_idle
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.1
next prev parent reply other threads:[~2011-02-09 15:29 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 11:19 [PATCH 00/15] [uq/master] Patch queue, part III Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 01/15] Refactor kvm&tcg function names in cpus.c Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 02/15] Refactor cpu_has_work/any_cpu_has_work " Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-08 18:50 ` Marcelo Tosatti
2011-02-08 18:50 ` [Qemu-devel] " Marcelo Tosatti
2011-02-09 8:07 ` Jan Kiszka
2011-02-09 8:07 ` [Qemu-devel] " Jan Kiszka
2011-02-09 13:54 ` Marcelo Tosatti
2011-02-09 13:54 ` [Qemu-devel] " Marcelo Tosatti
2011-02-09 15:29 ` Jan Kiszka [this message]
2011-02-09 15:29 ` [Qemu-devel] [PATCH v2 " Jan Kiszka
2011-02-07 11:19 ` [PATCH 03/15] Fix a few coding style violations " Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 04/15] Improve vm_stop reason declarations Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-08 18:59 ` Marcelo Tosatti
2011-02-08 18:59 ` [Qemu-devel] " Marcelo Tosatti
2011-02-09 8:07 ` Jan Kiszka
2011-02-09 8:07 ` [Qemu-devel] " Jan Kiszka
2011-02-09 14:17 ` Marcelo Tosatti
2011-02-09 14:17 ` [Qemu-devel] " Marcelo Tosatti
2011-02-09 14:51 ` Jan Kiszka
2011-02-09 14:51 ` [Qemu-devel] " Jan Kiszka
2011-02-09 15:29 ` [PATCH v2 " Jan Kiszka
2011-02-09 15:29 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 05/15] Refactor debug and vmstop request interface Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 06/15] Move debug exception handling out of cpu_exec Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 07/15] kvm: Separate TCG from KVM cpu execution Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-08 23:39 ` Marcelo Tosatti
2011-02-08 23:39 ` [Qemu-devel] " Marcelo Tosatti
2011-02-09 7:59 ` Jan Kiszka
2011-02-09 7:59 ` [Qemu-devel] " Jan Kiszka
2011-02-09 14:44 ` Marcelo Tosatti
2011-02-09 14:44 ` [Qemu-devel] " Marcelo Tosatti
2011-02-09 14:53 ` Jan Kiszka
2011-02-09 14:53 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 08/15] kvm: x86: Prepare VCPU loop for in-kernel irqchip Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 09/15] kvm: Drop return values from kvm_arch_pre/post_run Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 12:54 ` Alexander Graf
2011-02-07 12:54 ` [Qemu-devel] " Alexander Graf
2011-02-17 21:01 ` [PATCH] kvm: ppc: Fix breakage of kvm_arch_pre_run/process_irqchip_events Jan Kiszka
2011-02-17 21:01 ` [Qemu-devel] " Jan Kiszka
2011-03-11 5:55 ` Alexander Graf
2011-03-11 5:55 ` [Qemu-devel] " Alexander Graf
2011-03-11 6:26 ` Stefan Hajnoczi
2011-03-11 6:26 ` [Qemu-devel] " Stefan Hajnoczi
2011-03-11 7:02 ` Alexander Graf
2011-03-11 7:02 ` [Qemu-devel] " Alexander Graf
2011-02-07 11:19 ` [PATCH 10/15] kvm: x86: Catch and report failing IRQ and NMI injections Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 11/15] kvm: Remove unneeded memory slot reservation Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 15:26 ` Alex Williamson
2011-02-07 15:26 ` [Qemu-devel] " Alex Williamson
2011-02-07 11:19 ` [PATCH 12/15] Introduce log_start/log_stop in CPUPhysMemoryClient Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 13/15] cirrus: Remove obsolete kvm.h include Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 14/15] kvm: Make kvm_state globally available Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 11:19 ` [PATCH 15/15] kvm: x86: Introduce kvmclock device to save/restore its state Jan Kiszka
2011-02-07 11:19 ` [Qemu-devel] " Jan Kiszka
2011-02-07 12:27 ` Glauber Costa
2011-02-07 12:27 ` [Qemu-devel] " Glauber Costa
2011-02-07 12:36 ` Jan Kiszka
2011-02-07 12:36 ` [Qemu-devel] " Jan Kiszka
2011-02-07 13:40 ` Glauber Costa
2011-02-07 13:40 ` [Qemu-devel] " Glauber Costa
2011-02-07 14:03 ` Jan Kiszka
2011-02-07 14:03 ` [Qemu-devel] " Jan Kiszka
2011-02-07 18:04 ` Glauber Costa
2011-02-07 18:04 ` [Qemu-devel] " Glauber Costa
2011-02-07 18:12 ` Jan Kiszka
2011-02-07 18:12 ` [Qemu-devel] " Jan Kiszka
2011-02-07 18:26 ` Glauber Costa
2011-02-07 18:26 ` [Qemu-devel] " Glauber Costa
2011-02-07 12:44 ` Avi Kivity
2011-02-07 12:44 ` [Qemu-devel] " Avi Kivity
2011-02-07 19:39 ` [Qemu-devel] " Blue Swirl
2011-02-07 19:39 ` Blue Swirl
2011-02-07 21:48 ` Jan Kiszka
2011-02-07 21:48 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D52B2E1.70806@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.