Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1444906

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

From Davidlohr Bueso <dave@stgolabs.net>
Newsgroups linux.kernel
Subject Re: [PATCH v4] locking/pvqspinlock: Fix double hash race
Date 2016-07-16 22:10 +0200
Message-ID <rVE4p-8eJ-11@gated-at.bofh.it> (permalink)
References <rVn3z-5Yo-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, 16 Jul 2016, Wanpeng Li wrote:

>From: Wanpeng Li <wanpeng.li@hotmail.com>
>
>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@linux.vnet.ibm.com>
>Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
>Cc: Ingo Molnar <mingo@kernel.org>
>Cc: Waiman Long <Waiman.Long@hpe.com>
>Cc: Davidlohr Bueso <dave@stgolabs.net>
>Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>

Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4] locking/pvqspinlock: Fix double hash race Wanpeng Li <kernellwp@gmail.com> - 2016-07-16 04:00 +0200
  Re: [PATCH v4] locking/pvqspinlock: Fix double hash race Davidlohr Bueso <dave@stgolabs.net> - 2016-07-16 22:10 +0200
    Re: [PATCH v4] locking/pvqspinlock: Fix double hash race Wanpeng Li <kernellwp@gmail.com> - 2016-07-25 12:40 +0200
  Re: [PATCH v4] locking/pvqspinlock: Fix double hash race Wanpeng Li <kernellwp@gmail.com> - 2016-07-19 09:00 +0200

csiph-web