From: Peter Zijlstra <peterz@infradead.org>
To: Waiman Long <Waiman.Long@hpe.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Scott J Norton <scott.norton@hpe.com>,
Douglas Hatch <doug.hatch@hpe.com>,
Davidlohr Bueso <dave@stgolabs.net>
Subject: Re: [PATCH v7 4/5] locking/pvqspinlock: Allow 1 lock stealing attempt
Date: Tue, 13 Oct 2015 21:39:28 +0200 [thread overview]
Message-ID: <20151013193928.GX3816@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1442955044-43895-5-git-send-email-Waiman.Long@hpe.com>
On Tue, Sep 22, 2015 at 04:50:43PM -0400, Waiman Long wrote:
> This patch allows one attempt for the lock waiter to steal the lock
> when entering the PV slowpath. This helps to reduce the performance
> penalty caused by lock waiter preemption while not having much of
> the downsides of a real unfair lock.
>
Changelog does not explain the implementation, which is subtle enough to
warrant a few words.
> @@ -417,7 +415,8 @@ queue:
> * does not imply a full barrier.
> *
> */
> - pv_wait_head(lock, node);
> + if (pv_wait_head_and_lock(lock, node, tail))
> + goto release;
That's very much: pv_wait_head_or_lock(), maybe _or_steal() is even
better.
> while ((val = smp_load_acquire(&lock->val.counter)) & _Q_LOCKED_PENDING_MASK)
> cpu_relax();
>
> @@ -454,7 +453,6 @@ queue:
> cpu_relax();
>
> arch_mcs_spin_unlock_contended(&next->locked);
> - pv_kick_node(lock, next);
Not sure about removing that, breaks symmetry.
> /*
> + * Allow one unfair trylock when entering the PV slowpath to reduce the
> + * performance impact of lock waiter preemption (either explicitly via
> + * pv_wait or implicitly via PLE). This function will be called once when
> + * a lock waiter enter the slowpath before being queued.
> + *
> + * A little bit of unfairness here can improve performance without many
> + * of the downsides of a real unfair lock.
> + */
> +#define queued_spin_trylock(l) pv_queued_spin_trylock_unfair(l)
> +static inline bool pv_queued_spin_trylock_unfair(struct qspinlock *lock)
> +{
> + struct __qspinlock *l = (void *)lock;
> +
> + if (READ_ONCE(l->locked))
> + return 0;
> + /*
> + * Wait a bit here to ensure that an actively spinning queue head vCPU
> + * has a fair chance of getting the lock.
> + */
> + cpu_relax();
> +
> + return cmpxchg(&l->locked, 0, _Q_LOCKED_VAL) == 0;
> +}
This doesn't seem to make any sense.. Its also very much distinct from
the rest of the patch and can easily be added in a separate patch with
separate performance numbers to show it does (or does not) make a
difference.
next prev parent reply other threads:[~2015-10-13 19:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 20:50 [PATCH v7 0/5] locking/qspinlock: Enhance pvqspinlock performance Waiman Long
2015-09-22 20:50 ` [PATCH v7 1/5] locking/qspinlock: relaxes cmpxchg & xchg ops in native code Waiman Long
2015-10-13 18:02 ` Peter Zijlstra
2015-10-13 20:38 ` Waiman Long
2015-10-13 20:47 ` Peter Zijlstra
2015-10-14 9:39 ` Will Deacon
2015-09-22 20:50 ` [PATCH v7 2/5] locking/pvqspinlock, x86: Optimize PV unlock code path Waiman Long
2015-09-22 20:50 ` [PATCH v7 3/5] locking/pvqspinlock: Collect slowpath lock statistics Waiman Long
2015-10-13 20:05 ` Peter Zijlstra
2015-10-13 21:06 ` Waiman Long
2015-09-22 20:50 ` [PATCH v7 4/5] locking/pvqspinlock: Allow 1 lock stealing attempt Waiman Long
2015-10-13 18:23 ` Peter Zijlstra
2015-10-13 20:41 ` Waiman Long
2015-10-13 20:44 ` Peter Zijlstra
2015-10-15 20:44 ` Waiman Long
2015-10-13 19:39 ` Peter Zijlstra [this message]
2015-10-13 20:45 ` Waiman Long
2015-10-13 19:56 ` Peter Zijlstra
2015-10-13 20:50 ` Waiman Long
2015-10-14 9:28 ` Peter Zijlstra
2015-10-15 21:01 ` Waiman Long
2015-09-22 20:50 ` [PATCH v7 5/5] locking/pvqspinlock: Queue node adaptive spinning Waiman Long
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=20151013193928.GX3816@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Waiman.Long@hpe.com \
--cc=dave@stgolabs.net \
--cc=doug.hatch@hpe.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=scott.norton@hpe.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome