* [Qemu-devel] spawning and killing threads in qemu
@ 2012-01-26 18:31 Xin Tong
2012-01-26 18:35 ` Paolo Bonzini
0 siblings, 1 reply; 10+ messages in thread
From: Xin Tong @ 2012-01-26 18:31 UTC (permalink / raw)
To: qemu-devel
When i attach gdb to qemu running in system mode, i often get things like
[Thread 0x7ffed2013700 (LWP 29499) exited]
[New Thread 0x7ffed2013700 (LWP 29500)]
what spawns these threads and what do these threads do ?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-01-26 18:31 [Qemu-devel] spawning and killing threads in qemu Xin Tong
@ 2012-01-26 18:35 ` Paolo Bonzini
2012-01-26 19:22 ` Xin Tong
0 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2012-01-26 18:35 UTC (permalink / raw)
To: qemu-devel
On 01/26/2012 07:31 PM, Xin Tong wrote:
> When i attach gdb to qemu running in system mode, i often get things like
>
> [Thread 0x7ffed2013700 (LWP 29499) exited]
> [New Thread 0x7ffed2013700 (LWP 29500)]
>
> what spawns these threads and what do these threads do ?
The block layer's thread pool.
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-01-26 18:35 ` Paolo Bonzini
@ 2012-01-26 19:22 ` Xin Tong
2012-01-30 9:52 ` 陳韋任
0 siblings, 1 reply; 10+ messages in thread
From: Xin Tong @ 2012-01-26 19:22 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
what is that, can you please briefly explain ?
Thanks
Xin
On Thu, Jan 26, 2012 at 1:35 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 01/26/2012 07:31 PM, Xin Tong wrote:
>>
>> When i attach gdb to qemu running in system mode, i often get things like
>>
>> [Thread 0x7ffed2013700 (LWP 29499) exited]
>> [New Thread 0x7ffed2013700 (LWP 29500)]
>>
>> what spawns these threads and what do these threads do ?
>
>
> The block layer's thread pool.
>
> Paolo
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-01-26 19:22 ` Xin Tong
@ 2012-01-30 9:52 ` 陳韋任
2012-02-06 10:15 ` Stefan Hajnoczi
0 siblings, 1 reply; 10+ messages in thread
From: 陳韋任 @ 2012-01-30 9:52 UTC (permalink / raw)
To: Xin Tong; +Cc: Paolo Bonzini, qemu-devel
> On Thu, Jan 26, 2012 at 1:35 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > On 01/26/2012 07:31 PM, Xin Tong wrote:
> >>
> >> When i attach gdb to qemu running in system mode, i often get things like
> >>
> >> [Thread 0x7ffed2013700 (LWP 29499) exited]
> >> [New Thread 0x7ffed2013700 (LWP 29500)]
> >>
> >> what spawns these threads and what do these threads do ?
> >
> >
> > The block layer's thread pool.
Qemu 1.0 enable IO thread by default, I think that's why you can see there are
two threads. You can check block/raw-posix-aio.h, posix-aio-compat.c and linux-aio.c.
HTH,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-01-30 9:52 ` 陳韋任
@ 2012-02-06 10:15 ` Stefan Hajnoczi
2012-02-07 2:44 ` 陳韋任
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Hajnoczi @ 2012-02-06 10:15 UTC (permalink / raw)
To: 陳韋任; +Cc: Paolo Bonzini, qemu-devel, Xin Tong
On Mon, Jan 30, 2012 at 05:52:48PM +0800, 陳韋任 wrote:
> > On Thu, Jan 26, 2012 at 1:35 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > > On 01/26/2012 07:31 PM, Xin Tong wrote:
> > >>
> > >> When i attach gdb to qemu running in system mode, i often get things like
> > >>
> > >> [Thread 0x7ffed2013700 (LWP 29499) exited]
> > >> [New Thread 0x7ffed2013700 (LWP 29500)]
> > >>
> > >> what spawns these threads and what do these threads do ?
> > >
> > >
> > > The block layer's thread pool.
>
> Qemu 1.0 enable IO thread by default, I think that's why you can see there are
> two threads. You can check block/raw-posix-aio.h, posix-aio-compat.c and linux-aio.c.
--enable-io-thread is different from posix-aio-compat.c's thread pool.
--enable-io-thread means there is a dedicated thread (created at
startup) which runs the event loop.
The temporary threads you are seeing are indeed posix-aio-compat.c
worker threads. They execute blocking I/O system calls so that the QEMU
event loop can continue to process events while I/O operations are
running.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-02-06 10:15 ` Stefan Hajnoczi
@ 2012-02-07 2:44 ` 陳韋任
2012-02-07 10:25 ` Stefan Hajnoczi
0 siblings, 1 reply; 10+ messages in thread
From: 陳韋任 @ 2012-02-07 2:44 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: Paolo Bonzini, qemu-devel, 陳韋任, Xin Tong
Hi Stefan,
Thanks for the explanation. :)
> > Qemu 1.0 enable IO thread by default, I think that's why you can see there are
> > two threads. You can check block/raw-posix-aio.h, posix-aio-compat.c and linux-aio.c.
>
> --enable-io-thread is different from posix-aio-compat.c's thread pool.
The option "--enable-io-thread" should have been gone sine QEMU 1.0, right?
Or you just use the term to mean IO thread?
> --enable-io-thread means there is a dedicated thread (created at
> startup) which runs the event loop.
I want to know where IO thread is lauched but I am lost in vl.c. Would you
mind to shed some light on that?
> The temporary threads you are seeing are indeed posix-aio-compat.c
> worker threads. They execute blocking I/O system calls so that the QEMU
> event loop can continue to process events while I/O operations are
> running.
So, IO thread runs the event loop (I think it's main_loop_wait in main-loop.c,
right?), and it leave blocking I/O system calls to posix-aio-compat.c worker
threads? Is that correct?
Thanks!
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-02-07 2:44 ` 陳韋任
@ 2012-02-07 10:25 ` Stefan Hajnoczi
2012-02-09 2:40 ` Xin Tong
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Hajnoczi @ 2012-02-07 10:25 UTC (permalink / raw)
To: 陳韋任; +Cc: Paolo Bonzini, qemu-devel, Xin Tong
2012/2/7 陳韋任 <chenwj@iis.sinica.edu.tw>:
> Hi Stefan,
>
> Thanks for the explanation. :)
>
>> > Qemu 1.0 enable IO thread by default, I think that's why you can see there are
>> > two threads. You can check block/raw-posix-aio.h, posix-aio-compat.c and linux-aio.c.
>>
>> --enable-io-thread is different from posix-aio-compat.c's thread pool.
>
> The option "--enable-io-thread" should have been gone sine QEMU 1.0, right?
> Or you just use the term to mean IO thread?
Yes, I just used that term to describe the "IO thread".
>> --enable-io-thread means there is a dedicated thread (created at
>> startup) which runs the event loop.
>
> I want to know where IO thread is lauched but I am lost in vl.c. Would you
> mind to shed some light on that?
The IO thread is actually the main thread of the process. vcpus are
created as separate threads but the main loop in vl.c becomes the IO
thread.
>> The temporary threads you are seeing are indeed posix-aio-compat.c
>> worker threads. They execute blocking I/O system calls so that the QEMU
>> event loop can continue to process events while I/O operations are
>> running.
>
> So, IO thread runs the event loop (I think it's main_loop_wait in main-loop.c,
> right?), and it leave blocking I/O system calls to posix-aio-compat.c worker
> threads? Is that correct?
Yes. The posix-aio-compat.c only handles block I/O, so subsystems
like networking, VNC, and character devices use other mechanisms to
avoid tying up the main loop.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-02-07 10:25 ` Stefan Hajnoczi
@ 2012-02-09 2:40 ` Xin Tong
2012-02-09 3:19 ` 陳韋任
2012-02-09 7:15 ` Paolo Bonzini
0 siblings, 2 replies; 10+ messages in thread
From: Xin Tong @ 2012-02-09 2:40 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Paolo Bonzini, qemu-devel, 陳韋任
can you show me where these threads get created in the qemu code ?
Thanks
Xin
On Tue, Feb 7, 2012 at 5:25 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> 2012/2/7 陳韋任 <chenwj@iis.sinica.edu.tw>:
>> Hi Stefan,
>>
>> Thanks for the explanation. :)
>>
>>> > Qemu 1.0 enable IO thread by default, I think that's why you can see there are
>>> > two threads. You can check block/raw-posix-aio.h, posix-aio-compat.c and linux-aio.c.
>>>
>>> --enable-io-thread is different from posix-aio-compat.c's thread pool.
>>
>> The option "--enable-io-thread" should have been gone sine QEMU 1.0, right?
>> Or you just use the term to mean IO thread?
>
> Yes, I just used that term to describe the "IO thread".
>
>>> --enable-io-thread means there is a dedicated thread (created at
>>> startup) which runs the event loop.
>>
>> I want to know where IO thread is lauched but I am lost in vl.c. Would you
>> mind to shed some light on that?
>
> The IO thread is actually the main thread of the process. vcpus are
> created as separate threads but the main loop in vl.c becomes the IO
> thread.
>
>>> The temporary threads you are seeing are indeed posix-aio-compat.c
>>> worker threads. They execute blocking I/O system calls so that the QEMU
>>> event loop can continue to process events while I/O operations are
>>> running.
>>
>> So, IO thread runs the event loop (I think it's main_loop_wait in main-loop.c,
>> right?), and it leave blocking I/O system calls to posix-aio-compat.c worker
>> threads? Is that correct?
>
> Yes. The posix-aio-compat.c only handles block I/O, so subsystems
> like networking, VNC, and character devices use other mechanisms to
> avoid tying up the main loop.
>
> Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-02-09 2:40 ` Xin Tong
@ 2012-02-09 3:19 ` 陳韋任
2012-02-09 7:15 ` Paolo Bonzini
1 sibling, 0 replies; 10+ messages in thread
From: 陳韋任 @ 2012-02-09 3:19 UTC (permalink / raw)
To: Xin Tong
Cc: Stefan Hajnoczi, qemu-devel, 陳韋任,
Paolo Bonzini
On Wed, Feb 08, 2012 at 09:40:08PM -0500, Xin Tong wrote:
> can you show me where these threads get created in the qemu code ?
If you mean vcpu thread, see cpu_x86_init (target-i386/helper.c).
At the end of this function,
CPUX86State *cpu_x86_init(const char *cpu_model)
{
qemu_init_vcpu(env); <---
return env;
}
Just follow qemu_init_vcpu and you'll see how vcpu thread is spawn.
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] spawning and killing threads in qemu
2012-02-09 2:40 ` Xin Tong
2012-02-09 3:19 ` 陳韋任
@ 2012-02-09 7:15 ` Paolo Bonzini
1 sibling, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2012-02-09 7:15 UTC (permalink / raw)
To: qemu-devel
On 02/09/2012 03:40 AM, Xin Tong wrote:
> can you show me where these threads get created in the qemu code ?
It's in posix-aio-compat.c. The code is invoked by block/raw-posix.c.
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-02-09 7:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-26 18:31 [Qemu-devel] spawning and killing threads in qemu Xin Tong
2012-01-26 18:35 ` Paolo Bonzini
2012-01-26 19:22 ` Xin Tong
2012-01-30 9:52 ` 陳韋任
2012-02-06 10:15 ` Stefan Hajnoczi
2012-02-07 2:44 ` 陳韋任
2012-02-07 10:25 ` Stefan Hajnoczi
2012-02-09 2:40 ` Xin Tong
2012-02-09 3:19 ` 陳韋任
2012-02-09 7:15 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).