* [PATCH] rwlock_is_locked undefined for UP systems
@ 2004-01-16 13:45 Prashanth T
2004-01-16 13:55 ` Arjan van de Ven
2004-01-16 14:09 ` Christoph Hellwig
0 siblings, 2 replies; 7+ messages in thread
From: Prashanth T @ 2004-01-16 13:45 UTC (permalink / raw)
To: rml; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 253 bytes --]
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
[-- Attachment #2: rwlock-check-UP.patch --]
[-- Type: text/plain, Size: 585 bytes --]
diff -urN linux-2.6.1/include/linux/spinlock.h linux-2.6.1-rwlock-patch/include/linux/spinlock.h
--- linux-2.6.1/include/linux/spinlock.h 2004-01-09 12:29:33.000000000 +0530
+++ linux-2.6.1-rwlock-patch/include/linux/spinlock.h 2004-01-16 18:15:10.000000000 +0530
@@ -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)
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] rwlock_is_locked undefined for UP systems
2004-01-16 13:45 [PATCH] rwlock_is_locked undefined for UP systems Prashanth T
@ 2004-01-16 13:55 ` Arjan van de Ven
2004-01-16 14:53 ` Joe Thornber
2004-01-16 14:09 ` Christoph Hellwig
1 sibling, 1 reply; 7+ messages in thread
From: Arjan van de Ven @ 2004-01-16 13:55 UTC (permalink / raw)
To: Prashanth T; +Cc: rml, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 461 bytes --]
On Fri, 2004-01-16 at 14:45, Prashanth T wrote:
> 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.
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...
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rwlock_is_locked undefined for UP systems
2004-01-16 13:55 ` Arjan van de Ven
@ 2004-01-16 14:53 ` Joe Thornber
2004-01-16 15:14 ` Nikita Danilov
0 siblings, 1 reply; 7+ messages in thread
From: Joe Thornber @ 2004-01-16 14:53 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Prashanth T, rml, linux-kernel
On Fri, Jan 16, 2004 at 02:55:50PM +0100, Arjan van de Ven wrote:
> On Fri, 2004-01-16 at 14:45, Prashanth T wrote:
> > 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.
>
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rwlock_is_locked undefined for UP systems
2004-01-16 14:53 ` Joe Thornber
@ 2004-01-16 15:14 ` Nikita Danilov
2004-01-16 18:10 ` Mike Fedyk
0 siblings, 1 reply; 7+ messages in thread
From: Nikita Danilov @ 2004-01-16 15:14 UTC (permalink / raw)
To: Joe Thornber; +Cc: Arjan van de Ven, Prashanth T, rml, linux-kernel
Joe Thornber writes:
> On Fri, Jan 16, 2004 at 02:55:50PM +0100, Arjan van de Ven wrote:
> > On Fri, 2004-01-16 at 14:45, Prashanth T wrote:
> > > 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.
> >
> > 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. */
}
?
>
> - Joe
>
Nikita.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rwlock_is_locked undefined for UP systems
2004-01-16 13:45 [PATCH] rwlock_is_locked undefined for UP systems Prashanth T
2004-01-16 13:55 ` Arjan van de Ven
@ 2004-01-16 14:09 ` Christoph Hellwig
2004-01-19 6:12 ` Prashanth T
1 sibling, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2004-01-16 14:09 UTC (permalink / raw)
To: Prashanth T; +Cc: rml, linux-kernel
On Fri, Jan 16, 2004 at 07:15:11PM +0530, Prashanth T wrote:
> 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.
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rwlock_is_locked undefined for UP systems
2004-01-16 14:09 ` Christoph Hellwig
@ 2004-01-19 6:12 ` Prashanth T
0 siblings, 0 replies; 7+ messages in thread
From: Prashanth T @ 2004-01-19 6:12 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: rml, linux-kernel
ok....I understand that rwlock_is_locked( ) is to be protected by
CONFIG_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?
Christoph Hellwig wrote:
>On Fri, Jan 16, 2004 at 07:15:11PM +0530, Prashanth T wrote:
>
>
>>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.
>>
>>
>
>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.
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-01-19 6:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-16 13:45 [PATCH] rwlock_is_locked undefined for UP systems Prashanth T
2004-01-16 13:55 ` Arjan van de Ven
2004-01-16 14:53 ` Joe Thornber
2004-01-16 15:14 ` Nikita Danilov
2004-01-16 18:10 ` Mike Fedyk
2004-01-16 14:09 ` Christoph Hellwig
2004-01-19 6:12 ` Prashanth T
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox