LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sarah Bailey <saharabeara@gmail.com>
To: Kernel development list <linux-kernel@vger.kernel.org>,
	usb-hacking@svcs.cs.pdx.edu,
	USB development list <linux-usb-devel@lists.sourceforge.net>
Subject: Re: [linux-usb-devel] usbfs2: Why asynchronous I/O?
Date: Mon, 26 Feb 2007 00:54:31 -0800	[thread overview]
Message-ID: <20070226085431.GA16499@localdomain> (raw)
In-Reply-To: <20070225173302.GA12190@comsec.com> <200702250853.03851.david-b@pacbell.net> <Pine.LNX.4.44L0.0702251147500.25265-100000@netrider.rowland.org>

[-- Attachment #1: Type: text/plain, Size: 4602 bytes --]

On Sun, Feb 25, 2007 at 08:53:03AM -0800, David Brownell wrote:
> On Sunday 25 February 2007 12:57 am, Sarah Bailey wrote:
> > I haven't seen any evidence that the kernel-side aio is substantially
> > more efficient than the GNU libc implementation,
> 
> Face it:  spawning a new thread is fundamentally not as lightweight
> as just submitting an aiocb plus an URB.  And spawning ten threads
> costs a *LOT* more than submitting ten aiocbs and URBs.  (Count just
> the 4KB stacks associated with each thread, vs memory consumed by
> using AIO ... and remember to count the scheduling overheads.)

Yes, spawning a new thread is costly.  However, if someone writes their
own thread-based program and allocates the threads from a pool, that
argument is irrelevant.  Even with fibrils, you have a stack and
scheduling overhead.  With kernel AIO, you have also have some memory
overhead, and you also have context switch overhead when you call
kick_iocb or aio_complete.

Can someone point me at hard evidence one way or another?

> > so it seems like it would be better to leave the complexity in
> > userspace. 
> 
> Thing is, the kernel *already* has URBs.  And the concept behind them
> maps one-to-one onto AIOCBs.  All the kernel needs to expose is:
> mechanisms to submit (and probably cancel) async requests, then collect
> the responses when they're done.

It seems to me that you're arguing that URBs and AIOCBs go together on
the basis that they are both asynchronous and both have some sort of
completion function.  Just because two things are alike doesn't mean
that it's better to use them together.

> You're right that associating a thread with an URB is complexity.

That's not what I said.  I don't think that the libc implementation is
more complex than the kernel AIO implementation.  The libc code is
smaller than the kernel AIO (the core code in aio_misc.c is 721 lines,
while the kernel AIO core code is 1769 lines).  The libc code is simpler
and easier to understand, and therefore may be less error prone.

> > I also doubt that 
> > most userspace application writers know they aren't getting kernel-side
> > aio when they use aio_read(3) and aio_write(3).  Why implement something
> > that isn't going to be used?
> 
> I can't much help application writers that don't bother to read the
> relevant documentation (after it's been pointed out to them).

Where is this documentation?  There's a man page on io_submit, etc., but
how would an application writer know to look for it?  I've grepped
through the Documentation directory, and I didn't find anything that
looked relevant. 

> The gap between POSIX AIO and kernel AIO has been an ongoing problem.  This
> syslet/fibril/yadda-yadda stuff is just the latest spin.

Do you think that fibrils will replace the kernel AIO?  It seems like a
logicial conclusion, but does the kernel AIO give you anything more?
For example, I think it currently allows drivers to guarantee that the
requests will be queued in the order they are submitted.  GNU libc and
fibrils can't make that guarantee because the operations may block
before the request enters the hardware queue.  

On Sun, Feb 25, 2007 at 09:33:02AM -0800, Eric Blossom wrote:
> On Sun, Feb 25, 2007 at 08:53:03AM -0800, David Brownell wrote:
> > Without it, how would you achieve I/O overlap, and thus maximize the
> > I/O throughput accessible when streaming data to/from userspace?  The
> > description you gave of glibc aio support sure sounded to me like it
> > was incapable of achieving much in the way of I/O overlap.
> 
> I heartily agree with this sentiment.  The only way we've been able to
> sustain 32MB/s read and write bulk transfers across the USB from user
> space is by using the usbfs USBDEVFS_SUBMITURB ioctl.  We typically
> run with 8 to 16 outstanding requests, each around 4kB.

GNU libc can overlap I/O.  It implements the userland equivalent of
fibrils.  No one is arguing that we don't need I/O overlap. :)

> FWIW, the peripheral we're using is the Universal Software Radio
> Peripheral (USRP).  It's basically an FX2, FPGA, ADC's and DAC's.
>
> The code we use for this is in the GNU Radio code base,
> http://gnuradio.org/trac/wiki
> 
> The relevant part is usrp/host/lib/fusb*.{h,cc}

Yes, a sane interface to the USRP was one of the main motivations for
the new USB filesystem.  It remains to be seen whether we need a
non-standard interface like io_submit, or whether threads with blocking
I/O is fast enough and has the right semantics.

Sarah Bailey

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2007-02-26  8:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070225085755.GA4886@localdomain>
     [not found] ` <200702250853.03851.david-b@pacbell.net>
     [not found]   ` <20070225173302.GA12190@comsec.com>
2007-02-25 16:51     ` Alan Stern
2007-02-25 23:55       ` Greg KH
2007-02-26  2:22         ` Alan Stern
2007-02-26  8:54       ` Sarah Bailey [this message]
2007-02-27  0:20         ` Greg KH
2007-02-28 20:03         ` David Brownell
2007-02-25 17:42 David Brownell

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=20070226085431.GA16499@localdomain \
    --to=saharabeara@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=usb-hacking@svcs.cs.pdx.edu \
    --subject='Re: [linux-usb-devel] usbfs2: Why asynchronous I/O?' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).