Re: [PATCH v4] locking/pvqspinlock: Fix double hash race

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

 



Ping Ingo, Peterz. :)
2016-07-17 4:03 GMT+08:00 Davidlohr Bueso <dave@xxxxxxxxxxxx>:
> On Sat, 16 Jul 2016, Wanpeng Li wrote:
>
>> From: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>
>>
>> When the lock holder vCPU is racing with the queue head vCPU:
>>
>> lock holder vCPU             queue head vCPU
>> =====================        ==================
>>
>> node->locked = 1;
>> <preemption>                 READ_ONCE(node->locked)
>>   ...                       pv_wait_head_or_lock():
>>                               SPIN_THRESHOLD loop;
>>                               pv_hash();
>>                               lock->locked = _Q_SLOW_VAL;
>>                               node->state  = vcpu_hashed;
>> pv_kick_node():
>>  cmpxchg(node->state,
>>     vcpu_halted, vcpu_hashed);
>>  lock->locked = _Q_SLOW_VAL;
>>  pv_hash();
>>
>> With preemption at the right moment, it is possible that both the
>> lock holder and queue head vCPUs can be racing to set node->state
>> which can result in hash entry race. Making sure the state is never
>> set to vcpu_halted will prevent this racing from happening.
>>
>> This patch fix it by setting vcpu_hashed after we did all hash thing.
>>
>> Reviewed-by: Pan Xinhui <xinhui.pan@xxxxxxxxxxxxxxxxxx>
>> Cc: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
>> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
>> Cc: Waiman Long <Waiman.Long@xxxxxxx>
>> Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx>
>> Signed-off-by: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>
>
>
> Reviewed-by: Davidlohr Bueso <dave@xxxxxxxxxxxx>
--
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