summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2012-07-10 18:40:55 (GMT)
committerYury Usishchev <y.usishchev@samsung.com>2014-12-10 10:48:35 (GMT)
commit0bcc4adb9792b7a446494b6494e13a0d109eb45a (patch)
tree142554c6bb1a8385aeadbbbb3668d916ee8d3453
parent106e6b4e83c646e622a59a110c0bafa8432c5500 (diff)
downloadqemu-0bcc4adb9792b7a446494b6494e13a0d109eb45a.zip
qemu-0bcc4adb9792b7a446494b6494e13a0d109eb45a.tar.gz
qemu-0bcc4adb9792b7a446494b6494e13a0d109eb45a.tar.bz2
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>
-rw-r--r--linux-user/syscall.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 84621cc..6fc55b4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4526,6 +4526,15 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
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);