From: Kumba <kumba@gentoo.org>
To: gcc-patches@gcc.gnu.org
Cc: Richard Sandiford <rdsandiford@googlemail.com>,
Linux MIPS List <linux-mips@linux-mips.org>
Subject: [PATCH]: R10000 Needs LL/SC Workaround in Gcc
Date: Fri, 31 Oct 2008 01:00:36 -0400 [thread overview]
Message-ID: <490A90F4.6040601@gentoo.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 908 bytes --]
The attached patch adds a workaround to have gcc emit branch likely instructions
(beqzl) in atomic operations for R10000 CPUs. This is because revisions of this
CPU before 3.0 misbehave, while revisions 2.6 and earlier will deadlock. This
issue has been noted on SGI IP28 (Indigo2 Impact R10000) systems and SGI IP27
Origin systems.
After creating a patch to glibc based off of Debian Bug #462112
(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=462112), it was suggested by
David Daney that a similar patch be created for GCC.
Feedback would be welcome on any suggestions for improving this patch (please
CC, as I'm not subscribed to the ML).
Thanks!
--
Joshua Kinard
Gentoo/MIPS
kumba@gentoo.org
"The past tempts us, the present confuses us, the future frightens us. And our
lives slip away, moment by moment, lost in that vast, terrible in-between."
--Emperor Turhan, Centauri Republic
[-- Attachment #2: gcc-trunk-r10k-beqzl.patch --]
[-- Type: text/plain, Size: 4393 bytes --]
diff -Naurp gcc.orig/gcc/config/mips/mips.h gcc/gcc/config/mips/mips.h
--- gcc.orig/gcc/config/mips/mips.h 2008-10-30 22:20:27.000000000 -0400
+++ gcc/gcc/config/mips/mips.h 2008-10-30 23:12:11.000000000 -0400
@@ -3066,6 +3066,31 @@ while (0)
#ifndef HAVE_AS_TLS
#define HAVE_AS_TLS 0
#endif
+\f
+/* Certain revisions of the R10000 Processor need an LL/SC Workaround
+ enabled. Revisions before 3.0 misbehave on atomic operations, and
+ Revs 2.6 and lower deadlock after several seconds due to other errata.
+
+ To quote the R10K Errata:
+ Workaround: The basic idea is to inhibit the four instructions
+ from simultaneously becoming active in R10000. Padding all
+ ll/sc sequences with nops or changing the looping branch in the
+ routines to a branch likely (which is always predicted taken
+ by R10000) will work. The nops should go after the loop, and the
+ number of them should be 28. This number could be decremented for
+ each additional instruction in the ll/sc loop such as the lock
+ modifier(s) between the ll and sc, the looping branch and its
+ delay slot. For typical short routines with one ll/sc loop, any
+ instructions after the loop could also count as a decrement. The
+ nop workaround pollutes the cache more but would be a few cycles
+ faster if all the code is in the cache and the looping branch
+ is predicted not taken. */
+
+#ifndef (_MIPS_ARCH_R10000)
+#define R10K_BEQZ_INSN "\tbeq\t%@,%.,1b\n"
+#else
+#define R10K_BEQZ_INSN "\tbeqzl\t%@,1b\n"
+#endif
/* Return an asm string that atomically:
@@ -3083,7 +3108,7 @@ while (0)
"\tbne\t%0,%z2,2f\n" \
"\t" OP "\t%@,%3\n" \
"\tsc" SUFFIX "\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)\n" \
"2:\n"
@@ -3108,7 +3133,7 @@ while (0)
"\tand\t%@,%0,%3\n" \
OPS \
"\tsc\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)\n" \
"2:\n"
@@ -3128,7 +3153,7 @@ while (0)
"1:\tll" SUFFIX "\t%@,%0\n" \
"\t" INSN "\t%@,%@,%1\n" \
"\tsc" SUFFIX "\t%@,%0\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3153,7 +3178,7 @@ while (0)
"\tand\t%4,%4,%1\n" \
"\tor\t%@,%@,%4\n" \
"\tsc\t%@,%0\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3186,7 +3211,7 @@ while (0)
"\tand\t%5,%5,%2\n" \
"\tor\t%@,%@,%5\n" \
"\tsc\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3216,7 +3241,7 @@ while (0)
"\tand\t%0,%0,%2\n" \
"\tor\t%@,%@,%0\n" \
"\tsc\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3236,7 +3261,7 @@ while (0)
"1:\tll" SUFFIX "\t%0,%1\n" \
"\t" INSN "\t%@,%0,%2\n" \
"\tsc" SUFFIX "\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3253,7 +3278,7 @@ while (0)
"1:\tll" SUFFIX "\t%0,%1\n" \
"\t" INSN "\t%@,%0,%2\n" \
"\tsc" SUFFIX "\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\t" INSN "\t%0,%0,%2\n" \
"\tsync%-%]%>%)"
@@ -3270,7 +3295,7 @@ while (0)
"\tnor\t%@,%@,%.\n" \
"\t" INSN "\t%@,%@,%1\n" \
"\tsc" SUFFIX "\t%@,%0\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3289,7 +3314,7 @@ while (0)
"\tnor\t%@,%0,%.\n" \
"\t" INSN "\t%@,%@,%2\n" \
"\tsc" SUFFIX "\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3308,7 +3333,7 @@ while (0)
"\tnor\t%0,%0,%.\n" \
"\t" INSN "\t%@,%0,%2\n" \
"\tsc" SUFFIX "\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\t" INSN "\t%0,%0,%2\n" \
"\tsync%-%]%>%)"
@@ -3326,7 +3351,7 @@ while (0)
"1:\tll" SUFFIX "\t%0,%1\n" \
"\t" OP "\t%@,%2\n" \
"\tsc" SUFFIX "\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
@@ -3350,7 +3375,7 @@ while (0)
"\tand\t%@,%0,%3\n" \
OPS \
"\tsc\t%@,%1\n" \
- "\tbeq\t%@,%.,1b\n" \
+ R10K_BEQZ_INSN \
"\tnop\n" \
"\tsync%-%]%>%)"
next reply other threads:[~2008-11-01 8:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-31 5:00 Kumba [this message]
2008-10-31 14:24 ` [PATCH]: R10000 Needs LL/SC Workaround in Gcc Maciej W. Rozycki
2008-11-01 7:30 ` Kumba
2008-11-01 17:41 ` Richard Sandiford
2008-11-01 18:49 ` Kumba
2008-11-01 19:42 ` Richard Sandiford
2008-11-02 0:00 ` Kumba
2008-11-02 10:00 ` Richard Sandiford
2008-11-03 9:01 ` Kumba
2008-11-03 20:47 ` Richard Sandiford
2008-11-04 0:04 ` Ralf Baechle
2008-11-04 7:14 ` Kumba
2008-11-04 9:04 ` Ralf Baechle
2008-11-04 14:26 ` Maciej W. Rozycki
2008-11-04 14:31 ` Ralf Baechle
2008-11-04 14:23 ` Maciej W. Rozycki
2008-11-08 9:37 ` Richard Sandiford
2008-11-08 18:20 ` Markus Gothe
2008-11-10 6:09 ` Kumba
2008-11-11 23:13 ` Richard Sandiford
2008-11-11 23:28 ` Richard Sandiford
2008-11-11 23:40 ` Maciej W. Rozycki
2008-11-12 7:42 ` Kumba
2008-11-13 23:10 ` Richard Sandiford
2008-11-14 8:14 ` Kumba
2008-11-15 14:28 ` Richard Sandiford
2008-11-16 7:35 ` Kumba
2008-11-02 10:49 ` Maciej W. Rozycki
2008-11-02 11:34 ` Richard Sandiford
2008-11-03 16:51 ` Paul_Koning
2008-11-03 16:51 ` Paul_Koning
2008-11-03 16:59 ` Maciej W. Rozycki
2008-11-03 17:35 ` Ralf Baechle
2008-11-01 20:33 ` Maciej W. Rozycki
2008-11-01 23:45 ` Ralf Baechle
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=490A90F4.6040601@gentoo.org \
--to=kumba@gentoo.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=linux-mips@linux-mips.org \
--cc=rdsandiford@googlemail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.