Question on iommu_get_domain_for_dev() for DMA map/unmap

John Garry john.garry at huawei.com
Tue Aug 14 10:09:23 UTC 2018


Hi All,

I have a question on function iommu_get_domain_for_dev() in DMA mapping 
path, and why we need to get+put a reference to the iommu group.

The background is that we have been testing iperf throughput performance 
for a PCIe NIC card behind an SMMUv3, with small packets and many 
threads (128) on a system with a lot cores (>64).

We find that the reference counting on the iommu group in 
iommu_dma_map_sg()->iommu_get_domain_for_dev()->kobject_get()/put() is a 
big bottleneck. There is much contention on getting and putting the 
reference to iommu_group.device_kobj.

The question is do we actually need to get+put this reference for DMA 
map/unmap, since the device already takes a reference to the 
iommu_group.device_kobj when attached to the group? Is it to protect 
against the device being removed and the group being freed as it is 
dereferenced? If so, I would say it's not safe to reference the 
associated iommu domain thereafter in the DMA map/unmap, as it would be 
freed along with the iommu group.

Thanks in advance,
John



More information about the iommu mailing list