- linux-user: improve lock
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=91
This commit is contained in:
parent
be7a951982
commit
7102445230
@ -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>
|
From: Alexander Graf <agraf@suse.de>
|
||||||
Date: Thu, 5 Jul 2012 17:31:39 +0200
|
Date: Thu, 5 Jul 2012 17:31:39 +0200
|
||||||
Subject: [PATCH] linux-user: lock tcg
|
Subject: [PATCH] linux-user: lock tcg
|
||||||
@ -9,12 +9,12 @@ different threads.
|
|||||||
Signed-off-by: Alexander Graf <agraf@suse.de>
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
||||||
---
|
---
|
||||||
linux-user/mmap.c | 3 +++
|
linux-user/mmap.c | 3 +++
|
||||||
tcg/tcg.c | 29 +++++++++++++++++++++++++++--
|
tcg/tcg.c | 36 ++++++++++++++++++++++++++++++++++--
|
||||||
tcg/tcg.h | 6 ++++++
|
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
|
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
|
--- a/linux-user/mmap.c
|
||||||
+++ b/linux-user/mmap.c
|
+++ b/linux-user/mmap.c
|
||||||
@@ -30,6 +30,7 @@
|
@@ -30,6 +30,7 @@
|
||||||
@ -25,24 +25,24 @@ index 3f5e1d7..a669b3a 100644
|
|||||||
|
|
||||||
//#define DEBUG_MMAP
|
//#define DEBUG_MMAP
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ void mmap_lock(void)
|
@@ -41,6 +42,7 @@ void mmap_lock(void)
|
||||||
|
{
|
||||||
if (mmap_lock_count++ == 0) {
|
if (mmap_lock_count++ == 0) {
|
||||||
pthread_mutex_lock(&mmap_mutex);
|
pthread_mutex_lock(&mmap_mutex);
|
||||||
|
+ tcg_lock();
|
||||||
}
|
}
|
||||||
+ tcg_lock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmap_unlock(void)
|
@@ -48,6 +50,7 @@ void mmap_unlock(void)
|
||||||
@@ -49,6 +51,7 @@ void mmap_unlock(void)
|
{
|
||||||
if (--mmap_lock_count == 0) {
|
if (--mmap_lock_count == 0) {
|
||||||
pthread_mutex_unlock(&mmap_mutex);
|
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
|
diff --git a/tcg/tcg.c b/tcg/tcg.c
|
||||||
index ab589c7..c315e2a 100644
|
index ab589c7..4c93acb 100644
|
||||||
--- a/tcg/tcg.c
|
--- a/tcg/tcg.c
|
||||||
+++ b/tcg/tcg.c
|
+++ b/tcg/tcg.c
|
||||||
@@ -40,6 +40,8 @@
|
@@ -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
|
/* Note: the long term plan is to reduce the dependancies on the QEMU
|
||||||
CPU definitions. Currently they are used for qemu_ld/st
|
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;
|
uint16_t *gen_opc_ptr;
|
||||||
TCGArg *gen_opparam_ptr;
|
TCGArg *gen_opparam_ptr;
|
||||||
|
|
||||||
|
+#ifdef CONFIG_USER_ONLY
|
||||||
|
+static __thread int tcg_lock_count;
|
||||||
|
+#endif
|
||||||
+void tcg_lock(void)
|
+void tcg_lock(void)
|
||||||
+{
|
+{
|
||||||
+#ifdef CONFIG_USER_ONLY
|
+#ifdef CONFIG_USER_ONLY
|
||||||
+ TCGContext *s = &tcg_ctx;
|
+ TCGContext *s = &tcg_ctx;
|
||||||
+ qemu_mutex_lock(&s->lock);
|
+ if (tcg_lock_count++ == 0) {
|
||||||
|
+ qemu_mutex_lock(&s->lock);
|
||||||
|
+ }
|
||||||
+#endif
|
+#endif
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -70,14 +75,16 @@ index ab589c7..c315e2a 100644
|
|||||||
+{
|
+{
|
||||||
+#ifdef CONFIG_USER_ONLY
|
+#ifdef CONFIG_USER_ONLY
|
||||||
+ TCGContext *s = &tcg_ctx;
|
+ TCGContext *s = &tcg_ctx;
|
||||||
+ qemu_mutex_unlock(&s->lock);
|
+ if (--tcg_lock_count == 0) {
|
||||||
|
+ qemu_mutex_unlock(&s->lock);
|
||||||
|
+ }
|
||||||
+#endif
|
+#endif
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
static inline void tcg_out8(TCGContext *s, uint8_t v)
|
static inline void tcg_out8(TCGContext *s, uint8_t v)
|
||||||
{
|
{
|
||||||
*s->code_ptr++ = 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));
|
memset(s, 0, sizeof(*s));
|
||||||
s->temps = s->static_temps;
|
s->temps = s->static_temps;
|
||||||
s->nb_globals = 0;
|
s->nb_globals = 0;
|
||||||
@ -87,7 +94,7 @@ index ab589c7..c315e2a 100644
|
|||||||
/* Count total number of arguments and allocate the corresponding
|
/* Count total number of arguments and allocate the corresponding
|
||||||
space */
|
space */
|
||||||
total_args = 0;
|
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
|
#endif
|
||||||
|
|
||||||
@ -101,7 +108,7 @@ index ab589c7..c315e2a 100644
|
|||||||
|
|
||||||
return s->code_ptr - gen_code_buf;
|
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. */
|
Return -1 if not found. */
|
||||||
int tcg_gen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset)
|
int tcg_gen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset)
|
||||||
{
|
{
|
||||||
|
@ -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
|
Thu Jul 5 15:37:05 UTC 2012 - agraf@suse.com
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user