From: John Richard Moser <nigelenki@comcast.net>
To: Rik van Riel <riel@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Locking scheme to block less
Date: Mon, 09 Aug 2004 23:20:26 -0400 [thread overview]
Message-ID: <41183EFA.5090600@comcast.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0408092133390.25913-100000@dhcp83-102.boston.redhat.com>
Rik van Riel wrote:
> On Mon, 9 Aug 2004, John Richard Moser wrote:
>
>
>>Currently, the kernel uses only spin_locks,
>
>
> Oh ? Haven't you seen the read/write locks in
> include/linux/spinlock.h or the lockless synchronisation
> provided by include/linux/rcu.h ?
>
No, last I looked was in 2.4, and it was a passing glance long ago.
>
>>If the kernel provided a read-write locking semaphore,
>
>
> Funny, it does. You're not looking at a 2.0 kernel, are
> you?
>
>
>>spin_read_to_write_lock(spin_rwlock_t *lock);
>
[Reinsert->]
This is a read lock that will become a write lock. It allows other read
locks; but blocks write locks and other read_to_write locks. It is
blocked by write locks [and other read_to_write locks](sorry).
>
>>A read_to_write lock will block two such operations from occuring
>>concurrently, while still allowing read only operations AND still being
>>blocked when switched to write mode by both read and write operations.
>
>
> In fact, two threads trying to upgrade their read lock to a
> write lock simultaneously will block EACH OTHER, FOREVER.
>
What no, read that. It blocks write locks and other read_to_write
locks. It should have the above ammendment that it blocks other
read_to_write locks from beginning, although it is mentioned that this
DOES block its own kind. I guess I need to repete myself sometimes.
The point is to prevent operations that find an index on a linked list
to insert/remove at from altering while something could be reading.
Concurrent read locks can both find nearby indicies, then race for a
write lock, leaving the first to clobber the second.
With this type of semaphore (am I using this word correctly?), any
number of readlocks can exist concurrently with exactly one
read_write_lock, but will block that read_write_lock from transforming
to write mode. Similarly, only one read_write_lock can actually be
unblocked at any one time, to prevent these races.
> Sounds like an exceedingly bad idea to me ;)
>
I've seen bad things.
--
All content of all messages exchanged herein are left in the
Public Domain, unless otherwise explicitly stated.
next prev parent reply other threads:[~2004-08-10 3:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-10 0:38 Locking scheme to block less John Richard Moser
2004-08-10 0:51 ` viro
2004-08-10 3:14 ` John Richard Moser
2004-08-10 1:36 ` Rik van Riel
2004-08-10 3:20 ` John Richard Moser [this message]
2004-08-10 15:15 ` Martin J. Bligh
2004-08-11 2:08 ` Rik van Riel
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=41183EFA.5090600@comcast.net \
--to=nigelenki@comcast.net \
--cc=linux-kernel@vger.kernel.org \
--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 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.