On Sat, Jul 29, 2000 at 10:50:28PM +0200, Gary Funck wrote:
> On Jul 29, 10:24pm, Andi Kleen wrote:
> > 
> > > 
> > > In 2.4, does the 'read actor' (ie, for ext2) optimize the case where
> > > the part of the I/O request being handled has a user-level address that
> > > is page aligned, and the requested bytes to transfer are at least one
> > > full page?  Ie, does it handle the 'copy' by simply remapping the I/O
> > > page directly into the user's address space (avoiding a copy)?
> > 
> > No, because you cannot avoid the copy anyways because you need to maintain
> > cache coherency in the page cache. If you want zero copy IO use mmap().
> 
> Couldn't that be taken care of, by implementing copy-on-write semantics
> on the user-level page that has been (hypothetically) remapped by
> the "copy agent"?  It would seem that the common case would be not to
> modify the data buffer that was just read, and the copy-on-write would
> be typically unneeded.

Write protecting pages is very expensive, especially on SMP machines where
the TLB updates may have to be broadcasted to other CPUs when you have
multiple threads.

> 
> Does glibc implement fread() and friends using mmap(), when reading
> from a file?  Would there be something to be gained from that?
> Alternatively, if the file system implemented zero copy semantics
> in read(), there'd be no need to push the optimization to a higer
> level (ie, into glibc).

Why asking when you can easily check yourself ?

-Andi

Reply via email to