星期日, 三月 13, 2005
Zero-Copy in Linux Kernel
          Found a (supposedly) outdated doc on Zero Copy in Linux Kernel written by Dragan Stancevic.  The article clearly explains how send() and "sendfile()" differ from kernel's perspective. 
Using sendfile(socket, file, len), Data from a disk is first DMA-copied into kernel buffer, then the kernel socket buffer only collects descriptors (not the data!) of those skbs. Eventually the NIC performs DMA-gather over the socket buffer(skb descriptors) and the kernel buffer(data) into NIC's transmission ring buffer. Thus this operation (zero-copy in kernel) requires the NIC support scatter-gather DMA.
								
          
		
Using sendfile(socket, file, len), Data from a disk is first DMA-copied into kernel buffer, then the kernel socket buffer only collects descriptors (not the data!) of those skbs. Eventually the NIC performs DMA-gather over the socket buffer(skb descriptors) and the kernel buffer(data) into NIC's transmission ring buffer. Thus this operation (zero-copy in kernel) requires the NIC support scatter-gather DMA.