User: Password:
|
|
Subscribe / Log in / New account

Spinlock definition

Spinlock definition

Posted Feb 2, 2012 11:39 UTC (Thu) by abacus (guest, #49001)
Parent article: Betrayed by a bitfield

From arch/x86/include/asm/spinlock_types.h:

        typedef u8  __ticket_t;
        typedef u16 __ticketpair_t;

        typedef struct arch_spinlock {
                union {
                        __ticketpair_t head_tail;
                        struct __raw_tickets {
                                __ticket_t head, tail;
                        } tickets;
                };
        } arch_spinlock_t;
Shouldn't all the above fields have been declared as volatile ?


(Log in to post comments)

Spinlock definition

Posted Feb 3, 2012 6:54 UTC (Fri) by ncm (subscriber, #165) [Link]

No, volatile almost never does anything useful. It's the 32-bit lock word that was the mistake. Fortunately, it should be easy to fix in the kernel without depending on a compiler fix, just by forcing a 64-bit aligned word.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds