Skip to contentSkip to conversation

irq latency and tcg

Qemu-devel Artyom Tarasenko 3 participants 8 messages Dec 7, 2009 – Dec 12, 2009

lore
Share & tools
lore
#0 lore raw

Can it be that qemu (-system-sparc in my case, but I guess it's more or less similar on all platforms) reacts to irqs slower than a real hardware due to tcg optimizations?

I see one test pattern which fails on qemu:

<cause an interrupt>
nop * N
<check whether the interrupt happened>

What I observe is that the proper interrupt does take a place, but after the check, so no-one expects it anymore.
Is there a way to reduce the interrupt latency? Or maybe there is a good substitute to a nop*N, so that irq would definitely get through in the mean time?

Artyom

#1 lore raw
Quoted 3 lines · Artyom Tarasenko

Can it be that qemu (-system-sparc in my case, but I guess it's more or less similar on all platforms) reacts to irqs slower than a real hardware due to tcg optimizations?

Interrupts generally only trigger at branch instructions, or similar.

Using -icount should give you precise interrupt delivery.

Paul

#2 lore raw

2009/12/7 Paul Brook <[email protected]>:

Quoted 8 lines · Artyom Tarasenko
Quoted 3 lines

Can it be that qemu (-system-sparc in my case, but I guess it's more or less similar on all platforms) reacts to irqs slower than a real hardware due to tcg optimizations?

Interrupts generally only trigger at branch instructions, or similar.

Using -icount should give you precise interrupt delivery.

That's what I thought, but as I reported a few days ago, I couldn't find a good value for icount when using OBP.
I tried a few values but keep getting "qemu: fatal: Raised interrupt while not in I/O function".
Also I got a report from other person where qemu crashed with another
message: "qemu: fatal: Trap 0x29 while interrupts disabled".

What could be a good value for -icount? Is it host-cpu specific? Isn't it a bug that qemu crashes [at least] on some icount values?

#3 lore raw
Quoted 6 lines
Quoted 1 line

Using -icount should give you precise interrupt delivery.

That's what I thought, but as I reported a few days ago, I couldn't find a good value for icount when using OBP.
I tried a few values but keep getting "qemu: fatal: Raised interrupt while not in I/O function".

That's almost certainly a bug in the sparc backend.

Paul

#4 lore raw
In reply to Artyom Tarasenko
Quoted 10 lines · Artyom Tarasenko

Can it be that qemu (-system-sparc in my case, but I guess it's more or less similar on all platforms) reacts to irqs slower than a real hardware due to tcg optimizations?

I see one test pattern which fails on qemu:

<cause an interrupt>
nop * N
<check whether the interrupt happened>

Quoted 5 lines

What I observe is that the proper interrupt does take a place, but after the check, so no-one expects it anymore.
Is there a way to reduce the interrupt latency? Or maybe there is a good substitute to a nop*N, so that irq would definitely get through in the mean time?

On Sparc, nops do not generate any code at all.

#5 lore raw

2009/12/7 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

Can it be that qemu (-system-sparc in my case, but I guess it's more or less similar on all platforms) reacts to irqs slower than a real hardware due to tcg optimizations?

I see one test pattern which fails on qemu:

<cause an interrupt>
nop * N
<check whether the interrupt happened>

Quoted 7 lines
Quoted 5 lines

What I observe is that the proper interrupt does take a place, but after the check, so no-one expects it anymore.
Is there a way to reduce the interrupt latency? Or maybe there is a good substitute to a nop*N, so that irq would definitely get through in the mean time?

On Sparc, nops do not generate any code at all.

But "qemu: fatal: Raised interrupt while not in I/O function" is still a bug, right?

#6 lore raw
Quoted 19 lines · Artyom Tarasenko

2009/12/7 Blue Swirl <[email protected]>:

Quoted 18 lines
Quoted 15 lines · Artyom Tarasenko

Can it be that qemu (-system-sparc in my case, but I guess it's more or less similar on all platforms) reacts to irqs slower than a real hardware due to tcg optimizations?

I see one test pattern which fails on qemu:

<cause an interrupt>
nop * N
<check whether the interrupt happened>

What I observe is that the proper interrupt does take a place, but after the check, so no-one expects it anymore.
Is there a way to reduce the interrupt latency? Or maybe there is a good substitute to a nop*N, so that irq would definitely get through in the mean time?

Quoted 4 lines
Quoted 1 line

On Sparc, nops do not generate any code at all.

But "qemu: fatal: Raised interrupt while not in I/O function" is still a bug, right?

According to comment in exec-all.h:
/* Deterministic execution requires that IO only be performed on the last
instruction of a TB so that interrupts take effect immediately. */

Sparc generator must then violate this assumption. Is the assumption valid also when not using icount and should the check be enabled for all cases, not just icount?

#7 lore raw
Quoted 7 lines

According to comment in exec-all.h:
/* Deterministic execution requires that IO only be performed on the last
instruction of a TB so that interrupts take effect immediately. */

Sparc generator must then violate this assumption. Is the assumption valid also when not using icount and should the check be enabled for all cases, not just icount?

Not really. With -icount we're trying to achieve deterministic behavior[1]. When icount is disabled a few extra instructions interrupt latency is the least of your problems.

I guess with in-core peripherals you may be able to accurately predict interrupt response. However for the vast majority of cases I wouldn't be surprised if real hardware has a few cycles latency anyway.

Paul

[1] Even with -icount, qemu is still a long way from being cycle accurate. The goal is to give reproducible and consistent results. Actual realtime characteristics are still likely to be very different from real hardware.

Paul