From: Richard Henderson <rth@twiddle.net>
To: Matt Turner <mattst88@gmail.com>
Cc: Oliver Falk <oliver@linux-kernel.at>,
linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
linux-alpha@vger.kernel.org, Jay Estabrook <jay.estabrook@hp.com>
Subject: Re: alpha: half done futex implementation
Date: Mon, 13 Apr 2009 13:23:25 -0700 [thread overview]
Message-ID: <49E39F3D.4060501@twiddle.net> (raw)
In-Reply-To: <b4198de60904111755u5c2078c7xcc689dbd78aeb957@mail.gmail.com>
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~
next parent reply other threads:[~2009-04-13 20:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b4198de60904111755u5c2078c7xcc689dbd78aeb957@mail.gmail.com>
2009-04-13 20:23 ` Richard Henderson [this message]
2009-04-13 21:54 ` alpha: half done futex implementation Andreas Schwab
2009-04-13 22:20 ` Richard Henderson
2009-04-14 9:40 ` Segher Boessenkool
2009-04-14 9:45 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49E39F3D.4060501@twiddle.net \
--to=rth@twiddle.net \
--cc=ink@jurassic.park.msu.ru \
--cc=jay.estabrook@hp.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mattst88@gmail.com \
--cc=oliver@linux-kernel.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).