KVM GPU passthrough latency issues - Intel X299

Questions about virtualization software
Forum rules
Before you post please read how to get help
Post Reply
Level 1
Level 1
Posts: 1
Joined: Sat Jan 20, 2018 7:23 am
Location: United Kingdom

KVM GPU passthrough latency issues - Intel X299

Post by th2000125 » Sat Jan 20, 2018 9:52 am

Hello everyone,

I wanted to start by saying, hello! and sorry for being a first post help pleading newbie. I could have sworn I had an account but apparently not.

Brief explanation: I'm currently building a project with some friends, I have and always will use Linux as my primary OS but to game I have been forced to go to the darkside that is Windows. Anyway, I have never succeeded to successfully passthrough my GPU via KVM until now and this system is supposed to be our solution to LANs. After a first success I had to fix (code 43) for the Nvidia card. Then I had to work out why I was having abysmal performance in, to put it bluntly everything. And now, I seem to be at the final hurdle, I have got games to work, I can passthrough system audio to the host or use the HDMI stream (which is what we will be using at LANs or I hoped so) at the moment I am getting latency spikes that don't ruin single player games but multiplayer, lets just say there is much to be desired. The spikes appear to destroy my real-time audio abilities, I get pop's every few seconds 3 - 5 but the host audio is unaffected so in every other scenario so I don't know what to do.

I forgot to add, when my PC starts it "lags" every few seconds. CLI and system monitor both freeze for periods of time and then come back and go. This happens for around 3 minutes and then it appears to be fine afterwards. I really have no idea how I would go around debugging that. If I need to make a second post I would appreciate some direction :)

CPU: 7820X @ 4.5GHz
RAM: 32GB 4x8GB
NIC: Intel Gigabit, AQC107 (tried passing through as I thought the bridge might be adding latency but no avail)
SSD: Host@500GB Samsung 850 Evo and one of the VM's @500GB Samsung 850 Evo M.2 with a few hard drives
GPU: Host@GTX1060 (pcie x8mode), VM@1080ti (pcie x8mode - I can't run at it at x16 due to whacky BIOS config)

OS: Linux Mint 18.3 (Had to install 18.2 first as 18.3 live USB just kernel panic'd)
Kernel: 4.14.13 (I had so many issues going past Linux Kernels 4.8+, I get an ACPI error on boot with all of them)
Software: Compiled against library: libvirt 2.2.0, Using library: libvirt 2.2.0, Using API: QEMU 2.2.0, Running hypervisor: QEMU 2.6.2, OVMF 05/01/2018.


Code: Select all

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on vfio_iommu_type1.allow_unsafe_interrupts=1 elevator=deadline transparent_hugepage=always intel_idle.max_cstate=1 isolcpus=0-3,8-11 nohz_full=0-3,8-11 rcu_nocbs=0-3,8-11"

Code: Select all

#pci_stub ids=10de:1b06,10de:10ef,1d6a:d107

Code: Select all

options vfio-pci ids=10de:1b06,10de:10ef

Code: Select all

# Set hugetables / hugepages for KVM single guest
vm.nr_hugepages = 9000
kernel.shmmax = 9437184000
VM config

Code: Select all

<domain type='kvm'>
  <memory unit='KiB'>16777216</memory>
  <currentMemory unit='KiB'>16777216</currentMemory>
  <vcpu placement='static' current='8'>16</vcpu>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='2'/>
    <vcpupin vcpu='3' cpuset='3'/>
    <vcpupin vcpu='4' cpuset='8'/>
    <vcpupin vcpu='5' cpuset='9'/>
    <vcpupin vcpu='6' cpuset='10'/>
    <vcpupin vcpu='7' cpuset='11'/>
    <emulatorpin cpuset='0,8'/>
    <type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <bootmenu enable='yes'/>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='whatever'/>
      <hidden state='on'/>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='4' threads='2'/>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
        <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/disk/by-id/ata-Samsung_SSD_850_EVO_500GB'/>
      <target dev='sdb' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/disk/by-id/ata-HGST_HDN726040'/>
      <target dev='sdc' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='2'/>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/disk/by-id/ata-WDC_WD40EZRZ'/>
      <target dev='sdd' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='3'/>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/var/lib/libvirt/images/virtio-win-0.1.141.iso'/>
      <target dev='sde' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='5'/>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    <controller type='usb' index='0' model='nec-xhci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    <interface type='direct'>
      <mac address='52:54:00:ad:66:b3'/>
      <source dev='enp0s31f6' mode='private'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
        <address domain='0x0000' bus='0x17' slot='0x00' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
        <address domain='0x0000' bus='0x17' slot='0x00' function='0x1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
        <address domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
[/b]Not inuse audio passthrough[/b]

Code: Select all

    <qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
    <qemu:env name='QEMU_PA_SAMPLES' value='1024'/>
    <qemu:env name='QEMU_AUDIO_TIMER_PERIOD' value='150'/>
    <qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>

I have gone over so much data trying to work out where I am going wrong. Arch Linux documents and all kinds of forums, I have tried pci_stub vs vfio-pci and can't notice any difference. CPU pinning, Different Kernels, Latency monitoring after changing settings. I don't mind buying a DAC but for each of us to have to do that when we have already invested a fair bit in this build doesn't seem right and either way I need to fix this latency.

Any help would be seriously appreciated! Thanks so much for reading. :D

Post Reply

Return to “Virtualization”