Re: [KVM-RFC PATCH 1/2] eventfd: add an explicit srcu based notifier interface

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

 



Michael S. Tsirkin wrote:
> On Wed, Jun 17, 2009 at 11:02:06AM -0400, Gregory Haskins wrote:
>   
>> Michael S. Tsirkin wrote:
>>     
>>> On Tue, Jun 16, 2009 at 02:09:38PM -0400, Gregory Haskins wrote:
>>>   
>>>       
>>>>> What do you mean by copy_to_user(other->mm) here?  If you are going to switch
>>>>> to another mm, then I think current->mm must be valid (I think it's not enough
>>>>> that you can sleep). So preemptible() might not be enough.
>>>>>   
>>>>>       
>>>>>           
>>>> I dont currently use switch_mm, if that is what you mean.  I save the
>>>> task_struct into the appropriate context so current->mm doesn't matter
>>>> to me.  I never use it.  All I need (afaik) is to acquire the proper
>>>> mutex first.  I am not an MM expert, so perhaps I have this wrong but it
>>>> does appear to work properly even from kthread context.
>>>>
>>>> -Greg
>>>>
>>>>
>>>>     
>>>>         
>>> I think I saw get_user_pages + memcpy in your patch. Yes, that works
>>> without switching contexts but it's slower than copy to user if you are
>>> in the right context, and AFAIK it's slower than get_user_pages_fast.
>>>
>>>   
>>>       
>> Yeah, understood.  It will definitely be interesting to try that
>> optimization with switch_mm that you suggested.
>>     
>
> BTW, I'm kind of confused - in your patch you do get_task_struct: does this
> guarantee that mm is not going aways?
>   

Well, again, I am not an expert on MM, but I would think so.  If p holds
a reference to p->mm (which I would think it would have to), and we hold
a reference to p, p->mm should be indirectly stable coincident with the
lifetime of our p reference.  OTOH, I have not actually looked at
whether p actually takes a p->mm reference or not via inspection, so
this is just an educated guess at this point. ;)

I guess if this is broken, the solution is simple:  Modify the code to
take an mm reference as well.

-Greg

Attachment: signature.asc
Description: OpenPGP digital signature


[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