All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel]  Multi-threaded user program support?
@ 2011-08-18  2:35 陳韋任
  2011-08-18  3:00 ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: 陳韋任 @ 2011-08-18  2:35 UTC (permalink / raw)
  To: qemu-devel

Hi, all

  I am wondering if there is any plan to support multi-threaded
program in QEMU. I find a patch [1] which adds i386-linux-user NPTL
support, but I don't see it's merged back into the trunk. I don't
know why. Is there any consideration or difficulty on multi-threaded
support?

  Thanks!

Regards,
chenwj

[1] http://patchwork.ozlabs.org/patch/31746/

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] Multi-threaded user program support?
  2011-08-18  2:35 [Qemu-devel] Multi-threaded user program support? 陳韋任
@ 2011-08-18  3:00 ` Peter Maydell
  2011-08-19  2:59   ` 陳韋任
  2011-08-20  2:35   ` 陳韋任
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2011-08-18  3:00 UTC (permalink / raw)
  To: 陳韋任; +Cc: qemu-devel

On 18 August 2011 03:35, 陳韋任 <chenwj@iis.sinica.edu.tw> wrote:
>  I am wondering if there is any plan to support multi-threaded
> program in QEMU. I find a patch [1] which adds i386-linux-user NPTL
> support, but I don't see it's merged back into the trunk. I don't
> know why. Is there any consideration or difficulty on multi-threaded
> support?

So there are a number of issues here. Firstly, x86 targets
in particular are worse than others for multi-threaded user
mode: the patch you note is almost certainly not the only
area that needs addressing. (Properly handling the x86 LOCK
prefix by making sure we take a host mutex is very likely
broken, for instance.) If you look in MAINTAINERS you'll see
that the status of the x86 target is listed as "Odd Fixes",
which is why it's behind some of the others. So it's really
waiting for somebody to step forward and start reviewing
patches, fixing bugs and generally give it a bit of love
and attention :-)

More generally and not x86-specific, there are problems with
the multithreaded user-mode support which I suspect exist because
nobody has ever sat down and worked out a coherent design for it,
including what might need to be thread-local and what locking
is required. So the result is that it mostly works but if you
stress it (by spawning lots of interacting threads, for instance)
qemu can crash. Fixing this is harder and may involve tough decisions
like choosing to sacrifice a few % of performance in order to get
a design that doesn't have locking issues...

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] Multi-threaded user program support?
  2011-08-18  3:00 ` Peter Maydell
@ 2011-08-19  2:59   ` 陳韋任
  2011-08-19  3:13     ` Peter Maydell
  2011-08-20  2:35   ` 陳韋任
  1 sibling, 1 reply; 6+ messages in thread
From: 陳韋任 @ 2011-08-19  2:59 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, 陳韋任

> More generally and not x86-specific, there are problems with
> the multithreaded user-mode support which I suspect exist because
> nobody has ever sat down and worked out a coherent design for it,
> including what might need to be thread-local and what locking
> is required. So the result is that it mostly works but if you

  You mean some QEMU data structures need to be thread-local or lock
protected in order to emulate guest multi-threaded program correctly? 

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] Multi-threaded user program support?
  2011-08-19  2:59   ` 陳韋任
@ 2011-08-19  3:13     ` Peter Maydell
  2011-08-19 16:19       ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2011-08-19  3:13 UTC (permalink / raw)
  To: 陳韋任; +Cc: qemu-devel

On 19 August 2011 03:59, 陳韋任 <chenwj@iis.sinica.edu.tw> wrote:
>> More generally and not x86-specific, there are problems with
>> the multithreaded user-mode support which I suspect exist because
>> nobody has ever sat down and worked out a coherent design for it,
>> including what might need to be thread-local and what locking
>> is required. So the result is that it mostly works but if you
>
>  You mean some QEMU data structures need to be thread-local or lock
> protected in order to emulate guest multi-threaded program correctly?

Approximately, yes (the third option being "redesign the data
structure so it can be sensibly protected"). See
https://bugs.launchpad.net/qemu/+bug/668799 for discussion of
one example.

None of this is impossibly difficult; it just requires that somebody
sits down and actually works through the problems and fixes them.

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] Multi-threaded user program support?
  2011-08-19  3:13     ` Peter Maydell
@ 2011-08-19 16:19       ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2011-08-19 16:19 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, 陳韋任

On 08/18/2011 08:13 PM, Peter Maydell wrote:
> On 19 August 2011 03:59, 陳韋任 <chenwj@iis.sinica.edu.tw> wrote:
>>> More generally and not x86-specific, there are problems with
>>> the multithreaded user-mode support which I suspect exist because
>>> nobody has ever sat down and worked out a coherent design for it,
>>> including what might need to be thread-local and what locking
>>> is required. So the result is that it mostly works but if you
>>
>>  You mean some QEMU data structures need to be thread-local or lock
>> protected in order to emulate guest multi-threaded program correctly?
> 
> Approximately, yes (the third option being "redesign the data
> structure so it can be sensibly protected"). See
> https://bugs.launchpad.net/qemu/+bug/668799 for discussion of
> one example.

I suspect that to make things tractable for i386, which has so
many LOCKable instructions, that we'll also have to implement
at least a compare-and-swap primitive in TCG.


r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] Multi-threaded user program support?
  2011-08-18  3:00 ` Peter Maydell
  2011-08-19  2:59   ` 陳韋任
@ 2011-08-20  2:35   ` 陳韋任
  1 sibling, 0 replies; 6+ messages in thread
From: 陳韋任 @ 2011-08-20  2:35 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, 陳韋任

> So there are a number of issues here. Firstly, x86 targets
> in particular are worse than others for multi-threaded user
> mode: the patch you note is almost certainly not the only
> area that needs addressing. (Properly handling the x86 LOCK
> prefix by making sure we take a host mutex is very likely
> broken, for instance.) If you look in MAINTAINERS you'll see

  Just to be curious. *If* QEMU support multithreaded user
program, would the different memory (coherence/consistency)
model between guest and host architecture become a problem?  

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-08-20  2:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18  2:35 [Qemu-devel] Multi-threaded user program support? 陳韋任
2011-08-18  3:00 ` Peter Maydell
2011-08-19  2:59   ` 陳韋任
2011-08-19  3:13     ` Peter Maydell
2011-08-19 16:19       ` Richard Henderson
2011-08-20  2:35   ` 陳韋任

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.