THE LINUX FOUNDATION PROJECTS

Stop Copying Packets: Zero-Copy Hand-off for Multi-Process DPDK on FreeBSD

By November 23, 2026User Stories
DPDK Blog: Stop Copying Packets. Zero-copy hand-off for multi-process DPDK on FreeBSD, by Kumar Sanghvi, Zscaler

Kumar Sanghvi

Kumar Sanghvi

Zscaler

We couldn’t get our DPDK-based NIC service anywhere near the throughput we expected on two 25 GbE ports. Per-thread CPU accounting and pmcstat sampling pointed at the service itself.

In our memcpy baseline, the NIC forwarding threads were 100% busy while each application worker sat at roughly half a core. The forwarding threads were copying every payload twice: into a worker buffer on receive, and back into an mbuf on transmit. When I removed that copy, receive throughput nearly doubled, from 23.89 Gb/s to about 45 Gb/s.

That headline is the easy part. The more useful lesson is what the copy was protecting, and where the cost went once it was gone.

Why there is a hand-off at all

Our packet path separates the NIC from the application. Each physical 25 GbE port is split into five SR-IOV virtual functions. The NIC service runs one poll-mode forwarding thread per physical port, and each thread polls that port’s five VFs. Each application worker is tied to one VF and receives and sends its packets through the NIC service; in this case the workers run a TCP proxy with content inspection. Packets cross between the NIC service and its workers through shared-memory descriptor rings and a shared region of packet buffers.

Process-isolated packet hand-off architecture: two ports with five SR-IOV VFs each, a NIC service with one forwarding thread per port, shared-memory descriptor rings and buffer region, and ten worker processes

The isolation is deliberate: a worker crash must not take down the NIC service or the other workers. That turns “zero-copy” into an ownership question. Which process owns each buffer, which component writes it, how does a completion hand ownership back, and what happens to an in-flight packet if a worker exits?

Three ways to hand off a packet

I compared three modes on the same system and workload.

Mode A: memcpy. mbufs live in the NIC service’s hugepage memory (contigmem on FreeBSD). The forwarding thread copies the payload into a worker-owned buffer on RX and copies it back into an mbuf on TX. Ownership is simple and explicit; the price is CPU time and cache traffic on the forwarding cores, in both directions.

Mode A: CPU copies between service mbuf hugepage memory and the worker-owned packet buffer on RX and TX

Mode B: external buffers. Worker buffers are attached to mbufs with rte_pktmbuf_attach_extbuf, so the NIC DMAs directly into and out of worker memory. The copies disappear, but the lifecycle now involves the shared-info reference count, a free callback, and detach, all of which have to respect the worker buffer’s lifetime.

Mode B: NIC DMA into an mbuf attached to a worker external buffer, with shared-info refcount and free callback

Mode C: split-metadata mempool. Mode B removed the copies, but every packet still paid for attach, a shared-info refcount, a free callback and detach in the forwarding thread. Mode C was an attempt to remove that per-packet bookkeeping. The mbuf header stays in the NIC service’s hugepage memory, warm in its cache, while buf_iova points at the data area of a worker-owned buffer. A custom mempool binds free worker buffers to mbufs in bursts on RX and posts TX completions from the enqueue path. Mode C has no shared-info refcount, free callback or detach, and the NIC service never writes worker buffer memory.

Mode C: mbuf header in NIC-service hugepage memory with buf_iova pointing at worker-owned packet data; custom mempool ops bind buffers on RX and post TX completions

What I measured

The system under test was a dual-socket Intel Xeon Gold 6442Y server running a FreeBSD 13-based OS, with one dual-port Intel E810 25 GbE NIC (firmware 8.0.2, NVM 5.01) on the FreeBSD ice(4) 1.37.8 PF driver. Each port carried five virtual functions, driven by the iavf PMD of a DPDK 22.11-based build and serving ten workers, five per port. The APIs used here are still available in current releases, with the same signatures; Mode C also relies on the mbuf’s buf_iova field, which is present in default builds (enable_iova_as_pa=true). Traffic came from httperf on a second server of the same class, with 1,000 connections per worker. Intel PCM (pcm, pcm-memory, pcm-pcie) sampled at one-second intervals, alongside per-thread counters in the NIC service.

