From: Tiejun Chen <tiejun.chen@windriver.com>
To: qemu-devel@nongnu.org
Cc: mtosatti@redhat.com, afaerber@suse.de
Subject: [Qemu-devel] [v2][PATCH 1/1] cpus: use cpu_is_stopped efficiently
Date: Fri, 2 Aug 2013 09:43:09 +0800 [thread overview]
Message-ID: <1375407789-5885-1-git-send-email-tiejun.chen@windriver.com> (raw)
It makes more sense and simple later.
Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
v1 -> v2:
To optimize performance slightly, we can reorder the two conditions to
avoid the non-inline function call if cpu->stopped.
cpus.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/cpus.c b/cpus.c
index c232265..7e76506 100644
--- a/cpus.c
+++ b/cpus.c
@@ -62,6 +62,11 @@
static CPUArchState *next_cpu;
+bool cpu_is_stopped(CPUState *cpu)
+{
+ return cpu->stopped || !runstate_is_running();
+}
+
static bool cpu_thread_is_idle(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
@@ -69,7 +74,7 @@ static bool cpu_thread_is_idle(CPUArchState *env)
if (cpu->stop || cpu->queued_work_first) {
return false;
}
- if (cpu->stopped || !runstate_is_running()) {
+ if (cpu_is_stopped(cpu)) {
return true;
}
if (!cpu->halted || qemu_cpu_has_work(cpu) ||
@@ -432,11 +437,6 @@ void cpu_synchronize_all_post_init(void)
}
}
-bool cpu_is_stopped(CPUState *cpu)
-{
- return !runstate_is_running() || cpu->stopped;
-}
-
static void do_vm_stop(RunState state)
{
if (runstate_is_running()) {
@@ -455,7 +455,7 @@ static bool cpu_can_run(CPUState *cpu)
if (cpu->stop) {
return false;
}
- if (cpu->stopped || !runstate_is_running()) {
+ if (cpu_is_stopped(cpu)) {
return false;
}
return true;
--
1.7.9.5
next reply other threads:[~2013-08-02 1:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-02 1:43 Tiejun Chen [this message]
2013-08-02 13:33 ` [Qemu-devel] [v2][PATCH 1/1] cpus: use cpu_is_stopped efficiently Andreas Färber
2013-08-05 1:47 ` "“tiejun.chen”"
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=1375407789-5885-1-git-send-email-tiejun.chen@windriver.com \
--to=tiejun.chen@windriver.com \
--cc=afaerber@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).