Skip to contentSkip to conversation

Status of multithreading in user mode

Qemu-devel Cecilia Gonzalez-Alvarez 2 participants 2 messages Feb 23, 2016 – Feb 24, 2016

lore
Share & tools
lore
#0 lore raw

Hi all,

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.

Best,

Cecilia

#1 lore raw
Quoted 1 line · Cecilia Gonzalez-Alvarez

Hi all,

Hi Cecilia,

Quoted 26 lines

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
Quoted 6 lines

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