Received: from eggs.gnu.org ([2001:4830:134:3::10]:38638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYXbY-0005j7-OV for qemu-devel@nongnu.org; Wed, 24 Feb 2016 06:27:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYXbU-0005nX-Ju for qemu-devel@nongnu.org; Wed, 24 Feb 2016 06:27:40 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:50255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYXbU-0005nC-Ae for qemu-devel@nongnu.org; Wed, 24 Feb 2016 06:27:36 -0500 References: <56CC8B78.6090607@elis.ugent.be> From: Laurent Vivier Message-ID: <56CD9398.8000500@vivier.eu> Date: Wed, 24 Feb 2016 12:27:20 +0100 MIME-Version: 1.0 In-Reply-To: <56CC8B78.6090607@elis.ugent.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] Status of multithreading in user mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cecilia Gonzalez-Alvarez , qemu-devel@nongnu.org Cc: Michael Karcher Le 23/02/2016 17:40, Cecilia Gonzalez-Alvarez a écrit : > Hi all, Hi Cecilia, > I'm planning to use Qemu as a functional simulation frontend for a > multicore simulator. > > Although later plans include full-system simulation, I'd like to start, > for the sake of simplicity, with the individual simulation of > applications in user mode. > > I'm interested in targets x86_64 and AArch64, and my general question > is: how is the status of multithreading in user mode for those targets? > Concretely, can we trust that running multiple threads on qemu-x86_64 > and qemu-aarch64 will be reliable most of the time? > > Going through the mailing list I have the feeling that multithreading > and user mode is a recurring issue. > > I've done some experiments with the latest Qemu from the repository > (2.5.50) and although user mode for both architectures is mostly working > well, it fails with this particular example for qemu-x86_64: > http://users.elis.ugent.be/~cgonzlez/fft.c > > Compiled with GCC 4.8.4: > gcc -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-sse4a -mno-avx -mno-avx2 > -c -o fft.o fft.c > gcc fft.o -lm -static -pthread -o fft > and executed with 32 threads: > qemu-x86_64 fft -p32 > sometimes, randomly, stalls on a sys_futex. > > I don't know if this is a very concrete bug that I should report > somewhere else; my main concern is to know if threading support in user > mode is almost fully implemented and stable with just some random and > unimportant bugs. ARM has some atomic operations implemented by stopping all other CPU threads (see linux-user/main.c, do_strex_a64()). But I don't think locked operations have been implemented for x86_64. And Michael has found a bug in the futex implementation in linux-user mode. You can find a fix here: https://github.com/vivier/qemu-m68k/commit/236f512f1c020e2d774216a9beb1466c260a89e2 This is not the original fix from Michael, but the idea is here and he did all the work. Laurent