From: Davidlohr Bueso <dave@stgolabs.net>
To: Wanpeng Li <kernellwp@gmail.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Wanpeng Li <wanpeng.li@hotmail.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>, Waiman Long <Waiman.Long@hpe.com>
Subject: Re: [PATCH v4] locking/pvqspinlock: Fix double hash race
Date: Sat, 16 Jul 2016 13:03:22 -0700 [thread overview]
Message-ID: <20160716200321.GA3241@linux-80c1.suse> (raw)
In-Reply-To: <1468633869-4066-1-git-send-email-wanpeng.li@hotmail.com>
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>
next prev parent reply other threads:[~2016-07-16 20:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-16 1:51 [PATCH v4] locking/pvqspinlock: Fix double hash race Wanpeng Li
2016-07-16 20:03 ` Davidlohr Bueso [this message]
2016-07-25 10:30 ` Wanpeng Li
2016-07-19 6:53 ` Wanpeng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160716200321.GA3241@linux-80c1.suse \
--to=dave@stgolabs.net \
--cc=Waiman.Long@hpe.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=wanpeng.li@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.