iommu/dma: Use a large flush queue and timeout for shadow_on_flush
authorNiklas Schnelle <schnelle@linux.ibm.com>
Thu, 28 Sep 2023 14:31:40 +0000 (16:31 +0200)
committerJoerg Roedel <jroedel@suse.de>
Mon, 2 Oct 2023 06:43:03 +0000 (08:43 +0200)
commit9f5b681e2a3f7d5bab02e68f3e68a50b23968c7c
treecadaf6afa6ae8f173e26b68fd8aee494e1503252
parent32d5bc8b09c7cc48c511809e7c3b1755c7ecc5fa
iommu/dma: Use a large flush queue and timeout for shadow_on_flush

Flush queues currently use a fixed compile time size of 256 entries.
This being a power of 2 allows the compiler to use shift and mask
instead of more expensive modulo operations. With per-CPU flush queues
larger queue sizes would hit per-CPU allocation limits, with a single
flush queue these limits do not apply however. Also with single queues
being particularly suitable for virtualized environments with expensive
IOTLB flushes these benefit especially from larger queues and thus fewer
flushes.

To this end re-order struct iova_fq so we can use a dynamic array and
introduce the flush queue size and timeouts as new options in the
iommu_dma_options struct. So as not to lose the shift and mask
optimization, use a power of 2 for the length and use explicit shift and
mask instead of letting the compiler optimize this.

A large queue size and 1 second timeout is then set for the shadow on
flush case set by s390 paged memory guests. This then brings performance
on par with the previous s390 specific DMA API implementation.

Acked-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> #s390
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Link: https://lore.kernel.org/r/20230928-dma_iommu-v13-6-9e5fc4dacc36@linux.ibm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/dma-iommu.c