public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* zero-copy read() interface
@ 2005-08-18 10:01 Folkert van Heusden
  2005-08-18 10:05 ` Jörn Engel
  2005-08-18 10:06 ` Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Folkert van Heusden @ 2005-08-18 10:01 UTC (permalink / raw)
  To: linux-kernel

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

What about a zero-copy read-interface?
An ioctl (or something) which enables the kernel to do dma directly to
the userspace. Of course this should be limited to the root-user or a
user with special capabilities (rights) since if a drive screws up, data
from a different sector (or so) might end up in the proces' memory. Of
course copying a sector from kernel- to userspace can be done pretty
fast but i.m.h.o. all possible speedimprovements should be made unless
unclean.


Folkert van Heusden

-- 
Auto te koop, zie: http://www.vanheusden.com/daihatsu.php
----------------------------------------------------------------------
Get your PGP/GPG key signed at www.biglumber.com!
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zero-copy read() interface
  2005-08-18 10:01 zero-copy read() interface Folkert van Heusden
@ 2005-08-18 10:05 ` Jörn Engel
  2005-08-18 10:41   ` Folkert van Heusden
  2005-08-18 10:06 ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Jörn Engel @ 2005-08-18 10:05 UTC (permalink / raw)
  To: Folkert van Heusden; +Cc: linux-kernel

On Thu, 18 August 2005 12:01:52 +0200, Folkert van Heusden wrote:
> 
> What about a zero-copy read-interface?
> An ioctl (or something) which enables the kernel to do dma directly to
> the userspace. Of course this should be limited to the root-user or a
> user with special capabilities (rights) since if a drive screws up, data
> from a different sector (or so) might end up in the proces' memory. Of
> course copying a sector from kernel- to userspace can be done pretty
> fast but i.m.h.o. all possible speedimprovements should be made unless
> unclean.

Just use mmap().  Unlike your proposal, it cooperates with the page
cache.

Jörn

-- 
Don't worry about people stealing your ideas. If your ideas are any good,
you'll have to ram them down people's throats.
-- Howard Aiken quoted by Ken Iverson quoted by Jim Horning quoted by
   Raph Levien, 1979

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zero-copy read() interface
  2005-08-18 10:01 zero-copy read() interface Folkert van Heusden
  2005-08-18 10:05 ` Jörn Engel
@ 2005-08-18 10:06 ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2005-08-18 10:06 UTC (permalink / raw)
  To: Folkert van Heusden; +Cc: linux-kernel

On Thu, Aug 18, 2005 at 12:01:52PM +0200, Folkert van Heusden wrote:
> What about a zero-copy read-interface?
> An ioctl (or something) which enables the kernel to do dma directly to
> the userspace. Of course this should be limited to the root-user or a
> user with special capabilities (rights) since if a drive screws up, data
> from a different sector (or so) might end up in the proces' memory. Of
> course copying a sector from kernel- to userspace can be done pretty
> fast but i.m.h.o. all possible speedimprovements should be made unless
> unclean.

It's called O_DIRECT, and doesn't need root, just some alignment-constraints.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zero-copy read() interface
  2005-08-18 10:05 ` Jörn Engel
@ 2005-08-18 10:41   ` Folkert van Heusden
  2005-08-18 13:13     ` Jörn Engel
                       ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Folkert van Heusden @ 2005-08-18 10:41 UTC (permalink / raw)
  To: Jörn Engel; +Cc: linux-kernel

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

> > What about a zero-copy read-interface?
> > An ioctl (or something) which enables the kernel to do dma directly to
> > the userspace. Of course this should be limited to the root-user or a
> > user with special capabilities (rights) since if a drive screws up, data
> > from a different sector (or so) might end up in the proces' memory. Of
> > course copying a sector from kernel- to userspace can be done pretty
> > fast but i.m.h.o. all possible speedimprovements should be made unless
> > unclean.
> Just use mmap().  Unlike your proposal, it cooperates with the page
> cache.

Doesn't that one also use copying? I've also heard that using mmap is
expensive due to pagefaulting. I've found, for example, that copying a
1.3GB file using read/write instead of mmap & memcpy is seconds faster.


Folkert van Heusden

