X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=Documentation%2Fspinlocks.txt;h=619699dde5938b64c6d63e1059cf0ed702c128af;hb=22c1c7879d60d1419672ff9f6d162e89fe3cc1a1;hp=c2122996631e4d413fffe6be3d1173f827a8649c;hpb=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2;p=linux-2.6-omap-h63xx.git diff --git a/Documentation/spinlocks.txt b/Documentation/spinlocks.txt index c2122996631..619699dde59 100644 --- a/Documentation/spinlocks.txt +++ b/Documentation/spinlocks.txt @@ -1,7 +1,34 @@ -UPDATE March 21 2005 Amit Gud +SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and +are hence deprecated. -Macros SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED are deprecated and will be -removed soon. So for any new code dynamic initialization should be used: +Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or +__SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate for static +initialization. + +Most of the time, you can simply turn: + + static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED; + +into: + + static DEFINE_SPINLOCK(xxx_lock); + +Static structure member variables go from: + + struct foo bar { + .lock = SPIN_LOCK_UNLOCKED; + }; + +to: + + struct foo bar { + .lock = __SPIN_LOCK_UNLOCKED(bar.lock); + }; + +Declaration of static rw_locks undergo a similar transformation. + +Dynamic initialization, when necessary, may be performed as +demonstrated below. spinlock_t xxx_lock; rwlock_t xxx_rw_lock; @@ -9,18 +36,15 @@ removed soon. So for any new code dynamic initialization should be used: static int __init xxx_init(void) { spin_lock_init(&xxx_lock); - rw_lock_init(&xxx_rw_lock); + rwlock_init(&xxx_rw_lock); ... } module_init(xxx_init); -Reasons for deprecation - - it hurts automatic lock validators - - it becomes intrusive for the realtime preemption patches - -Following discussion is still valid, however, with the dynamic initialization -of spinlocks instead of static. +The following discussion is still valid, however, with the dynamic +initialization of spinlocks or with DEFINE_SPINLOCK, etc., used +instead of SPIN_LOCK_UNLOCKED. -----------------------