2015-03-21 12:46:36 +01:00
|
|
|
From b1a2eb97a7f8dffa47c9b5e1edfe62f79d56b26d Mon Sep 17 00:00:00 2001
|
2012-07-10 20:44:07 +02:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
|
|
|
Date: Tue, 10 Jul 2012 20:40:55 +0200
|
|
|
|
Subject: [PATCH] linux-user: Run multi-threaded code on a single core
|
|
|
|
|
|
|
|
Running multi-threaded code can easily expose some of the fundamental
|
|
|
|
breakages in QEMU's design. It's just not a well supported scenario.
|
|
|
|
|
|
|
|
So if we pin the whole process to a single host CPU, we guarantee that
|
|
|
|
we will never have concurrent memory access actually happen. We can still
|
|
|
|
get scheduled away at any time, so it's no complete guarantee, but apparently
|
|
|
|
it reduces the odds well enough to get my test cases to pass.
|
|
|
|
|
|
|
|
This gets Java 1.7 working for me again on my test box.
|
|
|
|
|
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
|
|
|
---
|
2014-01-17 23:04:30 +01:00
|
|
|
linux-user/syscall.c | 9 +++++++++
|
|
|
|
1 file changed, 9 insertions(+)
|
2012-07-10 20:44:07 +02:00
|
|
|
|
|
|
|
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
|
2015-03-21 12:46:36 +01:00
|
|
|
index 69e6f1c..918c241 100644
|
2012-07-10 20:44:07 +02:00
|
|
|
--- a/linux-user/syscall.c
|
|
|
|
+++ b/linux-user/syscall.c
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -4543,6 +4543,15 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
2012-07-10 20:44:07 +02:00
|
|
|
if (nptl_flags & CLONE_SETTLS)
|
|
|
|
cpu_set_tls (new_env, newtls);
|
|
|
|
|
|
|
|
+ /* agraf: Pin ourselves to a single CPU when running multi-threaded.
|
|
|
|
+ This turned out to improve stability for me. */
|
|
|
|
+ {
|
|
|
|
+ cpu_set_t mask;
|
|
|
|
+ CPU_ZERO(&mask);
|
|
|
|
+ CPU_SET(0, &mask);
|
|
|
|
+ sched_setaffinity(0, sizeof(mask), &mask);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
/* Grab a mutex so that thread setup appears atomic. */
|
|
|
|
pthread_mutex_lock(&clone_lock);
|
|
|
|
|