-- 
Auto te koop, zie: http://www.vanheusden.com/daihatsu.php
----------------------------------------------------------------------
Get your PGP/GPG key signed at www.biglumber.com!
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zero-copy read() interface
  2005-08-18 10:41   ` Folkert van Heusden
@ 2005-08-18 13:13     ` Jörn Engel
  2005-08-18 23:34     ` dean gaudet
  2005-08-21  9:01     ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: Jörn Engel @ 2005-08-18 13:13 UTC (permalink / raw)
  To: Folkert van Heusden; +Cc: linux-kernel

On Thu, 18 August 2005 12:41:32 +0200, Folkert van Heusden wrote:
>
> > Just use mmap().  Unlike your proposal, it cooperates with the page
> > cache.
> 
> Doesn't that one also use copying? I've also heard that using mmap is
> expensive due to pagefaulting. I've found, for example, that copying a
> 1.3GB file using read/write instead of mmap & memcpy is seconds faster.

Since you don't consider device DMA to be a copy, no, it doesn't.  The
data is transferred into page cache, then the pages are mapped into
your processes memory without an additional copy.

The pagefaulting isn't free either, I agree.  And for streaming
accesses like your copy of a large file, taking one fault per 4k
copied is not an ideal case.

Most likely you'd want Linus' pipe stuff for copying a large file
without ever looking at the data.  That work is still unfinished,
though, and I'm currently lacking time to work on it.

Jörn

-- 
He that composes himself is wiser than he that composes a book.
-- B. Franklin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zero-copy read() interface
  2005-08-18 10:41   ` Folkert van Heusden
  2005-08-18 13:13     ` Jörn Engel
@ 2005-08-18 23:34     ` dean gaudet
  2005-08-19  8:33       ` Jörn Engel
  2005-08-21  9:01     ` Andrew Morton
  2 siblings, 1 reply; 8+ messages in thread
From: dean gaudet @ 2005-08-18 23:34 UTC (permalink / raw)
  To: Folkert van Heusden; +Cc: Jörn Engel, linux-kernel

On Thu, 18 Aug 2005, Folkert van Heusden wrote:

> Doesn't that one also use copying? I've also heard that using mmap is
> expensive due to pagefaulting. I've found, for example, that copying a
> 1.3GB file using read/write instead of mmap & memcpy is seconds faster.

why would you memcpy if you're using mmap()?  just write() the mmap()d 
region.

-dean

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zero-copy read() interface
  2005-08-18 23:34     ` dean gaudet
@ 2005-08-19  8:33       ` Jörn Engel
  0 siblings, 0 replies; 8+ messages in thread
From: Jörn Engel @ 2005-08-19  8:33 UTC (permalink / raw)
  To: dean gaudet; +Cc: Folkert van Heusden, linux-kernel

On Thu, 18 August 2005 16:34:18 -0700, dean gaudet wrote:
> On Thu, 18 Aug 2005, Folkert van Heusden wrote:
> 
> > Doesn't that one also use copying? I've also heard that using mmap is
> > expensive due to pagefaulting. I've found, for example, that copying a
> > 1.3GB file using read/write instead of mmap & memcpy is seconds faster.
> 
> why would you memcpy if you're using mmap()?  just write() the mmap()d 
> region.

Still unnecessary.  Userspace doesn't want to see the data at all, so
it shouldn't.  The solution should either be sendfile(2), which Linus
doesn't like much, or the upcoming pipe stuff.

Jörn

-- 
Linux [...] existed just for discussion between people who wanted
to show off how geeky they were.
-- Rob Enderle

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zero-copy read() interface
  2005-08-18 10:41   ` Folkert van Heusden
  2005-08-18 13:13     ` Jörn Engel
  2005-08-18 23:34     ` dean gaudet
@ 2005-08-21  9:01     ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2005-08-21  9:01 UTC (permalink / raw)
  To: Folkert van Heusden; +Cc: joern, linux-kernel

Folkert van Heusden <folkert@vanheusden.com> wrote:
>
> > > What about a zero-copy read-interface?
> > > An ioctl (or something) which enables the kernel to do dma directly to
> > > the userspace. Of course this should be limited to the root-user or a
> > > user with special capabilities (rights) since if a drive screws up, data
> > > from a different sector (or so) might end up in the proces' memory. Of
> > > course copying a sector from kernel- to userspace can be done pretty
> > > fast but i.m.h.o. all possible speedimprovements should be made unless
> > > unclean.
> > Just use mmap().  Unlike your proposal, it cooperates with the page
> > cache.
> 
> Doesn't that one also use copying? I've also heard that using mmap is
> expensive due to pagefaulting. I've found, for example, that copying a
> 1.3GB file using read/write instead of mmap & memcpy is seconds faster.
> 

You can use remap_file_pages() to read all the pages into pagecache and
then instantiate all their pte's in a single syscall.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-08-21  9:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-18 10:01 zero-copy read() interface Folkert van Heusden
2005-08-18 10:05 ` Jörn Engel
2005-08-18 10:41   ` Folkert van Heusden
2005-08-18 13:13     ` Jörn Engel
2005-08-18 23:34     ` dean gaudet
2005-08-19  8:33       ` Jörn Engel
2005-08-21  9:01     ` Andrew Morton
2005-08-18 10:06 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox