Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for June 20, 2013
Pencil, Pencil, and Pencil
Dividing the Linux desktop
LWN.net Weekly Edition for June 13, 2013
A report from pgCon 2013
Is splice going to deprecate sendfile(2)?
Two new system calls: splice() and sync_file_range()
Posted Apr 4, 2006 14:13 UTC (Tue) by zlynx (subscriber, #2285)
Posted Apr 4, 2006 15:02 UTC (Tue) by axboe (subscriber, #904)
And what becomes of zero-copy?
Posted Apr 6, 2006 1:13 UTC (Thu) by xoddam (subscriber, #2322)
It is zero-copy
Posted Apr 6, 2006 5:59 UTC (Thu) by axboe (subscriber, #904)
Posted Apr 6, 2006 6:42 UTC (Thu) by xoddam (subscriber, #2322)
Posted Apr 6, 2006 7:16 UTC (Thu) by axboe (subscriber, #904)
Yeah it sounds crazy, but it's really true :-). You bring in the pages from the source file, then migrate them to the address space of the target file. Bingo, zero copy copies!
Posted Apr 7, 2006 22:46 UTC (Fri) by giraffedata (subscriber, #1954)
A splice-based file copy does one disk-disk copy, and no memory-memory copy, as contrasted with the traditional file copy that does one disk-disk copy plus two memory-memory copies.
Since the naive observer wouldn't even expect there to be memory-memory copies involved in copying files, "zero copy file copy" shouldn't sound odd at all.
Posted Apr 8, 2006 11:14 UTC (Sat) by axboe (subscriber, #904)
A normal copy will DMA those pages in, allocate pages in the target file address space, copy that data over, and then it'll be DMA'ed to disk again. So two DMA operations, and one full copy of all the data.
So a splice based copy will be zero memory copies, and two DMA "copies" (the dma operation above may be a series of dma transactions, depending on how large the file is). A normal copy contains the same number of DMA operations, but includes a memory copy.
Posted Apr 8, 2006 17:31 UTC (Sat) by giraffedata (subscriber, #1954)
So a splice based copy will be zero memory copies, and two DMA "copies"
I presume "copies" is in quotes because you agree with me that the DMA operations are not copies in the sense we're talking about. (If they were, a "zero-copy" file read wouldn't be zero-copy, and moving data from kernel file data cache to user space would be two copies (kernel memory to register, register to user memory)).
However, the combination of the two DMAs constitutes one disk copy. A disk copy is an instance of replicating data from one place on a disk to another, just as a memory copy is an instance of replicating data from one place in memory to another. And it's worth talking about because it takes time. If you could truly do a zero-copy copy, that would be remarkable. As it stands, "zero-copy copy" is just a trick of words in which you change the definition of copy in the middle of the sentence.
A normal copy contains the same number of DMA operations, but includes a memory copy.
Actually, the most normal file copy includes two memory copies -- from kernel file data cache of the source file to user space buffer, and from that buffer to the other file's kernel file data cache. With mmap, you can get it down to one, and with direct I/O you can get to zero.
Posted Apr 8, 2006 18:26 UTC (Sat) by axboe (subscriber, #904)
And yes, the normal copy is indeed two copies, to and from kernel/user space.
You can continue talking if you want, but don't expect a response from me.
Posted Apr 10, 2006 1:03 UTC (Mon) by xoddam (subscriber, #2322)
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds