_raw_write_trylock() missing
When I try to build 2.5.59 for an SMP machine, I see that
_raw_write_trylock() is undefined. As the read-write spin locks are
all implemented as magic assembler, I don't feel competent to create it...
Peter C
Quoted 8 lines · Peter Chubb
When I try to build 2.5.59 for an SMP machine, I see that
_raw_write_trylock()is undefined. As the read-write spin locks are
all implemented as magic assembler, I don't feel competent to create it...Peter C
Hello,
Here is an implementation of "_raw_write_trylock_ " needed for preemption support with SMP. I tested it on a 2.5.59 kernel with 2 Itaniums. It seems to work.
As I'm not used to deal with ia64 assembler (it's my first try), it would be better if someone could check the code.
What the macro is doing : (at least, what I think it is doing)
- if the actual lock value is equal to "0",
change the lock value to "00.....0001" else do nothing
The value of the macro is 0 if the lock value has been changed and different from 0 in other cases.
The code for this : (in include/asm-ia64/spinlock.h)
#define _raw_write_trylock(rw) \
({ \
register long result; \
\
__asm__ __volatile__ ( \
"mov ar.ccv = r0\n" \
"dep r29 = -1, r0, 31, 1\n" \
";;\n" \
"1:\n" \
"cmpxchg4.acq %0 = [%1], r29, ar.ccv\n" \
:"=r"(result) :"r"(rw) : "ar.ccv", "r2", "r29", "memory"); \
(result == 0); \
})Regards,
---------
Joël
Quoted 8 lines · Joel GUILLET
What the macro is doing : (at least, what I think it is doing)
- if the actual lock value is equal to "0",
change the lock value to "00.....0001" else do nothingThe code for this : (in
include/asm-ia64/spinlock.h)"dep r29 = -1, r0, 31, 1\n"
doesn't this make the value of r29 0x80000000? i.e the 1 is at the wrong end.
Quoted 1 line
"cmpxchg4.acq result = [rw], r29, ar.ccv\n"
so here you end up swapping 0x8000000 into rw if rw=0
i think maybe just making doing mov r29 = 1 above will do what you want.
Hello,
Quoted 5 lines · Ian Wienand
Quoted 4 lines · Joel GUILLET
What the macro is doing : (at least, what I think it is doing)
- if the actual lock value is equal to "0",
change the lock value to "00.....0001"
Sorry for that mistake in my mail, but the value I actually want to store into the lock is the 32 bit value "1000000...000".
... because the rw_lock value is composed with :
- 1 bit for the write "flag" (the most significant bit of a _long_ value)
- 31 bits for the read flags
... so the value of r29 (0x80000000) should be OK.
Quoted 24 lines
Quoted 4 lines
else do nothing
The code for this : (in
include/asm-ia64/spinlock.h)"dep r29 = -1, r0, 31, 1\n"doesn't this make the value of r29
0x80000000? i.e the 1 is at the wrong end.Quoted 1 line
"cmpxchg4.acq result = [rw], r29, ar.ccv\n"so here you end up swapping
0x8000000into rw if rw=0i think maybe just making doing mov r29 = 1 above will do what you want.
-i
[email protected]
http://www.gelato.unsw.edu.au_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Joel GUILLET
Joel> Here is an implementation of "_raw_write_trylock_ " needed for Joel> preemption support with SMP. I tested it on a 2.5.59 kernel Joel> with 2 Itaniums. It seems to work.
I included your change, after dropping the (unnecessary) clobber of r2 and and the label (final result is below). Let me know if you have any issue with this.
Thanks,
--david
#define _raw_spin_trylock(x) \
({ \
register long result; \
\
__asm__ __volatile__ ( \
"mov ar.ccv=r0\n" \
";;\n" \
"cmpxchg4.acq %0=[%2],%1,ar.ccv\n" \
: "=r"(result) : "r"(1), "r"(&(x)->lock) : "ar.ccv", "memory"); \
(result = 0); \
})