From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: Brandon Philips <brandon@ifup.org>
Cc: video4linux-list@redhat.com, v4l-dvb-maintainer@linuxtv.org,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH] v4l: Deadlock in videobuf-core for DQBUF waiting on QBUF
Date: Tue, 4 Mar 2008 10:45:16 -0300 [thread overview]
Message-ID: <20080304104516.21fcf30f@gaivota> (raw)
In-Reply-To: <20080303081305.GA18774@plankton.ifup.org>
On Mon, 3 Mar 2008 00:13:05 -0800
Brandon Philips <brandon@ifup.org> wrote:
> On 06:34 Fri 29 Feb 2008, Mauro Carvalho Chehab wrote:
> > On Wed, 27 Feb 2008 18:56:51 -0800
> > Brandon Philips <brandon@ifup.org> wrote:
> >
> > > On 09:08 Wed 27 Feb 2008, Jonathan Corbet wrote:
> > > > Brandon Philips <brandon@ifup.org> wrote:
> > > >
> > > > > buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
> > > > > + mutex_unlock(&q->vb_lock);
> > > > > retval = videobuf_waiton(buf, nonblocking, 1);
> > > > > + mutex_lock(&q->vb_lock);
> > > >
> > > > Are you sure that this doesn't create a race where two threads could end
> > > > up waiting on the same buf?
> > >
> > > You are right... I thought I had thought through this but a race can be
> > > created with two threads doing DQBUF.
> > >
> > > > Actually, almost anything could happen to buf by the time you've
> > > > gotten the mutex back - it might not even exist anymore - but there
> > > > are no checks for that. It seems like a better fix might be to set
> > > > nonblocking unconditionally to 1 for the videobuf_waiton() call, then
> > > > start over from the beginning on a -EAGAIN return (if the caller has
> > > > not requested nonblocking behavior).
> > >
> > > Hrm, that is one solution. I will think about it for a bit and submit a
> > > new patch.
> > >
> > > Thanks for catching this, I was being stupid.
> > >
> > > Mauro: Please don't push this patch out. Thanks.
> >
> > The patch were already applied at the staging tree. I'll keep it there until we
> > have a definitive solution. After that, the better would be to fold the both
> > patches and send to 2.6.25-rc.
>
> Quick update:
>
> Sorry for the delay I was mentoring my robotics team since Thursday.
>
> I wrote a test program (attached, super hacky) and I have found that the
> current vivi can easily hang a kernel on a spinlock even before my
> patch...
Argh!
>
> I will work on fixing this tomorrow before fixing the videobuf issue. I
> would like to be able to test my fix before submitting it this time.
This would be nice.
About your testing program, it would be a good idea to add it at v4l2-apps/test
dir. The original non-threaded code from V4L2 specs is also there.
Cheers,
Mauro
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
next prev parent reply other threads:[~2008-03-04 13:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-27 7:54 [PATCH] v4l: Deadlock in videobuf-core for DQBUF waiting on QBUF Brandon Philips
2008-02-27 20:09 ` [v4l-dvb-maintainer] " Trent Piepho
[not found] ` <20679.1204128530@vena.lwn.net>
2008-02-28 2:56 ` Brandon Philips
2008-02-29 9:34 ` Mauro Carvalho Chehab
2008-03-03 8:13 ` Brandon Philips
2008-03-04 13:45 ` Mauro Carvalho Chehab [this message]
2008-03-04 20:14 ` Brandon Philips
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=20080304104516.21fcf30f@gaivota \
--to=mchehab@infradead.org \
--cc=brandon@ifup.org \
--cc=corbet@lwn.net \
--cc=v4l-dvb-maintainer@linuxtv.org \
--cc=video4linux-list@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox