public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Adam Baker <linux@baker-net.org.uk>
To: Andy Walls <awalls@radix.net>
Cc: "Jean-Francois Moine" <moinejf@free.fr>,
	kilgota@banach.math.auburn.edu, linux-media@vger.kernel.org
Subject: Re: [PATCH] Add support for sq905 based cameras to gspca
Date: Wed, 4 Feb 2009 21:38:04 +0000	[thread overview]
Message-ID: <200902042138.05028.linux@baker-net.org.uk> (raw)
In-Reply-To: <1233714808.3086.57.camel@palomino.walls.org>

On Wednesday 04 February 2009, Andy Walls wrote:
> On Tue, 2009-02-03 at 22:09 +0000, Adam Baker wrote:
> > On Tuesday 03 February 2009, Jean-Francois Moine wrote:
> > > Indeed, the problem is there! You must have only one process reading
> > > the webcam! I do not see how this can work with these 2 processes...
> >
> > Although 2 processes are created only one ever gets used.
> > create_singlethread_workqueue would therefore be less wasteful but make
> > no other difference.
>
> This is generally not the case.  There is a single workqueue as far as a
> driver is concerned.  Work items submitted to the queue by the driver
> are set to be processed by the same CPU submitting the work item (unless
> you call queue_work_on() to specify the CPU).  However, there is no
> guarantee that the same CPU will be submitting work requests to the
> workqueue every time.
>
> For most drivers this is a moot point though, because they only ever
> instantiate and submit one work object ever per device.  This means the
> workqueue depth never exceeds 1 for most drivers.  So the correct
> statement would be, I believe, "only one sq905 worker thread ever gets
> used (per device per capture) at a time in sq905.c"

Yes, I did mean only one gets used in the case of sq905.c (because the queue 
is created per capture and only one item gets submitted to it).

<snip>
>
> I did look at the patch as submitted on Jan 19, and do have what I
> intend to be constructive criticisms (sorry if they're overcome by
> events by now):
>
> Creating and destroying the worker thread(s) at the start and stop of
> each capture is a bit overkill.  It's akin to registering and
> unregistering a device's interrupt handler before and after every
> capture, but it's a bit worse overhead-wise.  It's probably better to
> just instantiate the workqueue when the device "appears" (I'm not a USB
> guy so insert appropraite term there) and destroy the workqueue and
> worker threads(s) when the device is going to "disappear".  Or if it
> will meet your performance requirements, create and destroy the
> workqueue when you init and remove the module.  The workqueue and its
> thread(s) are essentially the bottom half of your interrupt handler to
> handle deferrable work - no point in killing them off until you really
> don't need them anymore.
>

My thought was that the camera was likely to remain plugged in even if it 
wasn't being used so it was best to clean up as much as possible when it 
wasn't in use. I don't really know how the overheads of creating a workqueue 
when you do need it compares to leaving an unused one around sitting on the 
not ready queue in the process table but starting a capture is going to take 
many ms just for the USB traffic so a little extra overhead doesn't seem too 
worrying.

> Also, you've created the workqueue threads with a non-unique name: the
> expansion of MODULE_NAME.  You're basically saying that you only need
> one workqueue, with it's per CPU thread(s), for all instantiations of an
> sq905 device - which *can* be a valid design choice.  However, you're
> bringing them up and tearing them down on a per capture basis.  That's a
> problem that needs to be corrected if you intend to support multiple
> sq905 devices on a single machine.  What happens when you attempt to
> have two sq905 devices do simultaneous captures?  I don't know myself;
> I've never tried to create 2 separate instantiations of a workqueue
> object with the same name.
>

I see multiple instance of [pdflush] and [nfsd] which seem to work fine so I 
believe the name doesn't need to be unique, just a guide to the user of what 
is eating CPU time. I don't have 2 sq905 cameras to test it but I have had 
left over workqueues caused by a driver bug stopping it shut down and new 
ones that started also worked fine.

>
> Regards,
> Andy



  reply	other threads:[~2009-02-04 21:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-19 23:22 [PATCH] Add support for sq905 based cameras to gspca Adam Baker
2009-01-20  3:33 ` Alexey Klimov
2009-01-21 17:20 ` Jean-Francois Moine
2009-01-21 19:10   ` kilgota
2009-01-22  4:17   ` Why not to try to combine sq905 and sq kilgota
     [not found] ` <200901272101.27451.linux@baker-net.org.uk>
     [not found]   ` <alpine.LNX.2.00.0901271543560.21122@banach.math.auburn.edu>
     [not found]     ` <200901272228.42610.linux@baker-net.org.uk>
     [not found]       ` <20090128113540.25536301@free.fr>
     [not found]         ` <alpine.LNX.2.00.0901281554500.22748@banach.math.auburn.edu>
     [not found]           ` <20090131203650.36369153@free.fr>
     [not found]             ` <alpine.LNX.2.00.0902022032230.1080@banach.math.auburn.edu>
2009-02-03  9:39               ` [PATCH] Add support for sq905 based cameras to gspca Jean-Francois Moine
2009-02-03 17:30                 ` kilgota
2009-02-03 18:21                   ` kilgota
2009-02-03 18:13                     ` Jean-Francois Moine
2009-02-03 19:15                       ` kilgota
2009-02-03 19:23                         ` Jean-Francois Moine
2009-02-03 19:54                           ` kilgota
2009-02-03 19:47                             ` Jean-Francois Moine
2009-02-03 19:59                             ` Alan Stern
2009-02-03 22:23                               ` kilgota
2009-02-04  2:02                                 ` Alan Stern
2009-02-04  3:12                                   ` kilgota
2009-02-03 22:09                           ` Adam Baker
2009-02-03 22:28                             ` kilgota
2009-02-04  1:59                             ` Alan Stern
2009-02-04  2:33                             ` Andy Walls
2009-02-04 21:38                               ` Adam Baker [this message]
2009-02-04 22:31                                 ` kilgota
2009-02-04 22:34                                   ` Adam Baker
2009-02-04 22:53                                     ` kilgota
2009-02-04 23:09                                       ` kilgota
2009-02-03 19:42                       ` kilgota
2009-02-03 19:53                       ` Alan Stern

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=200902042138.05028.linux@baker-net.org.uk \
    --to=linux@baker-net.org.uk \
    --cc=awalls@radix.net \
    --cc=kilgota@banach.math.auburn.edu \
    --cc=linux-media@vger.kernel.org \
    --cc=moinejf@free.fr \
    /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