From: Rusty Russell <rusty@rustcorp.com.au>
To: Russell King <rmk@arm.linux.org.uk>
Cc: Jamie Lokier <jamie@shareable.org>,
Felipe W Damasio <felipewd@terra.com.br>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kernel/futex.c: Uneeded memory barrier
Date: Tue, 16 Sep 2003 02:32:24 +1000 [thread overview]
Message-ID: <20030916010313.EE0812C799@lists.samba.org> (raw)
In-Reply-To: Your message of "Mon, 15 Sep 2003 10:23:06 +0100." <20030915102306.A22451@flint.arm.linux.org.uk>
In message <20030915102306.A22451@flint.arm.linux.org.uk> you write:
> On Mon, Sep 15, 2003 at 01:41:30PM +1000, Rusty Russell wrote:
> > ....hiding the subtlety in wrapper functions is the wrong approach. We
> > have excellent wait_event, wait_event_interruptible and
> > wait_event_interruptible_timeout macros in wait.h which these drivers
> > should be using, which would make them simpler, less buggy and
> > smaller.
>
> "smaller and simpler" hmm. And _more_ buggy. Let's take this case:
>
> add_wait_queue(&wq, &wait);
> for (;;) {
> set_current_state(TASK_INTERRUPTIBLE);
> if (condition)
> break;
> if (file->f_flags & O_NONBLOCK) {
> ret = -EAGAIN;
> break;
> }
> if (signal_pending(current)) {
> ret = -ERESTARTSYS;
> break;
> }
> schedule();
> }
> __set_current_state(TASK_RUNNING);
> remove_wait_queue(&wq, &wait);
>
> There are cases like the above which make the wait_event*() macros
> inappropriate:
There are, sure, but I'm not sure this is really one:
ret = 0;
if (file->f_flags & O_NONBLOCK) {
if (!condition)
ret = -EAGAIN;
} else
wait_event_interruptible(&wq, condition, &ret);
AFAICT this is equivalent, and clearer?
> - needing to atomically dequeue some data
Definitely: the futex code is a good example of this. But the
presence of spinlocks actually makes the barrier issue vanish anyway.
> I've yet to see anyone using wait_event*() in these circumstances -
> they're great for your simple "did something happen" case which the
> majority of drivers use, but there are use cases where wait_event*()
> is not appropriate.
I don't mind someone doing something weird and needing to use lower
primitives, but I still feel the wait_event* family are badly
underused. Perhaps it's just lack of publicity...
Cheers!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
prev parent reply other threads:[~2003-09-16 1:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-12 18:20 Felipe W Damasio
2003-09-12 18:33 ` Felipe W Damasio
2003-09-15 9:39 ` Rusty Russell
2003-09-16 12:05 ` Jamie Lokier
2003-09-13 19:02 ` Jamie Lokier
2003-09-15 1:36 ` Rusty Russell
2003-09-14 11:39 ` Rusty Russell
2003-09-14 14:08 ` Jamie Lokier
2003-09-15 3:41 ` Rusty Russell
2003-09-15 9:23 ` Russell King
2003-09-15 16:32 ` Rusty Russell [this message]
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=20030916010313.EE0812C799@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=felipewd@terra.com.br \
--cc=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
/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®