public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Alan Cox <alan@redhat.com>,
	video4linux-list@redhat.com, linux-kernel@vger.kernel.org,
	Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCH] video4linux: Push down the BKL
Date: Tue, 27 May 2008 13:31:00 -0300	[thread overview]
Message-ID: <20080527133100.6a9302fb@gaivota> (raw)
In-Reply-To: <20080527094144.1189826a@bike.lwn.net>

On Tue, 27 May 2008 09:41:44 -0600
Jonathan Corbet <corbet@lwn.net> wrote:


> > A next step would be to move the drivers to use the serialized one. 
> 
> So we're replacing the big kernel lock with the big v4l2 lock.  That
> might help the situation, but you'd need to be sure to serialize
> against other calls (open(), for example) which are also currently done
> under the BKL.

True, but on a quick analysis, I suspect that this is already somewhat broken
on some drivers.

Since the other methods don't explicitly call BKL (and, AFAIK, kernel open
handler don't call it neither), if a program 1 is opening a device and
initializing some data, and a program 2 starts doing ioctl, interrupting
program 1 execution in the middle of a data initialization procedure, you may
have a race condition, since some devices initialize some device global data
during open [1].

[1] For example: cx88 and saa7134 will change some data structures if you open
a device via /dev/radio or via /dev/video. So, if program 1 opens as radio and
program 2 opens as video, you may have a race condition. A way to fix this is to
initialize such structs only by the first program that is opening the device,
and serialize a concurrent open.

> > IMO, we need to create a multi-thread stress userspace tool for
> > checking the locks at the ioctls. There are a few testing utils at
> > mercurial tree, under v4l2-apps/test. This can be a starting point
> > for this tool. Also, Brandon improved one of those tools to work with
> > multithread.
> 
> I don't think that stress tools are the way to eliminate the BKL.
> You'll never find all the problems that way.  There's really no way to
> avoid the task of actually *looking* at each driver and ensuring that
> it has its act together with regard to locking.

True. Yet, just looking at the code may not be enough, since people make
mistakes. The recent changes at videobuf lock showed this. The lock fix
patches caused several new locking issues.

It is safer to have a tool to test and stress the driver before going to
production.

Cheers,
Mauro

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

  parent reply	other threads:[~2008-05-27 16:31 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-22 21:37 [PATCH] video4linux: Push down the BKL Alan Cox
2008-05-23  2:08 ` Andy Walls
2008-05-23  6:16   ` Hans Verkuil
2008-05-23  6:28     ` Hans Verkuil
2008-05-26 16:39     ` Mauro Carvalho Chehab
2008-05-23  9:09   ` Alan Cox
2008-05-26 16:34     ` Mauro Carvalho Chehab
2008-05-26 16:46       ` Hans Verkuil
2008-05-26 21:14         ` Mauro Carvalho Chehab
2008-06-01  2:34         ` [PATCH] cx18: convert driver to video_ioctl2() (Re: [PATCH] video4linux: Push down the BKL) Andy Walls
2008-06-01 10:15           ` Hans Verkuil
2008-06-01 19:01             ` Andy Walls
2008-06-03 21:20               ` Mauro Carvalho Chehab
2008-06-03 22:08                 ` [ivtv-devel] " Alan Cox
2008-06-04  0:44                   ` Andy Walls
2008-06-04 10:02                     ` Alan Cox
     [not found] ` <9027.1211551014@vena.lwn.net>
2008-05-23 15:39   ` [PATCH] video4linux: Push down the BKL Alan Cox
     [not found]     ` <15168.1211558968@vena.lwn.net>
2008-05-23 18:58       ` Alan Cox
2008-05-23 19:05 ` Hans Verkuil
2008-05-25 23:46 ` Mike Isely
2008-05-26 16:59 ` Mauro Carvalho Chehab
2008-05-26 20:23   ` Alan Cox
2008-05-26 21:10     ` Mauro Carvalho Chehab
2008-05-26 22:01       ` Alan Cox
2008-05-27 13:10         ` Mauro Carvalho Chehab
     [not found]           ` <20080527094144.1189826a@bike.lwn.net>
2008-05-27 16:31             ` Mauro Carvalho Chehab [this message]
2008-05-27 18:14               ` Alan Cox
     [not found]               ` <20080527103755.1fd67ec1@bike.lwn.net>
2008-05-27 18:59                 ` Mauro Carvalho Chehab
2008-05-27 19:26                   ` Devin Heitmueller
2008-05-27 21:00                     ` Mauro Carvalho Chehab
2008-05-27 21:22                       ` Devin Heitmueller
2008-05-27 23:48                       ` Andy Walls
2008-05-28  0:46                         ` Devin Heitmueller
2008-05-28  2:37                           ` Andy Walls
2008-05-28  2:47                             ` Devin Heitmueller
2008-05-28 23:30                               ` Andy Walls
2008-05-28  8:34                             ` Alan Cox
2008-05-28  6:13                           ` Hans Verkuil
     [not found]                   ` <20080527125041.0fc28fd4@infradead.org>
2008-05-27 20:24                     ` Mauro Carvalho Chehab

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=20080527133100.6a9302fb@gaivota \
    --to=mchehab@infradead.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=alan@redhat.com \
    --cc=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.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