All of lore.kernel.org
 help / color / mirror / Atom feed
* IRQ affinity on Linux guest
@ 2015-08-20 14:16 Mihai Neagu
  2015-08-20 23:20 ` Radim Krčmář
  0 siblings, 1 reply; 4+ messages in thread
From: Mihai Neagu @ 2015-08-20 14:16 UTC (permalink / raw)
  To: kvm; +Cc: adrian.papp, vicentiu.neagoe

Hello,

I'm trying to assign some IRQ affinities to core 0 by setting 
smp_affinity to 1.
This is on a dual-core embedded Linux virtual machine ran with KVM.
However, ISRs continue to run on both cores.
The same technique works well with QEMU with full software emulation.

Here is the output of the following:

host> uname -a
Linux rtcon2 3.19.0-22-generic #22~14.04.1-Ubuntu SMP Wed Jun 17
10:03:13 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

guest> uname -a
Linux NI-cRIO-Linux-525400123456 3.14.40-rt37-nilrt #1 SMP PREEMPT RT
Thu Aug 6 20:35:41 EEST 2015 x86_64 GNU/Linux

host> kvm --version
QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1.15), Copyright
(c) 2003-2008 Fabrice Bellard

Here is how IRQ affinity is configured on guest at startup, in an init.d
script:

echo 1 > /proc/irq/default_smp_affinity
for x in /proc/irq/*/smp_affinity;
do
   echo 1 > $x
done 2> /dev/null

The command line for starting the hardware accelerated VM:
kvm -kernel bzImage -hda rootfs.ext2 -append "root=/dev/sda console=ttyS0  \
rw" -nographic -cpu qemu64 -snapshot -smp 2 -m 2048

... which actually runs this:
qemu-system-x86-64 -enable-kvm -kernel bzImage -hda rootfs.ext2 -append    \
"root=/dev/sda console=ttyS0 rw" -nographic -cpu qemu64 -snapshot -smp 2   \
-m 2048

On the hardware accelerated guest, 'cat /proc/interrupts' shows:
            CPU0       CPU1
   0:         26          0   IO-APIC-edge      timer
   1:          7          4   IO-APIC-edge      i8042
   4:       1137        523   IO-APIC-edge      serial
   8:          0          1   IO-APIC-edge      rtc0
   9:          0          0   IO-APIC-fasteoi   acpi
  11:       4971          4   IO-APIC-fasteoi   eth0
  12:         66         64   IO-APIC-edge      i8042
  14:       1958        714   IO-APIC-edge      ata_piix
  15:       4512         63   IO-APIC-edge      ata_piix
...
Interrupts are serviced on both cores, even though affinity is set to 1.

The command line for starting full software emulation VM is:
qemu-system-x86_64 -kernel bzImage -hda rootfs.ext2 -append "root=/dev/sda \
console=ttyS0 rw" -nographic -cpu qemu64 -snapshot -smp 2 -m 2048

On the full software emulation guest, 'cat /proc/interrupts' shows:
            CPU0       CPU1
   0:         36          0   IO-APIC-edge      timer
   1:         10          0   IO-APIC-edge      i8042
   4:       1775          0   IO-APIC-edge      serial
   8:          1          0   IO-APIC-edge      rtc0
   9:          0          0   IO-APIC-fasteoi   acpi
  11:        345          0   IO-APIC-fasteoi   eth0
  12:        125          0   IO-APIC-edge      i8042
  14:       1720          0   IO-APIC-edge      ata_piix
  15:        481          0   IO-APIC-edge      ata_piix
...
Interrupts are serviced only on CPU0, therefore setting IRQ affinity worked.

Do you have any idea why KVM doesn't respect IRQ affinity on the guest?
What can I do to get it working with IRQ affinity set to 1?

Thanks,
Mihai

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

end of thread, other threads:[~2015-08-21 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 14:16 IRQ affinity on Linux guest Mihai Neagu
2015-08-20 23:20 ` Radim Krčmář
2015-08-21 12:33   ` Mihai Neagu
2015-08-21 14:46     ` Paolo Bonzini

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.