From: Richard Henderson <rth@twiddle.net>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: torvalds@transmeta.com, matthew@hairy.beasts.org,
bcrl@redhat.com, david@mysql.com, wli@holomorphy.com,
linux-kernel@vger.kernel.org,
Hubertus Franke <frankeh@watson.ibm.com>
Subject: Re: [PATCH] Fast Userspace Mutexes III.
Date: Wed, 6 Mar 2002 17:52:03 -0800 [thread overview]
Message-ID: <20020306175203.A26064@twiddle.net> (raw)
In-Reply-To: <E16hjZY-0001AV-00@wagner.rustcorp.com.au>
In-Reply-To: <E16hjZY-0001AV-00@wagner.rustcorp.com.au>; from rusty@rustcorp.com.au on Mon, Mar 04, 2002 at 02:55:36PM +1100
On Mon, Mar 04, 2002 at 02:55:36PM +1100, Rusty Russell wrote:
> + /* If we take the semaphore from 1 to 0, it's ours. */
> + while (!atomic_dec_and_test(count)) {
> + if (signal_pending(current)) {
> + retval = -EINTR;
> + break;
This is not safe from wraparound. Let one thread hold the
lock forever; let other threads keep trying to take the lock
while periodically getting SIGALRM. Eventually one of the
spinning threads will incorrectly acquire the mutex.
On sparc32, atomic_t is only 24 bits wide, so it wouldn't
take very long at all to wrap. It's slightly longer for
the other platforms, but it can still happen. And note
that even 64-bit platforms may be using a 32-bit atomic_t.
You really do need that cmpxchg loop.
r~
next prev parent reply other threads:[~2002-03-07 1:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-04 3:55 [PATCH] Fast Userspace Mutexes III Rusty Russell
2002-03-04 19:49 ` Robert Love
2002-03-04 20:13 ` Davide Libenzi
2002-03-04 20:20 ` Matthew Kirkwood
2002-03-04 20:48 ` Hubertus Franke
2002-03-04 22:15 ` Davide Libenzi
2002-03-05 1:50 ` Robert Love
2002-03-05 2:53 ` Davide Libenzi
2002-03-05 3:45 ` Rusty Russell
2002-03-05 3:55 ` Davide Libenzi
2002-03-05 6:11 ` Rusty Russell
2002-03-05 17:23 ` Davide Libenzi
2002-03-05 15:09 ` Hubertus Franke
2002-03-05 4:30 ` Edgar Toernig
2002-03-07 1:58 ` Richard Henderson
2002-03-07 2:10 ` Davide Libenzi
2002-03-05 4:48 ` Rusty Russell
2002-03-05 15:15 ` Hubertus Franke
2002-03-06 1:31 ` Rusty Russell
2002-03-05 1:34 ` Rusty Russell
2002-03-07 1:52 ` Richard Henderson [this message]
2002-03-07 3:39 ` Rusty Russell
2002-03-07 8:48 ` Richard Henderson
2002-03-07 9:17 ` Rusty Russell
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=20020306175203.A26064@twiddle.net \
--to=rth@twiddle.net \
--cc=bcrl@redhat.com \
--cc=david@mysql.com \
--cc=frankeh@watson.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@hairy.beasts.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@transmeta.com \
--cc=wli@holomorphy.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