Re: [PATCH RFC] 'spinlock/rwlock fixes' V3 [1/1]

From: Peter Chubb
Date: Thu Jan 20 2005 - 04:01:59 EST


>>>>> "Chris" == Chris Wedgwood <cw@xxxxxxxx> writes:

Chris> On Wed, Jan 19, 2005 at 07:01:04PM -0800, Andrew Morton wrote:

Chris> It still isn't enough to rid of the rwlock_read_locked and
Chris> rwlock_write_locked usage in kernel/spinlock.c as those are
Chris> needed for the cpu_relax() calls so we have to decide on
Chris> suitable names still...

I suggest reversing the sense of the macros, and having read_can_lock()
and write_can_lock()

Meaning:
read_can_lock() --- a read_lock() would have succeeded
write_can_lock() --- a write_lock() would have succeeded.

IA64 implementation:

#define read_can_lock(x) (*(volatile int *)x >= 0)
#define write_can_lock(x) (*(volatile int *)x == 0)

Then use them as
!read_can_lock(x)
where you want the old semantics. The compiler ought to be smart
enough to optimise the boolean ops.

---
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au
The technical we do immediately, the political takes *forever*



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/