Re: [PATCH] locking: Generic ticket lock

From: Arnd Bergmann
Date: Thu Oct 21 2021 - 09:50:11 EST


On Thu, Oct 21, 2021 at 3:05 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> 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 or
a trivial test-and-set?

> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> include/asm-generic/qspinlock.h | 30 +++++++++
> include/asm-generic/ticket_lock_types.h | 11 +++
> include/asm-generic/ticket_lock.h | 97 ++++++++++++++++++++++++++++++++
> 3 files changed, 138 insertions(+)

If anyone wants to use this for their architecture, feel free to add

Acked-by: Arnd Bergmann <arnd@xxxxxxxx>

to merge it through the respective architecture git tree. If there is more
than one architecture that wants it right now, I could also take them
all through
the asm-generic tree.

Arnd