Skip to contentSkip to conversation

HVM windows - PCI IRQ firing on both CPU's

DISCUSSION James Harper 2 participants 6 messages Aug 18, 2008

lore
Share & tools
lore
#0 lore raw

I'm just doing some testing on the gplpv drivers with different ways of handling interrupts, and I'm trying a scheme where each xen device (eg vbd/vif) driver attaches to the same IRQ as the pci driver, and each handles it in sequence.

In testing though, I noticed the following when logging what each ISR is doing:

60.32381439 - evtchn event on port 5
60.32384109 - port 5 handler (does some work)
60.32386780 - port 6 handler
60.32389069 - port 7 handler
0.00616564 - evtchn nothing to do
0.00619481 - port 5 handler
0.00621962 - port 6 handler
0.00624393 - port 7 handler

The first number is the timestamp (why is the TSC so far out of whack between CPU's??? Is that a hardware thing or a Xen thing? It causes huge problems with 'ping' too!!!), the second is the isr that is running.

Why is the ISR getting run again immediately on the other CPU? Is this an OS thing or am I not acking the interrupt correctly?

Thanks

James

#1 lore raw
Quoted 6 lines · James Harper

The first number is the timestamp (why is the TSC so far out of whack between CPU's??? Is that a hardware thing or a Xen thing? It causes huge problems with 'ping' too!!!), the second is the isr that is running.

Why is the ISR getting run again immediately on the other CPU? Is this an OS thing or am I not acking the interrupt correctly?

You should be checking and clearing only vcpu0's evtchn_upcall_pending and evtchn_pending_sel fields. Other vcpu's equivalent fields are currently unused for HVM guests. It is essential that you clear evtchn_upcall_pending -- that is the 'virtual interrupt wire' connected to the virtual PIC's level-triggered input pin.

Apart from those caveats, all should work fine with no spurious interrupts.

-- Keir

#2 lore raw
Quoted 1 line

On 18/8/08 11:53, "James Harper" <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

The first number is the timestamp (why is the TSC so far out of

whack

Quoted 1 line
Quoted 1 line

between CPU's??? Is that a hardware thing or a Xen thing? It causes

huge

Quoted 3 lines
Quoted 3 lines

problems with 'ping' too!!!), the second is the isr that is running.

Why is the ISR getting run again immediately on the other CPU? Is

this

Quoted 3 lines
Quoted 1 line

an OS thing or am I not acking the interrupt correctly?

You should be checking and clearing only vcpu0's evtchn_upcall_pending

and

Quoted 1 line

evtchn_pending_sel fields. Other vcpu's equivalent fields are

currently

Quoted 4 lines

unused for HVM guests. It is essential that you clear evtchn_upcall_pending
-- that is the 'virtual interrupt wire' connected to the virtual PIC's level-triggered input pin.

Just so I understand, even if I see the IRQ on CPU1, I should always treat it as if it came in on CPU0?

The lack of that would explain what I'm seeing.

Thanks

James

#3 lore raw
Quoted 2 lines · James Harper

Just so I understand, even if I see the IRQ on CPU1, I should always treat it as if it came in on CPU0?

Yes. Only vcpu0's event-channel logic is wired into the virtual PIC/IOAPIC. Even if the IOAPIC then forwards the interrupt to a different VCPU, it's still vcpu0's event-channel status that initiated the interrupt. Other vcpus' event-channel statuses do not cause interrupts in HVM.

Quoted 1 line

The lack of that would explain what I'm seeing.

It sure would.

-- Keir

#4 lore raw
Quoted 2 lines

On 18/8/08 13:19, "James Harper" <[email protected]>

Quoted 7 lines · wrote:
Quoted 3 lines

Just so I understand, even if I see the IRQ on CPU1, I should always treat it as if it came in on CPU0?

Yes. Only vcpu0's event-channel logic is wired into the virtual PIC/IOAPIC.
Even if the IOAPIC then forwards the interrupt to a different VCPU,

it's

Quoted 3 lines

still vcpu0's event-channel status that initiated the interrupt. Other vcpus' event-channel statuses do not cause interrupts in HVM.

I'm not sure if this is a general or a windows specific question, but I can approach this in one of two ways...

1. Make sure the interrupt is only ever delivered to CPU0 by specifying the affinity when I call IoConnectInterrupt
2. Accept the interrupt on any CPU but always use vcpu_info[0] to check the flags etc.

Does the hypervisor make any scheduling assumptions upon delivering an event to a domain? (eg does it schedule CPU0 on the basis that that CPU is going to be handling the event?)

Thanks

James

#5 lore raw
Quoted 7 lines · James Harper

I'm not sure if this is a general or a windows specific question, but I can approach this in one of two ways...

1. Make sure the interrupt is only ever delivered to CPU0 by specifying the affinity when I call IoConnectInterrupt
2. Accept the interrupt on any CPU but always use vcpu_info[0] to check the flags etc.

(2) will suffice. It's what we do in Linux PV-on-HVM drivers.

Quoted 3 lines

Does the hypervisor make any scheduling assumptions upon delivering an event to a domain? (eg does it schedule CPU0 on the basis that that CPU is going to be handling the event?)

No, the HVM interrupt emulation will cause the correct vcpu to be scheduled (i.e., the one that the IOAPIC/PIC forwards the interrupt to). It's just that the interrupt pin is hardwired to vcpu0's event-pending flag.

-- Keir