[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200123090038.GD14946@hirez.programming.kicks-ass.net>
Date: Thu, 23 Jan 2020 10:00:38 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Alex Kogan <alex.kogan@...cle.com>
Cc: linux@...linux.org.uk, mingo@...hat.com, will.deacon@....com,
arnd@...db.de, longman@...hat.com, linux-arch@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
tglx@...utronix.de, bp@...en8.de, hpa@...or.com, x86@...nel.org,
guohanjun@...wei.com, jglauber@...vell.com,
steven.sistare@...cle.com, daniel.m.jordan@...cle.com,
dave.dice@...cle.com, rahul.x.yadav@...cle.com
Subject: Re: [PATCH v7 3/5] locking/qspinlock: Introduce CNA into the slow
path of qspinlock
On Wed, Jan 22, 2020 at 06:04:56PM +0100, Peter Zijlstra wrote:
> +/*
> + * cna_splice_head -- splice the entire secondary queue onto the head of the
> + * primary queue.
> + */
> +static cna_splice_head(struct qspinlock *lock, u32 val,
> + struct mcs_spinlock *node, struct mcs_spinlock *next)
> +{
> + struct mcs_spinlock *head_2nd, *tail_2nd;
> +
> + tail_2nd = decode_tail(node->locked);
> + head_2nd = tail_2nd->next;
> +
> + if (lock) {
That should be: if (!next) {
> + u32 new = ((struct cna_node *)tail_2nd)->encoded_tail | _Q_LOCKED_VAL;
> + if (!atomic_try_cmpxchg_relaxed(&lock->val, &val, new))
> + return NULL;
> +
> + /*
> + * The moment we've linked the primary tail we can race with
> + * the WRITE_ONCE(prev->next, node) store from new waiters.
> + * That store must win.
> + */
And that still is a shit comment; I'll go try again.
> + cmpxchg_relaxed(&tail_2nd->next, head_2nd, next);
> + } else {
> + tail_2nd->next = next;
> + }
> +
> + return head_2nd;
> +}
Powered by blists - more mailing lists