Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DMA copy in splice()

I am new to linux kernel. And recently, i've went through the sendfile syscall in kernel 2.6.33. The following is the sequence of my journey:

   do_sendfile()
=> do_splice_direct()
=> splice_direct_to_actor()
=> do_splice_to()
=> do_splice_from()
=> splice_read,splice_write

Throughout this sequence, I didn't find the place where splice use the DMA copy. So where is the DMA copying taking place?

like image 282
sliter Avatar asked Sep 28 '11 15:09

sliter


2 Answers

Splice doesn't do any DMA copy. In fact the major usage of splice is to avoid copying at all - it tries to pass references to memory pages instead of copying the buffers.

The DMA mentioned in relation to splice will happen at the "leaf" - The origin of these pages that splice passes references to around will be created by, for example, a disk controller DMA into the buffer and will be sent by an Ethernet controller DMA of the content of the page as part of the packet - at least in a "perfect" zero copy sceanrio, which is difficult to achieve and rare.

Splice doesn't do the DMA - it enables no copying between the first DMA to the last.

like image 72
gby Avatar answered Oct 30 '22 18:10

gby


As I understand it the splice_* infrastructure does it's very best to minimise the amount of actual copying that is done. At best the reader is reading from the same set of pages the writer is filling.

There are some excellent articles on LWN describing the various bits of splice() including the new system call.

like image 36
stsquad Avatar answered Oct 30 '22 20:10

stsquad