lkml.org 
[lkml]   [2011]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance
On 12/15/2011 02:53 PM, Liu ping fan wrote:


>
>>> +struct kvm_vcpu *kvm_vcpu_get(struct kvm_vcpu *vcpu)
>>> +{
>>> + if (vcpu == NULL)
>>> + return NULL;
>>> + if (atomic_add_unless(&vcpu->refcount, 1, 0))
>>
>>
>> Why do not use atomic_inc()?
>> Also, i think a memory barrier is needed after increasing refcount.
>>
> Because when refcout==0, we prepare to destroy vcpu, and do not to
> disturb it by increasing the refcount.


Oh, get it.

> And sorry but I can not figure out the scene why memory barrier needed
> here. Seems no risks on SMP.
>


If atomic_add_unless is necessary, memory barrier is not needed here.



\
 
 \ /
  Last update: 2011-12-15 09:29    [from the cache]
©2003-2011 Jasper Spaans