From: Pete Zaitcev <zaitcev@redhat.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: Pete Zaitcev <zaitcev@redhat.com>,
riel@redhat.com, linux-kernel@vger.kernel.org,
linux390@de.ibm.com
Subject: Re: gcc-3.2 breaks rmap on s390x
Date: Thu, 3 Apr 2003 14:30:45 -0500 [thread overview]
Message-ID: <20030403143045.A1437@devserv.devel.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0304031954480.2237-100000@localhost.localdomain>; from hugh@veritas.com on Thu, Apr 03, 2003 at 08:01:10PM +0100
> Date: Thu, 3 Apr 2003 20:01:10 +0100 (BST)
> From: Hugh Dickins <hugh@veritas.com>
> > while (test_and_set_bit(PG_chainlock, &page->flags)) {
> > - while (test_bit(PG_chainlock, &page->flags))
> > + while (test_bit(PG_chainlock, &page->flags)) {
> > cpu_relax();
> > + barrier();
> > + }
> > }
> Isn't it rather odd that it should fix the problem you describe?
> because the barrier you're adding comes only in the exceptional path,
> when the lock was found already held.
The actual code is not drastically rearranged and fragments
are not replicated. Thus, the code below the while() loop
cannot possibly know if the lock was contested or not
(if the loop was executed at least once or not),
and it has to load the value from memory.
But suppose your worst fears came true and complier decided
to push the beyond the limits of reasonable into the shady
realm of legal. The worst the compiler can do is:
register word r10;
r10 = page->pte.direct;
if (r10!=0) something();
if (test_and_set_bit(PG_chainlock, &page->flags) == 0) {
/* No barrier here, mwuahahaha!!! */
} else {
do {
while (test_bit(PG_chainlock, &page->flags)) {
// This loop can be inverted too. No change to the reasoning.
cpu_relax();
barrier();
}
} while (test_and_set_bit(PG_chainlock, &page->flags));
r10 = page->pte.direct;
}
foo_using(r10);
Which continues to work, because the value loaded before uncontested
was taken is still valid later. The problem only happens if the
lock was contested.
BTW, Bill Irwin noted that, strictly speaking, the first if statement
with page_mapped should be done under the lock for safety. I think
he got a point. A 2.5 preempt in the wrong moment (between the
first load and test_and_set_bit in the above example) makes
the code invalid after all. Not that it mattered as long as
compiler does not do such exercises as I outlined above.
-- Pete
next prev parent reply other threads:[~2003-04-03 19:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-03 18:10 gcc-3.2 breaks rmap on s390x Pete Zaitcev
2003-04-03 18:44 ` Rik van Riel
2003-04-03 19:00 ` Davide Libenzi
2003-04-03 19:01 ` Hugh Dickins
2003-04-03 19:30 ` Pete Zaitcev [this message]
2003-04-03 19:17 ` Anton Blanchard
-- strict thread matches above, loose matches on Subject: below --
2003-04-03 19:42 Ulrich Weigand
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=20030403143045.A1437@devserv.devel.redhat.com \
--to=zaitcev@redhat.com \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=riel@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox