Re: [PATCHv2] kvm: remove in_range and switch to rwsem for iobus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 29, 2009 at 12:53:48PM +0300, Avi Kivity wrote:
> On 06/29/2009 12:41 PM, Michael S. Tsirkin wrote:
>> On Mon, Jun 29, 2009 at 11:37:00AM +0300, Avi Kivity wrote:
>>    
>>> On 06/28/2009 10:34 PM, Michael S. Tsirkin wrote:
>>>      
>>>> This changes bus accesses to use high-level kvm_io_bus_read/kvm_io_bus_write
>>>> functions, which utilize read/write semaphore intead of mutex.  in_range now
>>>> becomes unused so it is removed from device ops in favor of read/write
>>>> callbacks performing range checks internally.
>>>>
>>>> This allows aliasing (mostly for in-kernel virtio), as well as better error
>>>> handling by making it possible to pass errors up to userspace. And it's enough
>>>> to look at the diffstat to see that it's a better API anyway.
>>>>
>>>> While we are at it, document locking rules for kvm_io_device_ops.
>>>>
>>>> Note: since the use of the new bus_lock is localized to a small number of
>>>> places, it will be easy to switch to srcu in the future if we so desire.
>>>>
>>>>        
>>> Looks good. But please split into a locking change patch and an API
>>> change patch (in whatever order makes more sense).
>>>      
>>
>> This is harder than it seems. Is this really important?
>>
>> The locking change itself is about 6 lines, but
>> 1. if I do it after in_range removal I get deadlocks
>> as after marcelo's change kvm->lock is taken internally by writers.
>>    
>
> slots_lock is an outer lock to kvm->lock.
>
>> 2. if I do it before in_range removal it's a lot of churn:
>> one of the reasons for code reorg is so that there are less
>> places to change locking.
>>
>>
>>    
>
> I don't think you really need to change anything.  slots_lock is already  
> taken (except where you modify the list).

Are you sure about this? I don't understand the code well enough, so
this reuse of an apparently unrelated lock just makes me nervious.  For
example what about emulate_instruction? It is sometimes called from
svm/vmx without slot lock ...

> How about this:
>
> 1. add slots_lock for write when modifying the list
> 2. change the api
> 3. drop kvm->lock
>
> ?

Looks like I will just have to bite the bullet and switch to RCU.

-- 
MST
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux