rwlock_is_locked undefined for UP systems
PATCH 1/1 rwlock_is_locked undefined for UP systems
Hi,
I had to use rwlock_is_locked( ) with linux2.6 for kdb and noticed that
this routine to be undefined for UP. I have attached the patch for 2.6.1 below to return 0 for rwlock_is_locked( ) on UP systems. Please let me know.
Thanks
Prashanth
include/linux/spinlock.h +1 -0
@@ -176,6 +176,7 @@#endif #define rwlock_init (lock) do { (void)(lock); } while(0) +#define rwlock_is_locked (lock) ((void)(lock), 0)#define _raw_read_lock (lock) do { (void)(lock); } while(0)#define _raw_read_unlock (lock) do { (void)(lock); } while(0)#define _raw_write_lock (lock) do { (void)(lock); } while(0)
Quoted 5 lines · Prashanth T
Hi,
I had to userwlock_is_locked( )with linux2.6 for kdb and noticed that
this routine to be undefined for UP. I have attached the patch for 2.6.1 below to return 0 forrwlock_is_locked( )on UP systems.
Please let me know.
I consider any user of this on UP to be broken, just like UP use of spin_is_locked() is always a bug..... better a compiletime bug than a runtime bug I guess...
Quoted 10 lines · Arjan van de Ven
Quoted 5 lines · Prashanth T
Hi,
I had to userwlock_is_locked( )with linux2.6 for kdb and noticed that
this routine to be undefined for UP. I have attached the patch for 2.6.1 below to return 0 forrwlock_is_locked( )on UP systems.
Please let me know.I consider any user of this on UP to be broken, just like UP use of
spin_is_locked()is always a bug..... better a compiletime bug than a runtime bug I guess...
Then maybe a #error explaining this is in order ?
- Joe
Quoted 8 lines · Joe Thornber
Quoted 7 lines · Arjan van de Ven
Quoted 5 lines · Prashanth T
Hi,
I had to userwlock_is_locked( )with linux2.6 for kdb and noticed that
this routine to be undefined for UP. I have attached the patch for 2.6.1 below to return 0 forrwlock_is_locked( )on UP systems.
Please let me know.
Quoted 5 lines
Quoted 3 lines
I consider any user of this on UP to be broken, just like UP use of
spin_is_locked()is always a bug..... better a compiletime bug than a runtime bug I guess...Then maybe a #error explaining this is in order ?
So, if there is a function
void foo_locked(struct bar *obj)
{
/* check that we are called with obj's lock held */
BUG_ON(!rwlock_is_locked(&obj->lock));
/* proceed with obj. */
}it should now be changed to the
void foo_locked(struct bar *obj)
{
#ifdef CONFIG_SMP
BUG_ON(!rwlock_is_locked(&obj->lock));
#endif
/* proceed with obj. */
}?
Quoted 3 lines
- Joe
Nikita.
Quoted 1 line
Quoted 9 lines · Nikita Danilov
it should now be changed to the
void
foo_locked(struct bar *obj)
{#ifdef CONFIG_SMP BUG_ON(!rwlock_is_locked(&obj->lock)); #endif /* proceed with obj. */ }
You forgot preempt... ;)
Quoted 5 lines · Prashanth T
Hi,
I had to userwlock_is_locked( )with linux2.6 for kdb and noticed that
this routine to be undefined for UP. I have attached the patch for 2.6.1 below to return 0 forrwlock_is_locked( )on UP systems.
Please let me know.
we don't implement spin_is_locked on UP either because there's no really usefull return value. The lock will never be taken on !SMP && !PREEMPT, but OTOH it's also not needed, so any assert on will give false results. And the assert is probably the only thing that the _is_locked routines could used for sanely.
ok....I understand that rwlock_is_locked( ) is to be protected byCONFIG_SMP. But I was tempted when I saw spin_is_locked( )
to be returning zero for !SMP in include/linux/spinlock.h . Am I seeing something wrong here?
Quoted 20 lines · Christoph Hellwig
Quoted 7 lines · Prashanth T
Hi,
I had to userwlock_is_locked( )with linux2.6 for kdb and noticed that
this routine to be undefined for UP. I have attached the patch for 2.6.1 below to return 0 forrwlock_is_locked( )on UP systems. Please let me know.we don't implement
spin_is_lockedon UP either because there's no really usefull return value. The lock will never be taken on !SMP && !PREEMPT, but OTOH it's also not needed, so any assert on will give false results. And the assert is probably the only thing that the_is_lockedroutines could used for sanely.