From: Peter Zijlstra <peterz@infradead.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Will Deacon" <will@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Ingo Molnar" <mingo@kernel.org>,
"Waiman Long" <longman@redhat.com>,
linux-arch <linux-arch@vger.kernel.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Guo Ren" <guoren@kernel.org>,
"Palmer Dabbelt" <palmerdabbelt@google.com>,
"Anup Patel" <anup@brainfault.org>,
linux-riscv <linux-riscv@lists.infradead.org>,
"Christoph Müllner" <christophm30@gmail.com>,
"Stafford Horne" <shorne@gmail.com>
Subject: Re: [PATCH] locking: Generic ticket lock
Date: Thu, 21 Oct 2021 17:14:44 +0200 [thread overview]
Message-ID: <YXGD5OFbI7TEDFTr@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAK8P3a2+=9jjyqN5dMOb4+bYJy=q5G3CxFaCW+=4xryz-S=zYA@mail.gmail.com>
On Thu, Oct 21, 2021 at 03:49:51PM +0200, Arnd Bergmann wrote:
> On Thu, Oct 21, 2021 at 3:05 PM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > Therefore provide ticket locks, which depend on a single atomic
> > operation (fetch_add) while still providing fairness.
>
> Nice!
>
> Aside from the qspinlock vs ticket-lock question, can you describe the
> tradeoffs between this generic ticket lock and a custom implementation
> in architecture code? Should we convert most architectures over
> to the generic code in the long run, or is there something they
> can usually do better with an inline asm based ticket lock
I think for a load-store arch this thing should generate pretty close to
optimal code. x86 can do ticket_unlock() slightly better using a single
INCW (or ADDW 1) on the owner subword, where this implementation will to
separate load-add-store instructions.
If that is actually measurable is something else entirely.
> or a trivial test-and-set?
If your SMP arch is halfway sane (no fwd progress issues etc..) then
ticket should behave well and avoid the starvation/variablilty of TaS
lock.
The big exception there is virtualized architectures, ticket is
absolutely horrendous for 'guests' (any fair lock is for that matter).
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Will Deacon" <will@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Ingo Molnar" <mingo@kernel.org>,
"Waiman Long" <longman@redhat.com>,
linux-arch <linux-arch@vger.kernel.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Guo Ren" <guoren@kernel.org>,
"Palmer Dabbelt" <palmerdabbelt@google.com>,
"Anup Patel" <anup@brainfault.org>,
linux-riscv <linux-riscv@lists.infradead.org>,
"Christoph Müllner" <christophm30@gmail.com>,
"Stafford Horne" <shorne@gmail.com>
Subject: Re: [PATCH] locking: Generic ticket lock
Date: Thu, 21 Oct 2021 17:14:44 +0200 [thread overview]
Message-ID: <YXGD5OFbI7TEDFTr@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAK8P3a2+=9jjyqN5dMOb4+bYJy=q5G3CxFaCW+=4xryz-S=zYA@mail.gmail.com>
On Thu, Oct 21, 2021 at 03:49:51PM +0200, Arnd Bergmann wrote:
> On Thu, Oct 21, 2021 at 3:05 PM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > Therefore provide ticket locks, which depend on a single atomic
> > operation (fetch_add) while still providing fairness.
>
> Nice!
>
> Aside from the qspinlock vs ticket-lock question, can you describe the
> tradeoffs between this generic ticket lock and a custom implementation
> in architecture code? Should we convert most architectures over
> to the generic code in the long run, or is there something they
> can usually do better with an inline asm based ticket lock
I think for a load-store arch this thing should generate pretty close to
optimal code. x86 can do ticket_unlock() slightly better using a single
INCW (or ADDW 1) on the owner subword, where this implementation will to
separate load-add-store instructions.
If that is actually measurable is something else entirely.
> or a trivial test-and-set?
If your SMP arch is halfway sane (no fwd progress issues etc..) then
ticket should behave well and avoid the starvation/variablilty of TaS
lock.
The big exception there is virtualized architectures, ticket is
absolutely horrendous for 'guests' (any fair lock is for that matter).
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2021-10-21 15:19 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 13:05 [PATCH] locking: Generic ticket lock Peter Zijlstra
2021-10-21 13:05 ` Peter Zijlstra
2021-10-21 13:12 ` Peter Zijlstra
2021-10-21 13:12 ` Peter Zijlstra
2021-10-21 13:50 ` Stafford Horne
2021-10-21 13:50 ` Stafford Horne
2021-10-21 13:49 ` Arnd Bergmann
2021-10-21 13:49 ` Arnd Bergmann
2021-10-21 15:14 ` Peter Zijlstra [this message]
2021-10-21 15:14 ` Peter Zijlstra
2021-10-21 15:31 ` Arnd Bergmann
2021-10-21 15:31 ` Arnd Bergmann
2021-10-21 16:28 ` Peter Zijlstra
2021-10-21 16:28 ` Peter Zijlstra
2021-10-21 18:04 ` Waiman Long
2021-10-21 18:04 ` Waiman Long
2021-10-22 15:19 ` Boqun Feng
2021-10-22 15:19 ` Boqun Feng
2021-10-22 2:04 ` Guo Ren
2021-10-22 2:04 ` Guo Ren
2021-10-22 9:23 ` Mark Rutland
2021-10-22 9:23 ` Mark Rutland
2021-10-22 12:31 ` Peter Zijlstra
2021-10-22 12:31 ` Peter Zijlstra
2021-12-14 15:40 ` Will Deacon
2021-12-14 15:40 ` Will Deacon
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=YXGD5OFbI7TEDFTr@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=anup@brainfault.org \
--cc=arnd@arndb.de \
--cc=boqun.feng@gmail.com \
--cc=christophm30@gmail.com \
--cc=guoren@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=longman@redhat.com \
--cc=mingo@kernel.org \
--cc=palmerdabbelt@google.com \
--cc=shorne@gmail.com \
--cc=will@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 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.