* alpha: half done futex implementation
@ 2009-04-12 0:55 Matt Turner
2009-04-12 13:49 ` Tobias Klausmann
2009-04-13 20:23 ` Richard Henderson
0 siblings, 2 replies; 7+ messages in thread
From: Matt Turner @ 2009-04-12 0:55 UTC (permalink / raw)
To: linux-kernel, linux-alpha
Cc: Ivan Kokshaysky, Richard Henderson, Jay Estabrook, Oliver Falk
Hi,
Going on Richard's advice, I've tried to write an alpha futex
implementation based on the powerpc futex.h.
I've gotten this far.. :\
#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
__asm__ __volatile( \
"1: ldl_l %0,%2\n" \
insn \
/* something needs to happen here
* to save result of insn across
* stl_c? */
" stl_c %1,%2\n" \
" beq %1,2f\n" \
" mb\n" \
/* something needs to happen here
* for the ret */
" .subsection 2\n" \
"2: br 1b\n" \
" .previous\n" \
: "=&r" (oldval), "=&r" (ret) \
: "b" (uaddr) \
: "memory")
Could someone take a look and help finish it?
For futex_atomic_cmpxchg_inatomic, I think Ivan's DRM_CAS
implementation can be used with only trivial changes. See
http://cgit.freedesktop.org/mesa/drm/commit/?id=6feac49398d0f037103a4ae3d5a512badeed61fb
Please CC me on responses, as I'm not subscribed to linux-kernel@.
Thanks,
Matt Turner
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: alpha: half done futex implementation 2009-04-12 0:55 alpha: half done futex implementation Matt Turner @ 2009-04-12 13:49 ` Tobias Klausmann 2009-04-13 20:23 ` Richard Henderson 1 sibling, 0 replies; 7+ messages in thread From: Tobias Klausmann @ 2009-04-12 13:49 UTC (permalink / raw) To: linux-kernel, linux-alpha Hi! 30-rc1 doesn't compile on alpha: net/socket.c: In function 'sock_alloc': net/socket.c:496: error: implicit declaration of function 'percpu_add' net/socket.c:496: error: 'sockets_in_use' undeclared (first use in this function) net/socket.c:496: error: (Each undeclared identifier is reported only once net/socket.c:496: error: for each function it appears in.) net/socket.c: In function 'sock_release': net/socket.c:538: error: implicit declaration of function 'percpu_sub' net/socket.c:538: error: 'sockets_in_use' undeclared (first use in this function) I vaguely remember seeing discussion about this on lkml, but I can't find it right now. gcc is 4.3.3. Distro is Gentoo, machine is a UP1500 (Nautilus). Regards, Tobias -- Save a tree - disband an ISO working group today. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: alpha: half done futex implementation 2009-04-12 0:55 alpha: half done futex implementation Matt Turner 2009-04-12 13:49 ` Tobias Klausmann @ 2009-04-13 20:23 ` Richard Henderson 2009-04-13 21:54 ` Andreas Schwab 2009-04-14 9:40 ` Segher Boessenkool 1 sibling, 2 replies; 7+ messages in thread From: Richard Henderson @ 2009-04-13 20:23 UTC (permalink / raw) To: Matt Turner Cc: linux-kernel, linux-alpha, Ivan Kokshaysky, Jay Estabrook, Oliver Falk, linuxppc-dev Matt Turner wrote: > Hi, > > Going on Richard's advice, I've tried to write an alpha futex > implementation based on the powerpc futex.h. > > I've gotten this far.. :\ > #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ __asm__ __volatile( \ __ASM_MB \ "1: ldl_l %0,0(%3)\n" \ insn \ "2: stl_c %1,0(%3)\n" \ " beq %1,4f\n" \ " mov $31,%1\n" \ "3: .subsection 2\n" \ "4: br 1b\n" \ " .previous\n" \ ".section __ex_table,\"a\"\n" \ " .long 1b-.\n" \ " lda %0,3b-1b(%2)\n" \ " .long 2b-.\n" \ " lda %0,3b-2b(%2)\n" \ " .previous\n" \ : "=&r" (oldval), "=&r"(ret) \ : "r" (uaddr), "r"(oparg) \ : "memory") switch (op) { case FUTEX_OP_SET: __futex_atomic_op("mov %0,%1", ret, oldval, uaddr, oparg); break; case FUTEX_OP_ADD: __futex_atomic_op("addl %0,%4,%1\n", ret, oldval, uaddr, oparg); break; case FUTEX_OP_OR: __futex_atomic_op("or %0,%4,%1\n", ret, oldval, uaddr, oparg); break; case FUTEX_OP_ANDN: __futex_atomic_op("andnot %0,%4,%1\n", ret, oldval, uaddr, oparg); break; case FUTEX_OP_XOR: __futex_atomic_op("xor %0,%4,%1\n", ret, oldval, uaddr, oparg); break; default: ret = -ENOSYS; } Also, there's a bug in the powerpc implementation. It appears that oparg is clobbered, and if stwcx fails the operation will be repeated with incorrect inputs. r~ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: alpha: half done futex implementation 2009-04-13 20:23 ` Richard Henderson @ 2009-04-13 21:54 ` Andreas Schwab 2009-04-13 22:20 ` Richard Henderson 2009-04-14 9:40 ` Segher Boessenkool 1 sibling, 1 reply; 7+ messages in thread From: Andreas Schwab @ 2009-04-13 21:54 UTC (permalink / raw) To: Richard Henderson Cc: Matt Turner, Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Jay Estabrook Richard Henderson <rth@twiddle.net> writes: > switch (op) { > case FUTEX_OP_SET: > __futex_atomic_op("mov %0,%1", ret, oldval, uaddr, oparg); That should probably be "mov %4,%1\n"? Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: alpha: half done futex implementation 2009-04-13 21:54 ` Andreas Schwab @ 2009-04-13 22:20 ` Richard Henderson 0 siblings, 0 replies; 7+ messages in thread From: Richard Henderson @ 2009-04-13 22:20 UTC (permalink / raw) To: Andreas Schwab Cc: Matt Turner, Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Jay Estabrook Andreas Schwab wrote: > Richard Henderson <rth@twiddle.net> writes: > >> switch (op) { >> case FUTEX_OP_SET: >> __futex_atomic_op("mov %0,%1", ret, oldval, uaddr, oparg); > > That should probably be "mov %4,%1\n"? You're right. r~ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: alpha: half done futex implementation 2009-04-13 20:23 ` Richard Henderson 2009-04-13 21:54 ` Andreas Schwab @ 2009-04-14 9:40 ` Segher Boessenkool 2009-04-14 9:45 ` Segher Boessenkool 1 sibling, 1 reply; 7+ messages in thread From: Segher Boessenkool @ 2009-04-14 9:40 UTC (permalink / raw) To: Richard Henderson Cc: Matt Turner, Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Jay Estabrook > Also, there's a bug in the powerpc implementation. It appears that > oparg is clobbered, and if stwcx fails the operation will be > repeated with incorrect inputs. If either the lwarx or the stwcx. faults, the routine returns -EFAULT and doesn't retry (label "3" is the end of the asm). If the stwcx. fails because the CPU lost the reservation, %1 isn't clobbered as far as I see? Segher ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: alpha: half done futex implementation 2009-04-14 9:40 ` Segher Boessenkool @ 2009-04-14 9:45 ` Segher Boessenkool 0 siblings, 0 replies; 7+ messages in thread From: Segher Boessenkool @ 2009-04-14 9:45 UTC (permalink / raw) To: Segher Boessenkool Cc: Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Matt Turner, Jay Estabrook, Richard Henderson > If either the lwarx or the stwcx. faults, the routine returns -EFAULT > and doesn't retry (label "3" is the end of the asm). > > If the stwcx. fails because the CPU lost the reservation, %1 isn't > clobbered as far as I see? Oh, "insn" writes to %1, never mind. Segher ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-04-14 9:45 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-12 0:55 alpha: half done futex implementation Matt Turner 2009-04-12 13:49 ` Tobias Klausmann 2009-04-13 20:23 ` Richard Henderson 2009-04-13 21:54 ` Andreas Schwab 2009-04-13 22:20 ` Richard Henderson 2009-04-14 9:40 ` Segher Boessenkool 2009-04-14 9:45 ` Segher Boessenkool
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox