Efficient Linux sockets (DMA/zero-copy)

There’s been some talk on linux-kernel recently about providing an API for something along these lines, but the sticking point is that you can’t DMA from general userspace buffers to the network card, because:

  • What looks like contiguous data in the userspace linear address space is probably not-contiguous in physical memory, which is a problem if the network card doesn’t do scatter-gather DMA;
  • On many machines, not all physical memory addresses are “DMA-able”. There’s no way at the moment for a userspace application to specifically request a DMA-able buffer.

On recent kernels, you could try using vmsplice and splice together to achieve what you want – vmsplice the pages (with SPLICE_F_GIFT) you want to send into a pipe, then splice them (with SPLICE_F_MOVE) from the pipe into the socket.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)