From: Arnd Bergmann <arnd@arndb.de>
To: Nishanth Aravamudan <nacc@us.ibm.com>
Cc: Nish Aravamudan <nish.aravamudan@gmail.com>,
Sergey Vlasov <vsu@altlinux.ru>,
Al Borchers <alborchers@steinerpoint.com>,
david-b@pacbell.net, greg@kroah.com,
linux-kernel@vger.kernel.org
Subject: Re: [RFC UPDATE PATCH] add wait_event_*_lock() functions and comments
Date: Tue, 15 Feb 2005 18:50:45 +0100 [thread overview]
Message-ID: <200502151850.46217.arnd@arndb.de> (raw)
In-Reply-To: <20050215010435.GD2403@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1525 bytes --]
On Dinsdag 15 Februar 2005 02:04, Nishanth Aravamudan wrote:
> Here's at least one example:
>
> drivers/ieee1394/video1394.c:__video1394_ioctl()
>
AFAICS, that one should work just fine using after converting
while (d->buffer_status[v.buffer]!= VIDEO1394_BUFFER_READY) {
spin_unlock_irqrestore(&d->lock, flags);
interruptible_sleep_on(&d->waitq);
spin_lock_irqsave(&d->lock, flags);
if (signal_pending(current)) {
spin_unlock_irqrestore(&d->lock,flags);
return -EINTR;
}
}
to
static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d,
unsigned int buffer)
{
unsigned long flags;
unsigned int ret;
spin_lock_irqsave(&d->lock, flags);
ret = d->buffer_status[buffer];
spin_unlock_irqrestore(&d->lock, flags);
return ret;
}
...
spin_unlock_irqrestore(&d->lock, flags);
if (wait_event_interruptible(d->waitq,
video1394_buffer_state(d, v.buffer) == VIDEO1394_BUFFER_READY))
return -EINTR;
spin_lock_irqsave(&d->lock, flags);
The trick here is that it is known in advance that the state does not actually
have to be protected by the lock after reading it, because the state can not
change from READY to FREE in any other place in the code.
One exception might be two processes calling the ioctl at the same time, but
I think that is racy will any of these variations.
Arnd <><
[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2005-02-15 18:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-11 7:07 [RFC PATCH] add wait_event_*_lock() functions Al Borchers
2005-02-11 17:31 ` Nishanth Aravamudan
2005-02-11 19:55 ` [RFC UPDATE PATCH] add wait_event_*_lock() functions and comments Nishanth Aravamudan
2005-02-12 11:38 ` Arnd Bergmann
2005-02-12 13:28 ` Sergey Vlasov
2005-02-13 2:41 ` Arnd Bergmann
2005-02-13 5:00 ` Nish Aravamudan
2005-02-15 1:04 ` Nishanth Aravamudan
2005-02-15 17:50 ` Arnd Bergmann [this message]
2005-02-15 18:19 ` Nish Aravamudan
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=200502151850.46217.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=alborchers@steinerpoint.com \
--cc=david-b@pacbell.net \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nacc@us.ibm.com \
--cc=nish.aravamudan@gmail.com \
--cc=vsu@altlinux.ru \
/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