Ben-Ami Yassour wrote:
> Weidong,
> 
> I agree that supporting multiple devices is important, but I think
> that supporting a single device is good enough for a first merge with
> the main kvm tree. I suggest that we focus on merging with the main
> tree and work on this in the background.   
> 

I agree to merge the single device supporting to main kvm tree first. 

> Note that I made quite a few cleanups to the vtd.c code (checkpatch
> fixes etc.), also the memory pinning fix is directly related to the
> multiple devices and we need to merge it all. Since Amit is going to
> be out of the office, I'll setup a tree that we can use.   
> 

I found your changes on vtd.c, but they are not in vtd branch. It's easy to 
merge that. It's good you can setup a tree.

> Regarding the specific patch, can we do it simpler?
> It seems to me that we can get what we need without the vtd domain
> list and device list per domain. 

Can you explain how to avoid vtd domain list?

> Also, I could not find where you checked if we can use the same
> domain for two device. It seems that it creates a new domain for each
> new device.  

find_kvm_vtd_domain() checks that.

> 
> Here is an alternative approach that does not require new lists:
> Each device has a link to a domain (like in the original
> implementation). 
> Each domain has a reference count (probably need a wrapper around
> dmar_domain for that). 
> 
> When adding a new device:
> Loop the pt devices and check if there is a device in the same iommu
> that can share its domain. 
> If no:
>    create a domain and set ref count to 1
> If yes:
>    point to that domain and increment the domain reference count.
> 
> Removing a device:
> Decrement the domain reference count.
> If reference count is 0, release domain resources.
> 

Sounds good, but still need a domain (dmar_domain wrapper) list.

> kvm_iommu_map_pages:
> need to make sure that we do it once for each domain, there are some
> simple options that does not require additional list.
> 

there is a kvm_iommu_map_domain_pages() to map memory for each domain. Normally 
kvm_iommu_map_domain_pages() maps memory once for each domain. But, when kvm 
memory changes (e.g. balloon driver), we need to update memory for each domain. 
So kvm_iommu_map_pages()/kvm_iommu_put_pages update memory for all the domains. 
This patch doesn't complete the balloon driver case. 

> Do you see any reason why this is not good enough?

It's the initial version. welcome your comments to make it good enough.

Randy (Weidong)

N�����r��y����b�X��ǧv�^�)޺{.n�+����h����ܨ}���Ơz�&j:+v�������zZ+��+zf���h���~����i���z��w���?�����&�)ߢf

Reply via email to