From: Matthew Wilcox <matthew@wil.cx>
To: David Chinner <dgc@sgi.com>
Cc: linux-kernel@vger.kernel.org, Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: Announce: Semaphore-Removal tree
Date: Mon, 28 Apr 2008 06:20:04 -0600 [thread overview]
Message-ID: <20080428122004.GT14990@parisc-linux.org> (raw)
In-Reply-To: <20080428051040.GH103491721@sgi.com>
On Mon, Apr 28, 2008 at 03:10:40PM +1000, David Chinner wrote:
> On Fri, Apr 25, 2008 at 11:00:21AM -0600, Matthew Wilcox wrote:
> >
> > It's been a Good Idea for a while to use mutexes instead of
> > semaphores where possible. Additional debuggability, better optimised,
> > better-enforced semantics, etc.
> >
> > Obviously, there are some places that can't be converted to mutexes.
> > I'm not proposing blind changes.
>
> Matthew, what's the plan for code using semaphores that cannot be
> easily converted to something else? e.g. XFS?
I'm glad you asked!
Arjan, Ingo and I have been batting around something called a kcounter.
I appear to have misplaced the patch right now, but the basic idea is
that it returns you a cookie when you down(), which you then have to
pass to the up()-equivalent. This gives you at least some of the
assurances you get from mutexes.
Though ... looking at XFS, you have 5 counting semaphores currently:
1. i_flock
This one seems to be a mutex. I'd need to immerse myself in XFS for a
couple of days to verify that though -- there's a lot of places that use
it, and it doesn't have obvious lock/unlock pairing. Is it sometimes
unlocked from a different thread than the one which locked it? If so,
kcounters might be the right thing to use here.
2. l_flushsema
This seems to be a completion. ie you're using it to wait for the log
to be flushed.
3. q_flock
Ow. ow. My brain hurts. What are these semantics?
4. b_iodonesema
This should be a completion. It's used to wait for the io to be
complete.
5. b_sema
This looks like a mutex, but I think it's released in a different
context from the one which acquires it.
-----
Possibly XFS should be using constructs like wait_on_bit instead of
semaphores. See the implementation of wait_on_buffer for an example.
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2008-04-28 12:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-25 17:00 Announce: Semaphore-Removal tree Matthew Wilcox
2008-04-25 20:24 ` Daniel Walker
2008-04-25 20:38 ` Daniel Walker
2008-04-25 21:12 ` Christoph Hellwig
2008-04-25 21:22 ` Daniel Walker
2008-04-26 9:30 ` Christoph Hellwig
2008-04-26 13:39 ` Peter Zijlstra
2008-04-26 13:44 ` Christoph Hellwig
2008-04-26 14:04 ` Peter Zijlstra
2008-04-28 4:59 ` David Chinner
2008-04-26 13:54 ` Stephen Rothwell
2008-04-26 15:59 ` Matthew Wilcox
2008-04-26 16:43 ` Stephen Rothwell
2008-04-28 5:10 ` David Chinner
2008-04-28 12:20 ` Matthew Wilcox [this message]
2008-04-29 0:09 ` David Chinner
2008-04-29 2:35 ` Matthew Wilcox
2008-04-29 3:56 ` David Chinner
2008-04-30 10:21 ` Matthew Wilcox
2008-04-30 10:06 ` Matthew Wilcox
2008-04-30 11:01 ` David Chinner
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=20080428122004.GT14990@parisc-linux.org \
--to=matthew@wil.cx \
--cc=dgc@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/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