From: Rusty Russell <rusty@rustcorp.com.au>
To: frankeh@watson.ibm.com
Cc: linux-kernel@vger.kernel.org
Cc: "Peter Wächtler" <pwaechtler@loewe-komp.de>,
"Martin Wirth" <martin.wirth@dlr.de>,
drepper@redhat.com, matthew@hairy.beasts.org
Subject: Re: [PATCH] Futex Generalization Patch
Date: Sat, 06 Apr 2002 19:48:11 +1000 [thread overview]
Message-ID: <E16tmnr-0003BM-00@wagner.rustcorp.com.au> (raw)
In-Reply-To: Your message of "Thu, 04 Apr 2002 11:28:33 EST." <20020404162751.B0A253FE06@smtp.linux.ibm.com>
In message <20020404162751.B0A253FE06@smtp.linux.ibm.com> you write:
> In futex_wait we have
> kmap(page)
> schedule_timeout()
> kunmap()
Oops! Good catch.,.. I've moved the kunmap to before the timeout...
> ---------------------
> A) in futex_down_timeout
> get ride of woken, don't see why you need that.
> optimize the while statement. Unless there are some hidden gcc issues.
We don't need to set to -1 if we never slept, that's why we have the
woken flag.
> static inline int futex_down_timeout(struct futex *futx, struct timespec *rel
)
> {
> int val, woken = 0;
>
> /* Returns new value */
> while ((val = __futex_down(&futx->count)) != 0) {
> switch (__futex_down_slow(futx, val, rel)) {
> case -1:
> return -1; /* error */
> case 0:
> futx->count = -1; /* slept */
> /* fall through */
> case 1:
> return 0; /* passed */
> }
> }
> }
case 0 does not return, it sleeps! This is wrong...
> Still missing something on the futex_trydown !!
>
> futex_trydown ::= futex_down == 1 ? 0 : -1
>
> So P1 holds the lock, P2 runs "while (1) { futex_trydown }" will decrement
> the counter yielding at some point "1" and thus granting the lock.
> At one GHz on 32 way system this only requires a lock hold time of a few
> seconds. Doesn't sound like a good idea.
Look closer at __futex_down: it doesn't decrement if futx->count < 0.
> This brings back the discussion on compare and swap. This would be trivial to
> do with compare and swap.
Yes, this is what the PPC code does.
Cheers,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2002-04-06 9:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-04 7:52 Rusty Russell
2002-04-04 16:28 ` Hubertus Franke
2002-04-06 9:48 ` Rusty Russell [this message]
2002-04-10 14:24 ` Hubertus Franke
2002-04-10 16:37 ` Rusty Russell
2002-04-10 16:37 ` Hubertus Franke
2002-04-10 18:09 Bill Abt
2002-04-10 18:10 ` Hubertus Franke
2002-04-10 19:30 Bill Abt
2002-04-10 18:47 ` Hubertus Franke
2002-04-12 15:36 ` Peter Wächtler
2002-04-12 18:48 ` Hubertus Franke
2002-04-13 13:52 ` Peter Wächtler
2002-04-15 13:28 ` Hubertus Franke
2002-04-10 19:59 Bill Abt
2002-04-10 20:14 ` Hubertus Franke
2002-04-11 13:55 ` Rusty Russell
2002-04-15 14:49 Bill Abt
2002-04-15 16:22 ` Hubertus Franke
2002-04-15 20:57 ` Mark Mielke
2002-04-15 20:46 ` Hubertus Franke
2002-04-16 20:03 ` Peter Wächtler
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=E16tmnr-0003BM-00@wagner.rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=frankeh@watson.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®