Skip to content

Instantly share code, notes, and snippets.

@erenard
Created November 6, 2024 08:43
Show Gist options
  • Save erenard/af84d9cb256d71381feb87d06c10739d to your computer and use it in GitHub Desktop.
Save erenard/af84d9cb256d71381feb87d06c10739d to your computer and use it in GitHub Desktop.
Gaming VM with GPU passthroug, QEMU emulator, KVM hypervisor and libVirt

Gaming VM with GPU passthroug notes

CPU configuration

To have the lowest possible latency, cpu cores must be partitionned between host and guest OSes.

On CPUs with [ Intel Hyperthreading / AMD Simultaneous Multi-Threading] threads should not be separated to keep latency low.

First, read the installed CPU's topology

> virsh capabilities

will output -amongst other things- the capabilities/host/topology/cells/cell/cpus, here is an example with an AMD 5800X3D

<capabilities>
  <host>
    <topology>
      <cells num='1'>
        <cell id='0'>
          <cpus num='16'>
            <cpu id='0' socket_id='0' die_id='0' cluster_id='65535' core_id='0' siblings='0,8'/>
            <cpu id='1' socket_id='0' die_id='0' cluster_id='65535' core_id='1' siblings='1,9'/>
            <cpu id='2' socket_id='0' die_id='0' cluster_id='65535' core_id='2' siblings='2,10'/>
            <cpu id='3' socket_id='0' die_id='0' cluster_id='65535' core_id='3' siblings='3,11'/>
            <cpu id='4' socket_id='0' die_id='0' cluster_id='65535' core_id='4' siblings='4,12'/>
            <cpu id='5' socket_id='0' die_id='0' cluster_id='65535' core_id='5' siblings='5,13'/>
            <cpu id='6' socket_id='0' die_id='0' cluster_id='65535' core_id='6' siblings='6,14'/>
            <cpu id='7' socket_id='0' die_id='0' cluster_id='65535' core_id='7' siblings='7,15'/>
            <cpu id='8' socket_id='0' die_id='0' cluster_id='65535' core_id='0' siblings='0,8'/>
            <cpu id='9' socket_id='0' die_id='0' cluster_id='65535' core_id='1' siblings='1,9'/>
            <cpu id='10' socket_id='0' die_id='0' cluster_id='65535' core_id='2' siblings='2,10'/>
            <cpu id='11' socket_id='0' die_id='0' cluster_id='65535' core_id='3' siblings='3,11'/>
            <cpu id='12' socket_id='0' die_id='0' cluster_id='65535' core_id='4' siblings='4,12'/>
            <cpu id='13' socket_id='0' die_id='0' cluster_id='65535' core_id='5' siblings='5,13'/>
            <cpu id='14' socket_id='0' die_id='0' cluster_id='65535' core_id='6' siblings='6,14'/>
            <cpu id='15' socket_id='0' die_id='0' cluster_id='65535' core_id='7' siblings='7,15'/>
          </cpus>
        </cell>
      </cells>
    </topology>
  </host>
</capabilities>

The take away is: siblings should not be separated.

In the above example, reserving the core 0 for the host means that all the cpus having core_id='0' must be reserved togethers. That would be cpu id='0' and cpu id='8', each of them having siblings='0,8'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment