HEADS UP: zerocopy bpf commits impending

Robert Watson rwatson at FreeBSD.org
Mon Mar 24 08:26:37 PDT 2008


On Mon, 24 Mar 2008, Petri Helenius wrote:

> Pardon the basic question, but is the current patchset "zero copy" or "one 
> copy"? The paper I saw a link to described a mechanism to eliminate one of 
> the two copies the traditional bpf approach makes but I haven't taken a look 
> into the actual code.

The short answer is "one-copy".  This eliminates the copy between the kernel 
and user space, but not the possibility of in-kernel copying.  In practice, 
that in-kernel copying is frequently desirable as:

(1) It allows packing of headers into a buffer when a small snaplen is used,
     which greatly reduces memory overhead when capturing, for example, just
     TCP headers and not payloads.

(2) It allows us to more easily maintain independence between separate BPF
     sessions, and in particular, to avoid leaking memory between kernel,
     userspace, and different BPF consumers.

If doing full capture of all packet data to userspace, the approach we took 
would improve performance, but would still involve one full copy of packet 
data in kernel.  Further work would be required to eliminate that copy.

Robert N M Watson
Computer Laboratory
University of Cambridge


More information about the freebsd-net mailing list