* Re: alpha: half done futex implementation [not found] <b4198de60904111755u5c2078c7xcc689dbd78aeb957@mail.gmail.com> @ 2009-04-13 20:23 ` Richard Henderson 2009-04-13 21:54 ` Andreas Schwab 2009-04-14 9:40 ` Segher Boessenkool 0 siblings, 2 replies; 5+ messages in thread From: Richard Henderson @ 2009-04-13 20:23 UTC (permalink / raw) To: Matt Turner Cc: Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Jay Estabrook 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] 5+ messages in thread
* Re: alpha: half done futex implementation 2009-04-13 20:23 ` alpha: half done futex implementation 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; 5+ messages in thread From: Andreas Schwab @ 2009-04-13 21:54 UTC (permalink / raw) To: Richard Henderson Cc: Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Matt Turner, 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] 5+ 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; 5+ messages in thread From: Richard Henderson @ 2009-04-13 22:20 UTC (permalink / raw) To: Andreas Schwab Cc: Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Matt Turner, 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] 5+ messages in thread
* Re: alpha: half done futex implementation 2009-04-13 20:23 ` alpha: half done futex implementation 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; 5+ messages in thread From: Segher Boessenkool @ 2009-04-14 9:40 UTC (permalink / raw) To: Richard Henderson Cc: Oliver Falk, linux-kernel, linuxppc-dev, Ivan Kokshaysky, linux-alpha, Matt Turner, 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] 5+ 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; 5+ 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] 5+ messages in thread
end of thread, other threads:[~2009-04-14  9:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <b4198de60904111755u5c2078c7xcc689dbd78aeb957@mail.gmail.com>
2009-04-13 20:23 ` alpha: half done futex implementation 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; as well as URLs for NNTP newsgroup(s).