Skip to content

Commit

Permalink
reduce default SWIOTLB size when no PCI devs are used
Browse files Browse the repository at this point in the history
Linux inside HVM will allocate 64MB for bouncing DMA (SWIOTLB) by
default. If no real PCI device is assigned, that's way too much, and
wastes over 15% of VM's initial memory.
With real PCI devices, it's usually too much too, but it's very device
specific, so don't risk breaking it. In other cases, reduce default to
4MB.

Note PVH domain will not allocate SWIOTLB anyway, as no PCI devices are
there at all. This difference contributes to the VM start time, so
reducing SWIOTLB should also improve that part.

QubesOS/qubes-issues#6174

(cherry picked from commit c774fd4)
  • Loading branch information
marmarek committed May 13, 2023
1 parent 8c93ef0 commit d00e53b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion qubes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'libvirt_uri': 'xen:///',
'memory': 400,
'hvm_memory': 400,
'kernelopts': "",
'kernelopts': "swiotlb=2048",
'kernelopts_pcidevs': "",
'kernelopts_common': ('root=/dev/mapper/dmroot ro nomodeset console=hvc0 '
'rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 '),
Expand Down
12 changes: 6 additions & 6 deletions qubes/tests/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def test_600_libvirt_xml_pv(self):
<type arch="x86_64" machine="xenpv">linux</type>
<kernel>/tmp/kernel/vmlinuz</kernel>
<initrd>/tmp/kernel/initramfs</initrd>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0</cmdline>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 swiotlb=2048</cmdline>
</os>
<features>
</features>
Expand Down Expand Up @@ -900,7 +900,7 @@ def test_600_libvirt_xml_hvm_dom0_kernel(self):
<loader type="rom">hvmloader</loader>
<boot dev="cdrom" />
<boot dev="hd" />
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0</cmdline>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 swiotlb=2048</cmdline>
</os>
<features>
<pae/>
Expand Down Expand Up @@ -967,7 +967,7 @@ def test_600_libvirt_xml_hvm_dom0_kernel_kernelopts(self):
<loader type="rom">hvmloader</loader>
<boot dev="cdrom" />
<boot dev="hd" />
<cmdline>kernel &lt;text&gt;&#39;&#34;&amp; specific options</cmdline>
<cmdline>kernel &lt;text&gt;&#39;&#34;&amp; specific options swiotlb=2048</cmdline>
</os>
<features>
<pae/>
Expand Down Expand Up @@ -1031,7 +1031,7 @@ def test_600_libvirt_xml_pvh(self):
<type arch="x86_64" machine="xenpvh">xenpvh</type>
<kernel>/tmp/kernel/vmlinuz</kernel>
<initrd>/tmp/kernel/initramfs</initrd>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0</cmdline>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 swiotlb=2048</cmdline>
</os>
<features>
<pae/>
Expand Down Expand Up @@ -1101,7 +1101,7 @@ def test_600_libvirt_xml_pvh_no_membalance(self):
<type arch="x86_64" machine="xenpvh">xenpvh</type>
<kernel>/tmp/kernel/vmlinuz</kernel>
<initrd>/tmp/kernel/initramfs</initrd>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0</cmdline>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 swiotlb=2048</cmdline>
</os>
<features>
<pae/>
Expand Down Expand Up @@ -1340,7 +1340,7 @@ def test_600_libvirt_xml_hvm_cdrom_dom0_kernel_boot(self):
<loader type="rom">hvmloader</loader>
<boot dev="cdrom" />
<boot dev="hd" />
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0</cmdline>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 swiotlb=2048</cmdline>
</os>
<features>
<pae/>
Expand Down

0 comments on commit d00e53b

Please sign in to comment.