From: Andrew Morton <andrewm@uow.edu.au>
To: David Howells <dhowells@cambridge.redhat.com>
Cc: Linus Torvalds <torvalds@transmeta.com>,
Ben LaHaise <bcrl@redhat.com>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] 4th try: i386 rw_semaphores fix
Date: Thu, 12 Apr 2001 11:16:50 -0700 [thread overview]
Message-ID: <3AD5F112.E78436F@uow.edu.au> (raw)
In-Reply-To: Your message of "Wed, 11 Apr 2001 17:37:10 BST." <17213.987007030@warthog.cambridge.redhat.com> <17794.987025299@warthog.cambridge.redhat.com>
David Howells wrote:
>
> Here's the RW semaphore patch attempt #4. This fixes the bugs that Andrew
> Morton's test cases showed up.
>
It still doesn't compile with gcc-2.91.66 because of the
"#define rwsemdebug(FMT, ...)" thing. What can we do
about this?
I cooked up a few more tests, generally beat the thing
up. This code works. Good stuff. I'll do some more testing
later this week - put some delays inside the semaphore code
itself to stretch the timing windows, but I don't see how
it can break it.
Manfred says the rep;nop should come *before* the memory
operation, but I don't know if he's been heard...
parisc looks OK. ppc tried hard, but didn't get it
right. The spin_lock_irqsave() in up_read/up_write shouldn't be
necessary plus it puts the readers onto the
waitqueue with add_wait_queue_exclusive, so an up_write
will only release one reader. Looks like they'll end
up with stuck readers. Other architectures need work.
If they can live with a spinlock in the fastpath, then
the code at http://www.uow.edu.au/~andrewm/linux/rw_semaphore.tar.gz
is bog-simple and works.
Now I think we should specify the API a bit:
* A task is not allowed to down_read() the same rwsem
more than once time. Otherwise another task can
do a down_write() in the middle and cause deadlock.
(I don't think this has been specified for read_lock()
and write_lock(). There's no such deadlock on the
x86 implementation of these. Other architectures?
Heaven knows. They're probably OK).
* up_read() and up_write() may *not* be called from
interrupt context.
The latter is just a suggestion. It looks like your
code is safe for interrupt-context upping - but it
isn't tested for this. The guys who are going to
support rwsems for architectures which have less
rich atomic ops are going to *need* to know the rules
here. Let's tell 'em.
If we get agreement on these points, then please
drop a comment in there and I believe we're done.
In another email you said:
> schedule() disabled:
> reads taken: 585629
> writes taken: 292997
That's interesting. With two writer threads and
four reader threads hammering the rwsem, the write/read
grant ratio is 0.5003. Neat, but I'd have expected
readers to do better. Perhaps the writer-wakes-multiple
readers stuff isn't happening. I'll test for this.
There was some discussion regarding contention rates a few
days back. I did dome instrumentation on the normal semaphores.
The highest contention rate I could observe was during a `make
-j3 bzImage' on dual CPU. With this workload, down() enters
__down() 2% of the time. That's a heck of a lot. It means that
the semaphore slow path is by a very large margin the most
expensive part.
The most contention was on i_sem in real_lookup(), then pipe_sem
and vfork_sem. ext2_lookup is slow; no news there.
But tweaking the semaphore slowpath won't help here
because when a process slept in __down(), it was always
the only sleeper.
With `dbench 12' the contention rate was much lower
(0.01%). But when someone slept, there was almost
always another sleeper, so the extra wake_up() at
the end of __down() is worth attention.
I don't have any decent multithread workloads which would
allow me to form an opinion on whether we need to optimise
the slowpath, or to more finely thread the contention areas.
Could be with some workloads the contention is significant and
threading is painful. I'll have another look at it sometime...
next prev parent reply other threads:[~2001-04-12 18:21 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3AD0FD0F.9B0C47FD@uow.edu.au>
2001-04-09 3:08 ` rw_semaphores Linus Torvalds
2001-04-09 4:18 ` rw_semaphores Linus Torvalds
2001-04-09 13:55 ` rw_semaphores Ben LaHaise
2001-04-10 2:41 ` rw_semaphores Tachino Nobuhiro
2001-04-10 5:43 ` rw_semaphores Linus Torvalds
2001-04-10 6:33 ` rw_semaphores Tachino Nobuhiro
2001-04-10 7:47 ` rw_semaphores David Howells
2001-04-10 18:02 ` [PATCH] i386 rw_semaphores fix David Howells
2001-04-10 19:42 ` Linus Torvalds
2001-04-10 19:56 ` x86 cpu configuration (was: Re: [PATCH] i386 rw_semaphores fix) Jeff Garzik
2001-04-10 21:58 ` Alan Cox
2001-04-10 20:05 ` [PATCH] i386 rw_semaphores fix Andi Kleen
2001-04-10 20:16 ` Linus Torvalds
2001-04-10 22:00 ` Alan Cox
2001-04-11 0:00 ` Andi Kleen
2001-04-11 0:13 ` David Weinehall
2001-04-11 0:20 ` Andi Kleen
2001-04-11 0:56 ` David Weinehall
2001-04-11 1:04 ` Andi Kleen
2001-04-11 12:32 ` Alan Cox
2001-04-11 0:55 ` Linus Torvalds
2001-04-11 1:07 ` Andi Kleen
2001-04-11 1:12 ` Linus Torvalds
2001-04-11 1:23 ` Andi Kleen
2001-04-11 12:36 ` Alan Cox
2001-04-11 18:05 ` H. Peter Anvin
2001-04-11 12:28 ` Alan Cox
2001-04-11 18:06 ` H. Peter Anvin
2001-04-11 22:06 ` Alan Cox
2001-04-11 22:42 ` H. Peter Anvin
2001-04-11 22:55 ` Alan Cox
2001-04-10 21:57 ` Alan Cox
2001-04-11 0:40 ` Tim Wright
2001-04-11 7:38 ` David Howells
2001-04-11 12:24 ` Maciej W. Rozycki
2001-04-11 12:57 ` [PATCH] 2nd try: " David Howells
2001-04-11 16:37 ` [PATCH] 3rd " David Howells
2001-04-11 21:41 ` [PATCH] 4th " David Howells
2001-04-12 18:16 ` Andrew Morton [this message]
2001-04-11 23:00 ` [PATCH] 3rd " Anton Blanchard
2001-04-12 15:06 ` [PATCH] i386 rw_semaphores, general abstraction patch David Howells
2001-04-11 16:56 ` [PATCH] i386 rw_semaphores fix Andrew Morton
2001-04-11 17:36 ` David Howells
2001-04-11 18:41 ` Linus Torvalds
2001-04-11 21:27 ` David Howells
2001-04-16 14:39 ` rw_semaphores yodaiken
2001-04-16 14:56 ` rw_semaphores Alan Cox
2001-04-16 17:05 ` rw_semaphores Linus Torvalds
2001-04-16 17:34 ` rw_semaphores yodaiken
2001-04-16 17:26 ` rw_semaphores Andrew Morton
2001-04-12 21:18 [PATCH] 4th try: i386 rw_semaphores fix D.W.Howells
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=3AD5F112.E78436F@uow.edu.au \
--to=andrewm@uow.edu.au \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bcrl@redhat.com \
--cc=dhowells@cambridge.redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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