* Re: [Qemu-devel] [PATCH 1/2] do proper cpu_self check
2009-09-08 20:13 Glauber Costa
@ 2009-09-08 20:08 ` Glauber Costa
0 siblings, 0 replies; 3+ messages in thread
From: Glauber Costa @ 2009-09-08 20:08 UTC (permalink / raw)
To: Glauber Costa; +Cc: aliguori, qemu-devel
On Tue, Sep 8, 2009 at 5:13 PM, Glauber Costa<glommer@redhat.com> wrote:
> From: Glauber Costa <glommer@mothafucka.localdomain>
I've obviously sent this from the wrong address.
Just ignore it.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 1/2] do proper cpu_self check
@ 2009-09-08 20:13 Glauber Costa
2009-09-08 20:08 ` Glauber Costa
0 siblings, 1 reply; 3+ messages in thread
From: Glauber Costa @ 2009-09-08 20:13 UTC (permalink / raw)
To: qemu-devel; +Cc: Glauber Costa, aliguori
From: Glauber Costa <glommer@mothafucka.localdomain>
Currently, our check for qemu_cpu_self only checks if there is a cpu
currently in execution (represented by cpu_single_env being set). While
this might be okay for tcg, it is certainly not okay for kvm, since multiple
cpus might be executing.
Instead, I propose we use pthread primitives to test if the caller thread is
the same as env->thread.
For tcg, it will have the same semantics as before, since all CPUStates will
point to the same thread, and we'll only have one in execution at a time.
Signed-off-by: Glauber Costa <glommer@mothafucka.localdomain>
---
vl.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index a894285..604e996 100644
--- a/vl.c
+++ b/vl.c
@@ -3803,9 +3803,14 @@ void qemu_cpu_kick(void *_env)
qemu_thread_signal(env->thread, SIGUSR1);
}
-int qemu_cpu_self(void *env)
+int qemu_cpu_self(void *_env)
{
- return (cpu_single_env != NULL);
+ CPUState *env = _env;
+ QemuThread this;
+
+ qemu_thread_self(&this);
+
+ return qemu_thread_equal(&this, env->thread);
}
static void cpu_signal(int sig)
--
1.6.2.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 1/2] do proper cpu_self check
@ 2009-09-08 20:14 Glauber Costa
0 siblings, 0 replies; 3+ messages in thread
From: Glauber Costa @ 2009-09-08 20:14 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Currently, our check for qemu_cpu_self only checks if there is a cpu
currently in execution (represented by cpu_single_env being set). While
this might be okay for tcg, it is certainly not okay for kvm, since multiple
cpus might be executing.
Instead, I propose we use pthread primitives to test if the caller thread is
the same as env->thread.
For tcg, it will have the same semantics as before, since all CPUStates will
point to the same thread, and we'll only have one in execution at a time.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
vl.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index a894285..604e996 100644
--- a/vl.c
+++ b/vl.c
@@ -3803,9 +3803,14 @@ void qemu_cpu_kick(void *_env)
qemu_thread_signal(env->thread, SIGUSR1);
}
-int qemu_cpu_self(void *env)
+int qemu_cpu_self(void *_env)
{
- return (cpu_single_env != NULL);
+ CPUState *env = _env;
+ QemuThread this;
+
+ qemu_thread_self(&this);
+
+ return qemu_thread_equal(&this, env->thread);
}
static void cpu_signal(int sig)
--
1.6.2.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-08 20:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-08 20:14 [Qemu-devel] [PATCH 1/2] do proper cpu_self check Glauber Costa
-- strict thread matches above, loose matches on Subject: below --
2009-09-08 20:13 Glauber Costa
2009-09-08 20:08 ` Glauber Costa
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).