[RFC][PATCH] locking: Generic ticket-lock
David Laight
David.Laight at ACULAB.COM
Wed Apr 14 16:59:12 BST 2021
From: Peter Zijlstra
> Sent: 14 April 2021 13:56
>
> > I've tested it on csky SMP*4 hw (860) & riscv SMP*4 hw (c910) and it's okay.
>
> W00t :-)
>
> > Hope you can keep
> > typedef struct {
> > union {
> > atomic_t lock;
> > struct __raw_tickets {
> > #ifdef __BIG_ENDIAN
> > u16 next;
> > u16 owner;
> > #else
> > u16 owner;
> > u16 next;
> > #endif
> > } tickets;
> > };
> > } arch_spinlock_t;
> >
> > Using owner & next is much more readable.
>
> That almost doubles the line-count of the thing ;-)
And relies on the compiler not ever spilling it to stack.
Which it is much more likely to do that for the version
that uses shifts.
Have you checked what happens with -O0 ?
I don't think that is banned by the build system.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
More information about the linux-riscv
mailing list