Skip to content

venus: shmem cache and suballocation support

Chia-I Wu requested to merge olv/mesa:venus-shmem-suballoc into main

Shmems are internal and are for CPU access. Venus uses these shmems

  • 1 shmem for the ring buffer (`vn_instance_init_ring)
  • 1 shmem for the reply stream (vn_instance_get_reply_shmem_locked)
  • 1 shmem for indirection submissions (vn_instance_ring_cs_upload_locked)
  • 1 or more shmems for each VkCommandBuffer

This is alright until shmems become HOST3D, which requires a roundtrip to map and takes up a KVM memslot.

To remedy the issues, this MR introduces two changes.

All but the last commit make VkCommandBuffer use suballocated shmems. They also free the shmems owned by VkCommandBuffer after vkEndCommandBuffer is executed in the host. This greatly reduces shmem allocations and active shmems which can take up KVM memslots.

The last commit introduces a shmem cache. Because all but the shmem for the ring buffer are power-of-two in sizes, the shmem cache is straightforward and very effective.

No performance nor CTS regression when comparing GUEST-based shmems and HOST3D-based shmems after this MR.

/cc @zzyiwei @ryanneph

Merge request reports