All of lore.kernel.org
 help / color / mirror / Atom feed
* qemu icount to run guest SMP code
@ 2020-07-28 12:33 Wu, Wentong
  2020-07-28 13:36 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Wu, Wentong @ 2020-07-28 12:33 UTC (permalink / raw)
  To: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

Hi,
We are trying to run guest SMP code with qemu icount mode, but based on my current understanding I don't think we can do that, because with icount enabled, the multi cpus will be simulated in round-robin way(tcg kick vcpu timer, or current cpu exit in order to handle interrupt or the ending of the current execution translationblock) with the single vCPU thread, so qemu is not running guest code in parallel as real hardware does, if guest code has the assumption cores run in parallel it will cause unexpected behavior.

I'm fresh man to QEMU and not sure whether the understanding is correct or not, so appreciate any comment, thanks a lot!

BR.


[-- Attachment #2: Type: text/html, Size: 2702 bytes --]

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

* Re: qemu icount to run guest SMP code
  2020-07-28 12:33 qemu icount to run guest SMP code Wu, Wentong
@ 2020-07-28 13:36 ` Peter Maydell
  2020-07-29  2:43   ` Wu, Wentong
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2020-07-28 13:36 UTC (permalink / raw)
  To: Wu, Wentong; +Cc: QEMU Developers

On Tue, 28 Jul 2020 at 13:34, Wu, Wentong <wentong.wu@intel.com> wrote:
> We are trying to run guest SMP code with qemu icount mode, but based on my current understanding I don’t think we can do that, because with icount enabled, the multi cpus will be simulated in round-robin way(tcg kick vcpu timer, or current cpu exit in order to handle interrupt or the ending of the current execution translationblock) with the single vCPU thread, so qemu is not running guest code in parallel as real hardware does, if guest code has the assumption cores run in parallel it will cause unexpected behavior.

In general you can't expect QEMU's simulation to be accurate
to the level that it will correctly run guest code that's looking
carefully at the level of parallelism between multiple cores
(whether using -icount or not.) Timing of the emulated CPUs
will always vary from that of real hardware to some extent.

SMP mode with icount (ie without MTTCG) will run all vCPUs
on one thread, but since we always round-robin between them
well-behaved guest code will make forward progress and will
not notice any major differences between this and real
parallel execution. (Sometimes it might spin a little more if
it has a busy-loop waiting for another core, but only until
the round-robin kicks in and runs the other core.)

thanks
-- PMM


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

* RE: qemu icount to run guest SMP code
  2020-07-28 13:36 ` Peter Maydell
@ 2020-07-29  2:43   ` Wu, Wentong
  0 siblings, 0 replies; 4+ messages in thread
From: Wu, Wentong @ 2020-07-29  2:43 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers


Thanks for the reply.

> > We are trying to run guest SMP code with qemu icount mode, but based on my current understanding I don’t think we can do that, because with icount enabled, the multi cpus will be simulated in round-robin way(tcg kick vcpu timer, or current cpu exit in order to handle interrupt or the ending of the current execution translationblock) with the single vCPU thread, so qemu is not running guest code in parallel as real hardware does, if guest code has the assumption cores run in parallel it will cause unexpected behavior.
>
> Timing of the emulated CPUs will always vary from that of real hardware to some extent.

I understand that, but at least we can get the deterministic result on load heavily PC for emulated single core system if we can adjust the shift value to the level of hardware frequency. And it will not work if icount qemu need  communicate with other real hardware, for example via TCP protocol. 

> In general you can't expect QEMU's simulation to be accurate to the level that it will correctly run guest code that's looking carefully at the level of parallelism between multiple cores (whether using -icount or not.)

Not sure without icount(maybe it will be accurate if only QEMU is running on a powerful PC), but I can understand it's not accurate with icount enabled, the reason is as you mentioned below, there is the possibility that we have to spin to wait another core, so the icount timer will be not accurate.

>
> SMP mode with icount (ie without MTTCG) will run all vCPUs on one thread, but since we always round-robin between them well-behaved guest code will make forward progress and will not notice any major differences between this and real parallel execution. (Sometimes it might spin a little more if it has a busy-loop waiting for another core, but only until the round-robin kicks in and runs the other core.)

Yes, agree with "well-behaved guest code will make forward progress", 

please correct me if anything wrong.

BR

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

* qemu icount to run guest SMP code
@ 2020-07-27  7:25 Wu, Wentong
  0 siblings, 0 replies; 4+ messages in thread
From: Wu, Wentong @ 2020-07-27  7:25 UTC (permalink / raw)
  To: QEMU Developers, Peter Maydell

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

Hi,
We are trying to run guest SMP code with qemu icount mode, but based on my current understanding I don't think we can do that, because with icount enabled, the multi cpus will be simulated in round-robin way(tcg kick vcpu timer, or current cpu exit in order to handle interrupt or the ending of the current execution translationblock) with the single vCPU thread, so qemu is not running guest code in parallel as real hardware does, if guest code has the assumption cores run in parallel it will cause unexpected behavior. Appreciate any comment, thanks a lot!

BR,
Wentong

[-- Attachment #2: Type: text/html, Size: 2533 bytes --]

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

end of thread, other threads:[~2020-07-29  2:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 12:33 qemu icount to run guest SMP code Wu, Wentong
2020-07-28 13:36 ` Peter Maydell
2020-07-29  2:43   ` Wu, Wentong
  -- strict thread matches above, loose matches on Subject: below --
2020-07-27  7:25 Wu, Wentong

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.