* [Linux-ia64] _raw_write_trylock() missing
@ 2003-02-04 2:53 Peter Chubb
2003-02-04 14:18 ` Joel GUILLET
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Peter Chubb @ 2003-02-04 2:53 UTC (permalink / raw)
To: linux-ia64
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Linux-ia64] _raw_write_trylock() missing
2003-02-04 2:53 [Linux-ia64] _raw_write_trylock() missing Peter Chubb
@ 2003-02-04 14:18 ` Joel GUILLET
2003-02-05 1:46 ` Ian Wienand
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Joel GUILLET @ 2003-02-04 14:18 UTC (permalink / raw)
To: linux-ia64
On Tue, 4 Feb 2003, Peter Chubb wrote:
>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Linux-ia64] _raw_write_trylock() missing
2003-02-04 2:53 [Linux-ia64] _raw_write_trylock() missing Peter Chubb
2003-02-04 14:18 ` Joel GUILLET
@ 2003-02-05 1:46 ` Ian Wienand
2003-02-05 8:39 ` Joel GUILLET
2003-03-04 19:57 ` David Mosberger
3 siblings, 0 replies; 5+ messages in thread
From: Ian Wienand @ 2003-02-05 1:46 UTC (permalink / raw)
To: linux-ia64
On Tue, Feb 04, 2003 at 03:18:22PM +0100, Joel GUILLET wrote:
> 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 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.
> "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.
-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Linux-ia64] _raw_write_trylock() missing
2003-02-04 2:53 [Linux-ia64] _raw_write_trylock() missing Peter Chubb
2003-02-04 14:18 ` Joel GUILLET
2003-02-05 1:46 ` Ian Wienand
@ 2003-02-05 8:39 ` Joel GUILLET
2003-03-04 19:57 ` David Mosberger
3 siblings, 0 replies; 5+ messages in thread
From: Joel GUILLET @ 2003-02-05 8:39 UTC (permalink / raw)
To: linux-ia64
Hello,
On Wed, 5 Feb 2003, Ian Wienand wrote:
> On Tue, Feb 04, 2003 at 03:18:22PM +0100, Joel GUILLET wrote:
> > 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.
> > 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.
>
> > "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.
>
> -i
> ianw@gelato.unsw.edu.au
> http://www.gelato.unsw.edu.au
>
> _______________________________________________
> Linux-IA64 mailing list
> Linux-IA64@linuxia64.org
> http://lists.linuxia64.org/lists/listinfo/linux-ia64
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Linux-ia64] _raw_write_trylock() missing
2003-02-04 2:53 [Linux-ia64] _raw_write_trylock() missing Peter Chubb
` (2 preceding siblings ...)
2003-02-05 8:39 ` Joel GUILLET
@ 2003-03-04 19:57 ` David Mosberger
3 siblings, 0 replies; 5+ messages in thread
From: David Mosberger @ 2003-03-04 19:57 UTC (permalink / raw)
To: linux-ia64
>>>>> On Tue, 4 Feb 2003 15:18:22 +0100 (NFT), Joel GUILLET <Joel.Guillet@bull.net> said:
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); \
})
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-03-04 19:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-04 2:53 [Linux-ia64] _raw_write_trylock() missing Peter Chubb
2003-02-04 14:18 ` Joel GUILLET
2003-02-05 1:46 ` Ian Wienand
2003-02-05 8:39 ` Joel GUILLET
2003-03-04 19:57 ` David Mosberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox