- linux-user: improve lock

OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=91
This commit is contained in:
Alexander Graf 2012-07-10 16:43:10 +00:00 committed by Git OBS Bridge
parent be7a951982
commit 7102445230
2 changed files with 29 additions and 17 deletions

View File

@ -1,4 +1,4 @@
From 84d6bd737ce0dd9471aa9d589d918406f2c3c6e8 Mon Sep 17 00:00:00 2001
From 9a66bfa1a21b7429229be3d52b1d6ea08b141d36 Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Thu, 5 Jul 2012 17:31:39 +0200
Subject: [PATCH] linux-user: lock tcg
@ -9,12 +9,12 @@ different threads.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
linux-user/mmap.c | 3 +++
tcg/tcg.c | 29 +++++++++++++++++++++++++++--
tcg/tcg.c | 36 ++++++++++++++++++++++++++++++++++--
tcg/tcg.h | 6 ++++++
3 files changed, 36 insertions(+), 2 deletions(-)
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 3f5e1d7..a669b3a 100644
index 3f5e1d7..83e9eda 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -30,6 +30,7 @@
@ -25,24 +25,24 @@ index 3f5e1d7..a669b3a 100644
//#define DEBUG_MMAP
@@ -42,6 +43,7 @@ void mmap_lock(void)
@@ -41,6 +42,7 @@ void mmap_lock(void)
{
if (mmap_lock_count++ == 0) {
pthread_mutex_lock(&mmap_mutex);
+ tcg_lock();
}
+ tcg_lock();
}
void mmap_unlock(void)
@@ -49,6 +51,7 @@ void mmap_unlock(void)
@@ -48,6 +50,7 @@ void mmap_unlock(void)
{
if (--mmap_lock_count == 0) {
pthread_mutex_unlock(&mmap_mutex);
+ tcg_unlock();
}
+ tcg_unlock();
}
/* Grab lock to make sure things are in a consistent state after fork(). */
diff --git a/tcg/tcg.c b/tcg/tcg.c
index ab589c7..c315e2a 100644
index ab589c7..4c93acb 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -40,6 +40,8 @@
@ -54,15 +54,20 @@ index ab589c7..c315e2a 100644
/* Note: the long term plan is to reduce the dependancies on the QEMU
CPU definitions. Currently they are used for qemu_ld/st
@@ -105,6 +107,22 @@ static TCGRegSet tcg_target_call_clobber_regs;
@@ -105,6 +107,29 @@ static TCGRegSet tcg_target_call_clobber_regs;
uint16_t *gen_opc_ptr;
TCGArg *gen_opparam_ptr;
+#ifdef CONFIG_USER_ONLY
+static __thread int tcg_lock_count;
+#endif
+void tcg_lock(void)
+{
+#ifdef CONFIG_USER_ONLY
+ TCGContext *s = &tcg_ctx;
+ qemu_mutex_lock(&s->lock);
+ if (tcg_lock_count++ == 0) {
+ qemu_mutex_lock(&s->lock);
+ }
+#endif
+}
+
@ -70,14 +75,16 @@ index ab589c7..c315e2a 100644
+{
+#ifdef CONFIG_USER_ONLY
+ TCGContext *s = &tcg_ctx;
+ qemu_mutex_unlock(&s->lock);
+ if (--tcg_lock_count == 0) {
+ qemu_mutex_unlock(&s->lock);
+ }
+#endif
+}
+
static inline void tcg_out8(TCGContext *s, uint8_t v)
{
*s->code_ptr++ = v;
@@ -245,7 +263,8 @@ void tcg_context_init(TCGContext *s)
@@ -245,7 +270,8 @@ void tcg_context_init(TCGContext *s)
memset(s, 0, sizeof(*s));
s->temps = s->static_temps;
s->nb_globals = 0;
@ -87,7 +94,7 @@ index ab589c7..c315e2a 100644
/* Count total number of arguments and allocate the corresponding
space */
total_args = 0;
@@ -2182,11 +2201,13 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf)
@@ -2182,11 +2208,13 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf)
}
#endif
@ -101,7 +108,7 @@ index ab589c7..c315e2a 100644
return s->code_ptr - gen_code_buf;
}
@@ -2197,7 +2218,11 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf)
@@ -2197,7 +2225,11 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf)
Return -1 if not found. */
int tcg_gen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset)
{

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Jul 10 16:42:54 UTC 2012 - agraf@suse.com
- linux-user: improve lock
-------------------------------------------------------------------
Thu Jul 5 15:37:05 UTC 2012 - agraf@suse.com