spinlocks: check spinlock_t/rwlock_t argument type on non-SMP builds
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 30 lines · * [email protected] <[email protected]> wrote:
From: David Kilroy <[email protected]>
When writing code for UP without
CONFIG_DEBUG_SPINLOCKit's easy to get the first argument to the spinlock/rwlock functions wrong. This is because the parameter is not actually used in this configuration.Typically you will only find out it's wrong
* by rebuilding withCONFIG_SMPorCONFIG_DEBUG_SPINLOCK
* after you've submitted your beautiful patch series.The first means a long wait, and the latter is a bit late.
Change the intermediate macros into inline functions.
Signed-off-by David Kilroy <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
include/linux/spinlock.h | 6 - include/linux/spinlock_api_up.h | 118 ++++++++++++++++++++++-------- 2 files changed, 92 insertions(+), 32 deletions(-)diff -puN
include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-buildsinclude/linux/spinlock.hinclude/linux/spinlock.h renamed from include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-builds +0
-0@@ -240,17 +240,17 @@ static inline void smp_mb__after_lock(vo#define spin_lock_irqsave (lock, flags) \ do { \
include/linux/spinlock.h static inline void smp_mb__after_lock(vo · line 249
Quoted 10 lines
include/linux/spinlock.h renamed from include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-builds +2
-2typecheck(unsigned long, flags); \ -_spin_lock_irqsave (lock, flags); \ +_spin_lock_irqsave (lock, &flags); \ } while (0)#define read_lock_irqsave (lock, flags) \ do { \ typecheck(unsigned long, flags); \ - _read_lock_irqsave(lock, flags); \ + _read_lock_irqsave(lock, &flags); \ } while (0)
these bits broke the Alpha build:
/home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_readb':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:451: error: '_spin_lock_irqsave' is static but used in inline function 't2_readb' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:456: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_readb' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_readw':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:465: error: '_spin_lock_irqsave' is static but used in inline function 't2_readw' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:470: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_readw' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_readl':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:483: error: '_spin_lock_irqsave' is static but used in inline function 't2_readl' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:488: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_readl' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_readq':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:497: error: '_spin_lock_irqsave' is static but used in inline function 't2_readq' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:504: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_readq' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_writeb':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:513: error: '_spin_lock_irqsave' is static but used in inline function 't2_writeb' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:519: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_writeb' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_writew':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:527: error: '_spin_lock_irqsave' is static but used in inline function 't2_writew' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:533: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_writew' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_writel':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:545: error: '_spin_lock_irqsave' is static but used in inline function 't2_writel' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:550: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_writel' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_writeq':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:558: error: '_spin_lock_irqsave' is static but used in inline function 't2_writeq' which is not static /home/mingo/tip/arch/alpha/include/asm/core_t2.h:565: error: '_spin_unlock_irqrestore' is static but used in inline function 't2_writeq' which is not static make[2]: *** [arch/alpha/kernel/sys_sable.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [arch/alpha/kernel] Error 2
make[1]: *** Waiting for unfinished jobs....
so i've dropped them for now.
Ingo
Quoted 46 lines · On Mon, 21 Sep 2009 09:43:52 +0200 Ingo Molnar <[email protected]> wrote:
Quoted 30 lines · * [email protected] <[email protected]> wrote:
From: David Kilroy <[email protected]>
When writing code for UP without
CONFIG_DEBUG_SPINLOCKit's easy to get the first argument to the spinlock/rwlock functions wrong. This is because the parameter is not actually used in this configuration.Typically you will only find out it's wrong
* by rebuilding withCONFIG_SMPorCONFIG_DEBUG_SPINLOCK
* after you've submitted your beautiful patch series.The first means a long wait, and the latter is a bit late.
Change the intermediate macros into inline functions.
Signed-off-by David Kilroy <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
include/linux/spinlock.h | 6 - include/linux/spinlock_api_up.h | 118 ++++++++++++++++++++++-------- 2 files changed, 92 insertions(+), 32 deletions(-)diff -puN
include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-buildsinclude/linux/spinlock.hinclude/linux/spinlock.h renamed from include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-builds +0
-0@@ -240,17 +240,17 @@ static inline void smp_mb__after_lock(vo#define spin_lock_irqsave (lock, flags) \ do { \include/linux/spinlock.h static inline void smp_mb__after_lock(vo · line 249
Quoted 10 lines
include/linux/spinlock.h renamed from include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-builds +2
-2typecheck(unsigned long, flags); \ -_spin_lock_irqsave (lock, flags); \ +_spin_lock_irqsave (lock, &flags); \ } while (0)#define read_lock_irqsave (lock, flags) \ do { \ typecheck(unsigned long, flags); \ - _read_lock_irqsave(lock, flags); \ + _read_lock_irqsave(lock, &flags); \ } while (0)these bits broke the Alpha build:
Quoted 2 lines
/home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_readb':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:451: error: '_spin_lock_irqsave' is static but used in inline function 't2_readb' which is not static
hm. What the heck does that mean?
__EXTERN_INLINE u8 t2_readb(const volatile void __iomem *xaddr)
Something to do with the extern-inline?
Do you have the .config? My alpha builds went OK.
Quoted 47 lines · Andrew Morton
Quoted 44 lines · On Mon, 21 Sep 2009 09:43:52 +0200 Ingo Molnar <[email protected]> wrote:
Quoted 30 lines · * [email protected] <[email protected]> wrote:
From: David Kilroy <[email protected]>
When writing code for UP without
CONFIG_DEBUG_SPINLOCKit's easy to get the first argument to the spinlock/rwlock functions wrong. This is because the parameter is not actually used in this configuration.Typically you will only find out it's wrong
* by rebuilding withCONFIG_SMPorCONFIG_DEBUG_SPINLOCK
* after you've submitted your beautiful patch series.The first means a long wait, and the latter is a bit late.
Change the intermediate macros into inline functions.
Signed-off-by David Kilroy <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
include/linux/spinlock.h | 6 - include/linux/spinlock_api_up.h | 118 ++++++++++++++++++++++-------- 2 files changed, 92 insertions(+), 32 deletions(-)diff -puN
include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-buildsinclude/linux/spinlock.hinclude/linux/spinlock.h renamed from include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-builds +0
-0@@ -240,17 +240,17 @@ static inline void smp_mb__after_lock(vo#define spin_lock_irqsave (lock, flags) \ do { \include/linux/spinlock.h static inline void smp_mb__after_lock(vo · line 249
Quoted 10 lines
include/linux/spinlock.h renamed from include/linux/spinlock.h~spinlocks-check-spinlock_t-rwlock_t-argument-type-on-non-smp-builds +2
-2typecheck(unsigned long, flags); \ -_spin_lock_irqsave (lock, flags); \ +_spin_lock_irqsave (lock, &flags); \ } while (0)#define read_lock_irqsave (lock, flags) \ do { \ typecheck(unsigned long, flags); \ - _read_lock_irqsave(lock, flags); \ + _read_lock_irqsave(lock, &flags); \ } while (0)these bits broke the Alpha build:
Quoted 8 lines
Quoted 2 lines
/home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function 't2_readb':/home/mingo/tip/arch/alpha/include/asm/core_t2.h:451: error: '_spin_lock_irqsave' is static but used in inline function 't2_readb' which is not statichm. What the heck does that mean?
__EXTERN_INLINEu8t2_readb(const volatile void __iomem *xaddr)Something to do with the extern-inline?
This came up the last time this went into Ingos tree. And yes, it's the extern inlines using the spinlock functions that causes the error.
Quoted 1 line
Do you have the .config? My alpha builds went OK.
Last I checked, you need to have:CONFIG_SMP=NCONFIG_DEBUG_SPINLOCK=N
The latter gets auto-selected, so I set:CONFIG_DEBUG_LOCK_ALLOC=NCONFIG_LOCK_STAT=NCONFIG_PROVE_LOCKING=NCONFIG_LOCK_STAT=N
Regards,
Dave.