spinlock-consolidation.patch
Subsystems (11)
Guys, I'm planning on sending this Linuswards in about two days time. There's never a right time for this sort of thing and there may be some relatively trivial breakage for architectures I don't test for. But it kills 1300 lines of code.
So. Last call, please...
From: Ingo Molnar <[email protected]>
This patch (written by me and also containing many suggestions of Arjan van de Ven) does a major cleanup of the spinlock code. It does the following things:
- consolidates and enhances the spinlock/rwlock debugging code
- simplifies the asm/spinlock.h files
- encapsulates the raw spinlock type and moves generic spinlock features (such as ->break_lock) into the generic code.
- cleans up the spinlock code hierarchy to get rid of the spaghetti.
Most notably there's now only a single variant of the debugging code, located in lib/spinlock_debug.c. (previously we had one SMP debugging variant per architecture, plus a separate generic one for UP builds)
Also, i've enhanced the rwlock debugging facility, it will now track write-owners. There is new spinlock-owner/CPU-tracking on SMP builds too. All locks have lockup detection now, which will work for both soft and hard spin/rwlock lockups.
The arch-level include files now only contain the minimally necessary subset of the spinlock code - all the rest that can be generalized now lives in the generic headers:
include/asm-i386/spinlock_types.h | 16 include/asm-x86_64/spinlock_types.h | 16
I have also split up the various spinlock variants into separate files, making it easier to see which does what. The new layout is:
SMP | UP ----------------------------|----------------------------------- asm/spinlock_types_smp.h | linux/spinlock_types_up.h linux/spinlock_types.h | linux/spinlock_types.h asm/spinlock_smp.h | linux/spinlock_up.h linux/spinlock_api_smp.h | linux/spinlock_api_up.h linux/spinlock.h | linux/spinlock.h
/*
* here's the role of the various spinlock/rwlock related include files:
*
* on SMP builds:
*
* asm/spinlock_types.h: contains the raw_spinlock_t/raw_rwlock_t and the
* initializers
*
* linux/spinlock_types.h:
* defines the generic type and initializers
*
* asm/spinlock.h: contains the __raw_spin_*()/etc. lowlevel
* implementations, mostly inline assembly code
*
* (also included on UP-debug builds:)
*
* linux/spinlock_api_smp.h:
* contains the prototypes for the _spin_*() APIs.
*
* linux/spinlock.h: builds the final spin_*() APIs.
*
* on UP builds:
*
* linux/spinlock_type_up.h:
* contains the generic, simplified UP spinlock type.
* (which is an empty structure on non-debug builds)
*
* linux/spinlock_types.h:
* defines the generic type and initializers
*
* linux/spinlock_up.h:
* contains the __raw_spin_*()/etc. version of UP * builds. (which are NOPs on non-debug, non-preempt * builds)
*
* (included on UP-non-debug builds:)
*
* linux/spinlock_api_up.h:
* builds the _spin_*() APIs.
*
* linux/spinlock.h: builds the final spin_*() APIs.
*/
All SMP and UP architectures are converted by this patch.
arm, i386, ia64, ppc, ppc64, s390/s390x, x64 was build-tested via crosscompilers. m32r, mips, sh, sparc, have not been tested yet, but should be mostly fine.
From: Grant Grundler <[email protected]>
Booted and lightly tested on a500-44 (64-bit, SMP kernel, dual CPU). Builds 32-bit SMP kernel (not booted or tested). I did not try to build non-SMP kernels. That should be trivial to fix up later if necessary.
I converted bit ops atomic_hash lock to raw_spinlock_t. Doing so avoids some ugly nesting of linux/*.h and asm/*.h files. Those particular locks are well tested and contained entirely inside arch specific code. I do NOT expect any new issues to arise with them.
If someone does ever need to use debug/metrics with them, then they will
need to unravel this hairball between spinlocks, atomic ops, and bit ops that exist only because parisc has exactly one atomic instruction: LDCW (load and clear word).
---
dev/null | 845 ----------------------------------- arch/alpha/kernel/alpha_ksyms.c | 9 arch/alpha/kernel/smp.c | 172 ------- arch/m32r/kernel/smp.c | 48 - arch/mips/lib/dec_and_lock.c | 8 arch/parisc/lib/Makefile | 2 arch/parisc/lib/bitops.c | 4 arch/ppc/lib/Makefile | 1 arch/ppc/lib/dec_and_lock.c | 8 arch/ppc64/lib/dec_and_lock.c | 8 arch/ppc64/lib/locks.c | 14 arch/s390/lib/spinlock.c | 12 arch/sparc/kernel/sparc_ksyms.c | 10 arch/sparc/lib/Makefile | 2 arch/sparc64/kernel/process.c | 5 arch/sparc64/kernel/sparc64_ksyms.c | 5 arch/sparc64/lib/Makefile | 1 fs/buffer.c | 1 include/asm-alpha/spinlock.h | 96 +-- include/asm-alpha/spinlock_types.h | 20 include/asm-arm/spinlock.h | 54 -- include/asm-arm/spinlock_types.h | 20 include/asm-i386/spinlock.h | 200 ++------ include/asm-i386/spinlock_types.h | 20 include/asm-ia64/spinlock.h | 69 +- include/asm-ia64/spinlock_types.h | 21 include/asm-m32r/spinlock.h | 127 +---- include/asm-m32r/spinlock_types.h | 23 include/asm-mips/spinlock.h | 75 +-- include/asm-mips/spinlock_types.h | 20 include/asm-parisc/atomic.h | 12 include/asm-parisc/bitops.h | 2 include/asm-parisc/cacheflush.h | 1 include/asm-parisc/processor.h | 1 include/asm-parisc/spinlock.h | 163 +----- include/asm-parisc/spinlock_types.h | 21 include/asm-parisc/system.h | 24 include/asm-ppc/spinlock.h | 89 --- include/asm-ppc/spinlock_types.h | 20 include/asm-ppc64/spinlock.h | 191 +++---- include/asm-ppc64/spinlock_types.h | 20 include/asm-s390/spinlock.h | 63 -- include/asm-s390/spinlock_types.h | 21 include/asm-sh/spinlock.h | 61 -- include/asm-sh/spinlock_types.h | 22 include/asm-sparc/spinlock.h | 140 ----- include/asm-sparc/spinlock_types.h | 20 include/asm-sparc64/spinlock.h | 160 ------ include/asm-sparc64/spinlock_types.h | 20 include/asm-x86_64/spinlock.h | 164 +----- include/asm-x86_64/spinlock_types.h | 20 include/linux/bit_spinlock.h | 77 +++ include/linux/jbd.h | 1 include/linux/spinlock.h | 629 +++++--------------------- include/linux/spinlock_api_smp.h | 57 ++ include/linux/spinlock_api_up.h | 80 +++ include/linux/spinlock_types.h | 67 ++ include/linux/spinlock_types_up.h | 51 ++ include/linux/spinlock_up.h | 74 +++ kernel/Makefile | 1 kernel/sched.c | 4 kernel/spinlock.c | 15 lib/Makefile | 1 lib/dec_and_lock.c | 3 lib/kernel_lock.c | 3 lib/spinlock_debug.c | 257 ++++++++++ 66 files changed, 1592 insertions(+), 2863 deletions(-)
arch/alpha/kernel/alpha_ksyms.c renamed from arch/alpha/kernel/alpha_ksyms.c~spinlock-consolidation +0 -9
@@ -185,15 +185,6 @@ EXPORT_SYMBOL(smp_num_cpus);EXPORT_SYMBOL (smp_call_function);EXPORT_SYMBOL (smp_call_function_on_cpu);EXPORT_SYMBOL (_atomic_dec_and_lock); -#ifdef CONFIG_DEBUG_SPINLOCK -EXPORT_SYMBOL (_raw_spin_unlock); -EXPORT_SYMBOL (debug_spin_lock); -EXPORT_SYMBOL (debug_spin_trylock); -#endif -#ifdef CONFIG_DEBUG_RWLOCK -EXPORT_SYMBOL (_raw_write_lock); -EXPORT_SYMBOL (_raw_read_lock); -#endif EXPORT_SYMBOL (cpu_present_mask);#endif /* CONFIG_SMP */
arch/alpha/kernel/smp.c renamed from arch/alpha/kernel/smp.c~spinlock-consolidation +0 -172
175 lines not on this page · raw message
arch/m32r/kernel/smp.c renamed from arch/m32r/kernel/smp.c~spinlock-consolidation +12 -36
69 lines not on this page · raw message
arch/mips/lib/dec_and_lock.c renamed from arch/mips/lib/dec_and_lock.c~spinlock-consolidation +0 -8
@@ -20,14 +20,7 @@* has a cmpxchg, and where atomic->value is an int holding * the value of the atomic (i.e. the high bits aren't used * for a lock or anything like that). -* -* N.B. ATOMIC_DEC_AND_LOCK gets defined in include/linux/spinlock.h -* if spinlocks are empty and thus atomic_dec_and_lock is defined -* to be atomic_dec_and_test - in that case we don't need it -* defined here as well. */ - -#ifndef ATOMIC_DEC_AND_LOCK int _atomic_dec_and_lock (atomic_t *atomic,spinlock_t *lock) {int counter;
@@ -52,4 +45,3 @@ int _atomic_dec_and_lock(atomic_t *atomi }EXPORT_SYMBOL (_atomic_dec_and_lock); -#endif /* ATOMIC_DEC_AND_LOCK */
arch/parisc/lib/bitops.c renamed from arch/parisc/lib/bitops.c~spinlock-consolidation +2 -2
@@ -13,8 +13,8 @@#include <asm/atomic.h> #ifdef CONFIG_SMP -spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = { - [0 ... (ATOMIC_HASH_SIZE -1 )] =SPIN_LOCK_UNLOCKED +raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = { + [0 ... (ATOMIC_HASH_SIZE -1 )] = __RAW_SPIN_LOCK_UNLOCKED };#endif
arch/parisc/lib/debuglocks.c deleted +0 -277
277 lines not on this page · raw message
arch/parisc/lib/Makefile renamed from arch/parisc/lib/Makefile~spinlock-consolidation +0 -2
@@ -5,5 +5,3 @@ lib-y := lusercopy.o bitops.o checksum.o io.o memset.o fixup.o memcpy.o obj-y := iomap.o - -lib-$(CONFIG_SMP) += debuglocks.o
arch/ppc64/lib/dec_and_lock.c renamed from arch/ppc64/lib/dec_and_lock.c~spinlock-consolidation +0 -8
@@ -20,14 +20,7 @@* has a cmpxchg, and where atomic->value is an int holding * the value of the atomic (i.e. the high bits aren't used * for a lock or anything like that). -* -* N.B. ATOMIC_DEC_AND_LOCK gets defined in include/linux/spinlock.h -* if spinlocks are empty and thus atomic_dec_and_lock is defined -* to be atomic_dec_and_test - in that case we don't need it -* defined here as well. */ - -#ifndef ATOMIC_DEC_AND_LOCK int _atomic_dec_and_lock (atomic_t *atomic,spinlock_t *lock) {int counter;
@@ -52,4 +45,3 @@ int _atomic_dec_and_lock(atomic_t *atomi }EXPORT_SYMBOL (_atomic_dec_and_lock); -#endif /* ATOMIC_DEC_AND_LOCK */
arch/ppc64/lib/locks.c renamed from arch/ppc64/lib/locks.c~spinlock-consolidation +7 -7
@@ -23,12 +23,12 @@/* waiting for a spinlock... */ #if defined(CONFIG_PPC_SPLPAR ) || defined(CONFIG_PPC_ISERIES ) -void __spin_yield (spinlock_t *lock) +void __spin_yield (raw_spinlock_t *lock) {unsigned int lock_value, holder_cpu, yield_count;struct paca_struct *holder_paca; - lock_value = lock->lock; + lock_value = lock->slock;if (lock_value ==0 )return ; holder_cpu = lock_value &0xffff ;
@@ -38,7 +38,7 @@ void __spin_yield(spinlock_t *lock)if ((yield_count &1 ) ==0 )return ;/* virtual cpu is currently running */ rmb (); -if (lock->lock != lock_value) +if (lock->slock != lock_value)return ;/* something has changed */ #ifdef CONFIG_PPC_ISERIES HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc,
@@ -54,7 +54,7 @@ void __spin_yield(spinlock_t *lock)* This turns out to be the same for read and write locks, since * we only know the holder if it is write-locked. */ -void __rw_yield (rwlock_t *rw) +void __rw_yield (raw_rwlock_t *rw) {int lock_value;unsigned int holder_cpu, yield_count;
@@ -82,9 +82,9 @@ void __rw_yield(rwlock_t *rw) }#endif -void spin_unlock_wait (spinlock_t *lock) +void __raw_spin_unlock_wait (raw_spinlock_t *lock) { -while (lock->lock) { +while (lock->slock) {HMT_low ();if (SHARED_PROCESSOR )__spin_yield (lock);
@@ -92,4 +92,4 @@ void spin_unlock_wait(spinlock_t *lock)HMT_medium (); } -EXPORT_SYMBOL (spin_unlock_wait); +EXPORT_SYMBOL (__raw_spin_unlock_wait);
arch/ppc/lib/dec_and_lock.c renamed from arch/ppc/lib/dec_and_lock.c~spinlock-consolidation +0 -8
@@ -11,14 +11,7 @@* has a cmpxchg, and where atomic->value is an int holding * the value of the atomic (i.e. the high bits aren't used * for a lock or anything like that). -* -* N.B. ATOMIC_DEC_AND_LOCK gets defined in include/linux/spinlock.h -* if spinlocks are empty and thus atomic_dec_and_lock is defined -* to be atomic_dec_and_test - in that case we don't need it -* defined here as well. */ - -#ifndef ATOMIC_DEC_AND_LOCK int _atomic_dec_and_lock (atomic_t *atomic,spinlock_t *lock) {int counter;
@@ -43,4 +36,3 @@ int _atomic_dec_and_lock(atomic_t *atomi }EXPORT_SYMBOL (_atomic_dec_and_lock); -#endif /* ATOMIC_DEC_AND_LOCK */
arch/ppc/lib/Makefile renamed from arch/ppc/lib/Makefile~spinlock-consolidation +0 -1
@@ -4,6 +4,5 @@ obj-y := checksum.o string.o strcase.o dec_and_lock.o div64.o -obj-$(CONFIG_SMP) += locks.o obj-$(CONFIG_8xx) += rheap.o obj-$(CONFIG_CPM2) += rheap.o
arch/s390/lib/spinlock.c renamed from arch/s390/lib/spinlock.c~spinlock-consolidation +6 -6
@@ -36,7 +36,7 @@ _diag44(void) }void -_raw_spin_lock_wait (spinlock_t *lp,unsigned int pc) +_raw_spin_lock_wait (raw_spinlock_t *lp,unsigned int pc) {int count = spin_retry;
@@ -53,7 +53,7 @@ _raw_spin_lock_wait(spinlock_t *lp, unsiEXPORT_SYMBOL (_raw_spin_lock_wait);int -_raw_spin_trylock_retry (spinlock_t *lp,unsigned int pc) +_raw_spin_trylock_retry (raw_spinlock_t *lp,unsigned int pc) {int count = spin_retry;
@@ -67,7 +67,7 @@ _raw_spin_trylock_retry(spinlock_t *lp,EXPORT_SYMBOL (_raw_spin_trylock_retry);void -_raw_read_lock_wait (rwlock_t *rw) +_raw_read_lock_wait (raw_rwlock_t *rw) {unsigned int old;int count = spin_retry;
@@ -86,7 +86,7 @@ _raw_read_lock_wait(rwlock_t *rw)EXPORT_SYMBOL (_raw_read_lock_wait);int -_raw_read_trylock_retry (rwlock_t *rw) +_raw_read_trylock_retry (raw_rwlock_t *rw) {unsigned int old;int count = spin_retry;
@@ -102,7 +102,7 @@ _raw_read_trylock_retry(rwlock_t *rw)EXPORT_SYMBOL (_raw_read_trylock_retry);void -_raw_write_lock_wait (rwlock_t *rw) +_raw_write_lock_wait (raw_rwlock_t *rw) {int count = spin_retry;
@@ -119,7 +119,7 @@ _raw_write_lock_wait(rwlock_t *rw)EXPORT_SYMBOL (_raw_write_lock_wait);int -_raw_write_trylock_retry (rwlock_t *rw) +_raw_write_trylock_retry (raw_rwlock_t *rw) {int count = spin_retry;
arch/sparc64/kernel/process.c renamed from arch/sparc64/kernel/process.c~spinlock-consolidation +0 -5
@@ -607,11 +607,6 @@ int copy_thread(int nr, unsigned long clstruct thread_info *t = p->thread_info;char *child_trap_frame; -#ifdef CONFIG_DEBUG_SPINLOCK - p->thread.smp_lock_count =0 ; - p->thread.smp_lock_pc =0 ; -#endif -/* Calculate offset to stack_frame & pt_regs */ child_trap_frame = ((char *)t) + (THREAD_SIZE - (TRACEREG_SZ +STACKFRAME_SZ ));memcpy (child_trap_frame, (((struct sparc_stackf *)regs)-1 ), (TRACEREG_SZ +STACKFRAME_SZ ));
arch/sparc64/kernel/sparc64_ksyms.c renamed from arch/sparc64/kernel/sparc64_ksyms.c~spinlock-consolidation +0 -5
@@ -115,17 +115,12 @@ EXPORT_PER_CPU_SYMBOL(__cpu_data);/* used by various drivers */ #ifdef CONFIG_SMP -#ifndef CONFIG_DEBUG_SPINLOCK /* Out of line rw-locking implementation. */ EXPORT_SYMBOL (__read_lock);EXPORT_SYMBOL (__read_unlock);EXPORT_SYMBOL (__write_lock);EXPORT_SYMBOL (__write_unlock);EXPORT_SYMBOL (__write_trylock); -/* Out of line spin-locking implementation. */ -EXPORT_SYMBOL (_raw_spin_lock); -EXPORT_SYMBOL (_raw_spin_lock_flags); -#endif /* Hard IRQ locking */ EXPORT_SYMBOL (synchronize_irq);
arch/sparc64/lib/debuglocks.c deleted +0 -366
366 lines not on this page · raw message
arch/sparc64/lib/Makefile renamed from arch/sparc64/lib/Makefile~spinlock-consolidation +0 -1
@@ -14,7 +14,6 @@ lib-y := PeeCeeI.o copy_page.o clear_pag copy_in_user.o user_fixup.o memmove.o \ mcount.o ipcsum.o rwsem.o xor.o find_bit.o delay.o -lib-$(CONFIG_DEBUG_SPINLOCK) += debuglocks.o lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o obj-y += iomap.o
arch/sparc/kernel/sparc_ksyms.c renamed from arch/sparc/kernel/sparc_ksyms.c~spinlock-consolidation +0 -10
@@ -114,17 +114,7 @@ DOT_ALIAS2(unsigned, urem, unsigned, uns/* used by various drivers */ EXPORT_SYMBOL (sparc_cpu_model);EXPORT_SYMBOL (kernel_thread); -#ifdef CONFIG_DEBUG_SPINLOCK #ifdef CONFIG_SMP -EXPORT_SYMBOL (_do_spin_lock); -EXPORT_SYMBOL (_do_spin_unlock); -EXPORT_SYMBOL (_spin_trylock); -EXPORT_SYMBOL (_do_read_lock); -EXPORT_SYMBOL (_do_read_unlock); -EXPORT_SYMBOL (_do_write_lock); -EXPORT_SYMBOL (_do_write_unlock); -#endif -#else // XXX find what uses (or used) these. EXPORT_SYMBOL (___rw_read_enter);EXPORT_SYMBOL (___rw_read_exit);
arch/sparc/lib/debuglocks.c deleted +0 -202
202 lines not on this page · raw message
arch/sparc/lib/Makefile renamed from arch/sparc/lib/Makefile~spinlock-consolidation +0 -2
@@ -9,5 +9,3 @@ lib-y := mul.o rem.o sdiv.o udiv.o umul. strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \ copy_user.o locks.o atomic.o atomic32.o bitops.o \ lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o - -lib-$(CONFIG_DEBUG_SPINLOCK) += debuglocks.o
fs/buffer.c renamed from fs/buffer.c~spinlock-consolidation +1 -0
@@ -40,6 +40,7 @@#include <linux/cpu.h> #include <linux/bitops.h> #include <linux/mpage.h> +#include <linux/bit_spinlock.h> static int fsync_buffers_list (spinlock_t *lock,struct list_head *list);static void invalidate_bh_lrus (void );
include/asm-alpha/spinlock.h renamed from include/asm-alpha/spinlock.h~spinlock-consolidation +27 -69
181 lines not on this page · raw message
include/asm-alpha/spinlock_types.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef _ALPHA_SPINLOCK_TYPES_H +#define _ALPHA_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile unsigned int lock; +}raw_spinlock_t ; + +#define __RAW_SPIN_LOCK_UNLOCKED { 0 } + +typedef struct { +volatile unsigned int lock; +}raw_rwlock_t ; + +#define __RAW_RW_LOCK_UNLOCKED { 0 } + +#endif
include/asm-arm/spinlock.h renamed from include/asm-arm/spinlock.h~spinlock-consolidation +19 -35
111 lines not on this page · raw message
include/asm-arm/spinlock_types.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __ASM_SPINLOCK_TYPES_H +#define __ASM_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile unsigned int lock; +}raw_spinlock_t ; + +#define __RAW_SPIN_LOCK_UNLOCKED { 0 } + +typedef struct { +volatile unsigned int lock; +}raw_rwlock_t ; + +#define __RAW_RW_LOCK_UNLOCKED { 0 } + +#endif
include/asm-i386/spinlock.h renamed from include/asm-i386/spinlock.h~spinlock-consolidation +70 -130
292 lines not on this page · raw message
include/asm-i386/spinlock_types.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __ASM_SPINLOCK_TYPES_H +#define __ASM_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile unsigned int slock; +}raw_spinlock_t ; + +#define __RAW_SPIN_LOCK_UNLOCKED { 1 } + +typedef struct { +volatile unsigned int lock; +}raw_rwlock_t ; + +#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS } + +#endif
include/asm-ia64/spinlock.h renamed from include/asm-ia64/spinlock.h~spinlock-consolidation +26 -43
155 lines not on this page · raw message
include/asm-ia64/spinlock_types.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef _ASM_IA64_SPINLOCK_TYPES_H +#define _ASM_IA64_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile unsigned int lock; +}raw_spinlock_t ; + +#define __RAW_SPIN_LOCK_UNLOCKED { 0 } + +typedef struct { +volatile unsigned int read_counter :31 ; +volatile unsigned int write_lock :1 ; +}raw_rwlock_t ; + +#define __RAW_RW_LOCK_UNLOCKED { 0, 0 } + +#endif
include/asm-m32r/spinlock.h renamed from include/asm-m32r/spinlock.h~spinlock-consolidation +30 -97
224 lines not on this page · raw message
include/asm-m32r/spinlock_types.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef _ASM_M32R_SPINLOCK_TYPES_H +#define _ASM_M32R_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile int slock; +}raw_spinlock_t ; + +#define __RAW_SPIN_LOCK_UNLOCKED { 1 } + +typedef struct { +volatile int lock; +}raw_rwlock_t ; + +#define RW_LOCK_BIAS 0x01000000 +#define RW_LOCK_BIAS_STR "0x01000000" + +#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS } + +#endif
include/asm-mips/spinlock.h renamed from include/asm-mips/spinlock.h~spinlock-consolidation +27 -48
201 lines not on this page · raw message
include/asm-mips/spinlock_types.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef _ASM_SPINLOCK_TYPES_H +#define _ASM_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile unsigned int lock; +}raw_spinlock_t ; + +#define __RAW_SPIN_LOCK_UNLOCKED { 0 } + +typedef struct { +volatile unsigned int lock; +}raw_rwlock_t ; + +#define __RAW_RW_LOCK_UNLOCKED { 0 } + +#endif
include/asm-parisc/atomic.h renamed from include/asm-parisc/atomic.h~spinlock-consolidation +6 -6
@@ -24,19 +24,19 @@# define ATOMIC_HASH_SIZE 4# define ATOMIC_HASH (a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ])) -extern spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned; +extern raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned; -/* Can't use _raw_spin_lock_irq because of #include problems, so +/* Can't use raw_spin_lock_irq because of #include problems, so * this is the substitute */ #define _atomic_spin_lock_irqsave (l,f) do { \ - spinlock_t *s = ATOMIC_HASH(l); \ + raw_spinlock_t *s = ATOMIC_HASH(l); \ local_irq_save(f); \ - _raw_spin_lock(s); \ + __raw_spin_lock(s); \ } while(0)#define _atomic_spin_unlock_irqrestore (l,f) do { \ - spinlock_t *s = ATOMIC_HASH(l); \ - _raw_spin_unlock(s); \ + raw_spinlock_t *s = ATOMIC_HASH(l); \ + __raw_spin_unlock(s); \ local_irq_restore(f); \ } while(0)
include/asm-parisc/bitops.h renamed from include/asm-parisc/bitops.h~spinlock-consolidation +1 -1
@@ -2,7 +2,7 @@#define _PARISC_BITOPS_H#include <linux/compiler.h> -#include <asm/system.h> +#include <asm/spinlock.h> #include <asm/byteorder.h> #include <asm/atomic.h>
include/asm-parisc/cacheflush.h renamed from include/asm-parisc/cacheflush.h~spinlock-consolidation +1 -0
@@ -3,6 +3,7 @@#include <linux/config.h> #include <linux/mm.h> +#include <asm/cache.h> /* for flush_user_dcache_range_asm() proto */ /* The usual comment is "Caches aren't brain-dead on the <architecture>". * Unfortunately, that doesn't apply to PA-RISC. */
include/asm-parisc/processor.h renamed from include/asm-parisc/processor.h~spinlock-consolidation +1 -0
@@ -11,6 +11,7 @@#ifndef __ASSEMBLY__#include <linux/config.h> #include <linux/threads.h> +#include <linux/spinlock_types.h> #include <asm/hardware.h> #include <asm/page.h>
include/asm-parisc/spinlock.h renamed from include/asm-parisc/spinlock.h~spinlock-consolidation +28 -135
263 lines not on this page · raw message
include/asm-parisc/spinlock_types.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef __ASM_SPINLOCK_TYPES_H +#define __ASM_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile unsigned int lock[4 ]; +}raw_spinlock_t ; + +#define __RAW_SPIN_LOCK_UNLOCKED { { 1, 1, 1, 1 } } + +typedef struct { +raw_spinlock_t lock; +volatile int counter; +}raw_rwlock_t ; + +#define __RAW_RW_LOCK_UNLOCKED { __RAW_SPIN_LOCK_UNLOCKED, 0 } + +#endif
include/asm-parisc/system.h renamed from include/asm-parisc/system.h~spinlock-consolidation +1 -23
@@ -160,29 +160,7 @@ static inline void set_eiem(unsigned lon })#ifdef CONFIG_SMP -/* -* Your basic SMP spinlocks, allowing only a single CPU anywhere -*/ - -typedef struct { -volatile unsigned int lock[4 ]; -#ifdef CONFIG_DEBUG_SPINLOCK -unsigned long magic; -volatile unsigned int babble; -const char *module; -char *bfile; -int bline; -int oncpu; -void *previous; -struct task_struct * task; -#endif -#ifdef CONFIG_PREEMPT -unsigned int break_lock; -#endif -}spinlock_t ; - -#define __lock_aligned __attribute__((__section__(".data.lock_aligned"))) - +# define __lock_aligned __attribute__((__section__(".data.lock_aligned")))#endif #define KERNEL_START (0x10100000 - 0x1000)
include/asm-ppc64/spinlock.h renamed from include/asm-ppc64/spinlock.h~spinlock-consolidation +86 -105
14 lines not on this page · raw message
include/asm-ppc64/spinlock_types.h new file +20 -0
Lines of this file are not shown. View the raw message.
include/asm-ppc/spinlock.h renamed from include/asm-ppc/spinlock.h~spinlock-consolidation +19 -70
89 lines not on this page · raw message
include/asm-ppc/spinlock_types.h new file +20 -0
Lines of this file are not shown. View the raw message.
include/asm-s390/spinlock.h renamed from include/asm-s390/spinlock.h~spinlock-consolidation +23 -40
63 lines not on this page · raw message
include/asm-s390/spinlock_types.h new file +21 -0
Lines of this file are not shown. View the raw message.
include/asm-sh/spinlock.h renamed from include/asm-sh/spinlock.h~spinlock-consolidation +20 -41
61 lines not on this page · raw message
include/asm-sh/spinlock_types.h new file +22 -0
Lines of this file are not shown. View the raw message.
include/asm-sparc64/spinlock.h renamed from include/asm-sparc64/spinlock.h~spinlock-consolidation +22 -138
160 lines not on this page · raw message
include/asm-sparc64/spinlock_types.h new file +20 -0
Lines of this file are not shown. View the raw message.
include/asm-sparc/spinlock.h renamed from include/asm-sparc/spinlock.h~spinlock-consolidation +21 -119
140 lines not on this page · raw message
include/asm-sparc/spinlock_types.h new file +20 -0
Lines of this file are not shown. View the raw message.
include/asm-x86_64/spinlock.h renamed from include/asm-x86_64/spinlock.h~spinlock-consolidation +42 -122
164 lines not on this page · raw message
include/asm-x86_64/spinlock_types.h new file +20 -0
Lines of this file are not shown. View the raw message.
include/linux/bit_spinlock.h new file +77 -0
77 lines not on this page · raw message
include/linux/jbd.h renamed from include/linux/jbd.h~spinlock-consolidation +1 -0
Lines of this file are not shown. View the raw message.
include/linux/spinlock_api_smp.h new file +57 -0
57 lines not on this page · raw message
include/linux/spinlock_api_up.h new file +80 -0
80 lines not on this page · raw message
include/linux/spinlock.h renamed from include/linux/spinlock.h~spinlock-consolidation +126 -503
629 lines not on this page · raw message
include/linux/spinlock_types.h new file +67 -0
67 lines not on this page · raw message
include/linux/spinlock_types_up.h new file +51 -0
51 lines not on this page · raw message
include/linux/spinlock_up.h new file +74 -0
74 lines not on this page · raw message
kernel/Makefile renamed from kernel/Makefile~spinlock-consolidation +1 -0
Lines of this file are not shown. View the raw message.
kernel/sched.c renamed from kernel/sched.c~spinlock-consolidation +4 -0
Lines of this file are not shown. View the raw message.
kernel/spinlock.c renamed from kernel/spinlock.c~spinlock-consolidation +9 -6
Lines of this file are not shown. View the raw message.
lib/dec_and_lock.c renamed from lib/dec_and_lock.c~spinlock-consolidation +0 -3
Lines of this file are not shown. View the raw message.
lib/kernel_lock.c renamed from lib/kernel_lock.c~spinlock-consolidation +1 -2
Lines of this file are not shown. View the raw message.
lib/Makefile renamed from lib/Makefile~spinlock-consolidation +1 -0
Lines of this file are not shown. View the raw message.
lib/spinlock_debug.c new file +257 -0
257 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
_
Part of the diff is not shown here. View the raw message.
David S. Miller
maintainerYes, please put this in, I was about to recommend that you do this in fact :-)
Hi,
Quoted 4 lines · Andrew Morton
include/linux/spinlock_api_smp.h | 57 ++ include/linux/spinlock_api_up.h | 80 +++ include/linux/spinlock_types_up.h | 51 ++ include/linux/spinlock_up.h | 74 +++
These are rather small files and not useful outside of <linux/spinlock.h>/<linux/spinlock_types.h>. Is it really needed to keep these separate?
bye, Roman
Quoted 4 lines · Andrew Morton
Guys, I'm planning on sending this Linuswards in about two days time. There's never a right time for this sort of thing and there may be some relatively trivial breakage for architectures I don't test for. But it kills 1300 lines of code.
the patch goes far beyond code reduction effects: the patch also unifies and centralizes all known spinlock-debugging features, which improves every architecture. E.g. on x86 we can now detect spinlock deadlocks even without the NMI watchdog. Even the architecture with the most advanced lowlevel spinlock-debugging framework (Sparc) gets improved a bit by this [by getting additional rwlock debugging code].
If i missed any spinlock-debugging cleverness then please holler and i'll add it to the generic code.
Ingo
ps. also, with this patch the ATOMIC_DEC_AND_LOCK uglinesses have
finally become history
ps2. and PREEMPT_RT gets a central spinlock type to fiddle with ;-)