Stacked bar chart of peer-recorded receive throughput by mode: A memcpy 23.89 Gb/s, B external buffers 44.57 Gb/s, C split-metadata 45.22 Gb/s
A: memcpy B: external buffers C: split metadata
Receive throughput 23.89 Gb/s 44.57 Gb/s (+86.6%) 45.22 Gb/s (+89.3%)
NIC thread busy 100% 95–96% 93–95%
NIC thread polls/s 8.6–9.2 K 107–125 K 239–257 K
Worker CPU 50.6–55.9% 99.7–99.9% 99.9%
Worker RSS ~8.1 GB ~8.1 GB 12–13 GB
L3 misses/s (all cores) 697 M 25 M 46 M
Memory traffic per Gb/s 2.18 GB/s 1.52 GB/s 1.51 GB/s

Receive throughput is the per-port receive rate recorded by the peer system, summed over both ports. NIC thread busy is the share of forwarding-loop iterations that handled at least one packet or completion; a poll-mode thread always occupies its core, so this is loop occupancy, not CPU utilisation.

Three things stand out.

The bottleneck moved. B and C delivered almost the same throughput because the workers were saturated. C’s advantage shows up as NIC-thread headroom, about 2.2 times B’s poll rate, not as extra end-to-end capacity under this load.

Zero-copy removes CPU copies, not data movement. NIC DMA still has to happen: PCIe reads stayed at 2.1–2.2 million read transactions (PCM PCIRdCur) per gigabit delivered in all three modes. What changed was the CPU-side traffic around it, with far fewer L3 misses and less memory traffic per Gb/s.

C is not free. Compared with B, C’s workers had higher RSS (12–13 GB versus about 8.1 GB) and a much larger VSZ, because the entire packet-buffer region was mapped into every worker. C also showed more incoming cross-socket (UPI) traffic, 2.44 versus 1.30 GB/s, and higher DIMM power, 50.8 versus 45.5 W.

Choosing a mode

B and C are not ordered winners. I would start from the measured bottleneck:

  • •A if the copy is not your limit and explicit ownership is worth more than the throughput.
  • •B if you need direct DMA into worker memory and can live with the refcount, callback and detach lifecycle.
  • •C if the forwarding thread needs headroom and you can support custom pool operations, accepting more worker memory and cross-socket traffic than B.
Decision tree: if CPU payload copies need not be removed, Mode A; if they must and refcount, callback and detach are acceptable, Mode B; otherwise evaluate Mode C with custom pool and ownership safeguards

Pitfalls I hit, or would watch for

  • •Advertise the true data room. If the receive pool is created with DPDK’s default mbuf size (RTE_MBUF_DEFAULT_BUF_SIZE) but the real packet area is smaller, the PMD programs a larger receive buffer than the packet area can hold, and the NIC is free to DMA past it into trailing per-buffer metadata. Nothing breaks until a large enough frame (a tunnelled packet, for example) arrives. Size the data room from the real buffer plus headroom, and drop and count anything larger on the hand-off path. I hit an overrun of exactly this kind.
  • •Keep service writes out of worker cache lines. The service can leave payload bytes untouched and still pull worker lines across sockets if it updates nearby metadata.
  • •NUMA placement still matters. Zero-copy removes a copy, not the cost of remote memory. I did not isolate the cause of C’s extra cross-socket traffic; buffer placement relative to the worker’s socket is the first thing I would check.
  • •Expect the bottleneck to move. Once copies disappear, the workers may become the limit, as they did here.
  • •Treat a worker crash as an ownership transition. Test an in-flight packet plus a worker exit in each mode, and make sure the service never reuses a worker-owned buffer based on a stale descriptor.

Caveats and next steps

These are one run per mode, and the power and hardware counters are one-second snapshots, not averages. Modes A and B used 2 MB pages for the shared buffer region and Mode C used 1 GB pages; treat that as a recorded test condition, not an explanation of the results.

Next, I want repeated runs with packet-size and connection-count sweeps, a worker-count sweep to see where NIC-thread headroom stops paying off, crash injection in each mode, and a closer look at NUMA placement of the buffer region.

If you are building a process-isolated DPDK service, measure where your forwarding thread spends its time before choosing a mode, and decide up front who owns each buffer when something goes wrong. In our setup, removing the copy was the difference between a saturated forwarding thread and saturated workers.

Get involved

Work on DPDK yourself

Patch review and patch submission both happen on the dev@dpdk.org mailing list. These guides walk through the workflow, from setup to your first reply or submission.