Skip to content
LinkState
Go back

Kernel version changes in drop tracing cost

Introduction to Benchmarking skb Drop Reason Tracing

The Linux socket buffer (skb) carries a drop_reason field that is set when a packet is discarded by the networking stack. Tracing this field lets operators see why packets are dropped (congestion, ACL, RPF failure, LRO overflow, etc.) without touching the data path. The mechanism relies on eBPF programs attached to kernel probes that fire when an skb is freed or consumed, read the drop reason via bpf_skb_get_drop_reason(), and record it in a userspace‑visible map.

Production observability must stay low‑overhead. Adding a tracing probe consumes CPU cycles, memory bandwidth, and can cause contention on shared resources (per‑CPU maps, ring buffers). Benchmarking across kernel releases quantifies that overhead so teams can:


Kernel Versions and Probe Choice

Kernel Overview

KernelReleaseNotable skb‑tracing changes
5.15LTS (Oct 2021)First stable inclusion of bpf_skb_get_drop_reason() and bpf_skb_set_drop_reason(); tracepoint kfree_skb present.
6.1LTS (Jan 2023)Helper signatures unchanged; added BPF_CORE_READ support for direct skb->drop_reason access; tracepoint kfree_skb unchanged.
6.6LTS (Oct 2023)No new drop‑reason helpers; improved symbol visibility for __kfree_skb due to reduced inline‑attribute churn; tracepoint kfree_skb still stable.

All three ship with CONFIG_BPF_SYSCALL=y, CONFIG_BPF_JIT=y, and CONFIG_DEBUG_INFO_BPF=y in typical distro configs, enabling libbpf‑based tracing.

Probe Options

Probe TypeAttachment PointVisibilityOverhead Characteristics
Tracepointtracepoint:kfree_skb (defined in include/trace/events/skb.h)Fires on every kfree_skb() call, including those from consume_skb() and __kfree_skb()Very low; uses existing tracepoint infrastructure, no symbol resolution needed.
Kprobekprobe:__kfree_skb (or kprobe:kfree_skb)Fires on the exact function entry; can be paired with fexit for exit‑side dataSlightly higher due to dynamic symbol lookup and possible JIT compilation overhead.
Fentry/Fexitfentry:__kfree_skb / fexit:__kfree_skb (requires CONFIG_TRACING=y and CONFIG_BPF_TRACING=y)Similar to kprobe but uses the newer BPF trampoline mechanism, reducing context‑save overhead.Lowest among dynamic probes when the kernel supports BPF trampoline (5.5+).
Kretprobekretprobe:__kfree_skbCaptures the return value (success/failure) after the free operation.Overhead comparable to kprobe; useful if you need to know whether the skb was actually freed.

Choosing a Probe for Benchmarking

For the benchmark we compare:

  1. Tracepoint on kfree_skb.
  2. Fentry on __kfree_skb (when available).
  3. Kprobe on __kfree_skb (as a baseline).

Helper Availability and Its Impact

Core Helpers

Frequently used alongside:

Helper Availability Across Kernels

KernelHelper Status
5.15bpf_skb_get_drop_reason() and bpf_skb_set_drop_reason() present (since 5.5). bpf_probe_read_kernel(), bpf_get_smp_processor_id(), ringbuf helpers present. BPF_CORE_READ available but limited to simple field access; requires vmlinux.h from bpftool gen.
6.1No change to drop‑reason helper signatures. Enhanced BPF_CORE_READ understands bitfield packing (future‑proof). Added offload helpers (bpf_skb_get_tx_hash()) – irrelevant here. Ringbuf reservation hints improved.
6.6Drop‑reason helpers unchanged. bpf_probe_read_kernel() and bpf_probe_read_user() get inline variants when CONFIG_BPF_LLVM_INLINE=y. Introduced bpf_spin_lock()/unlock() (optional, higher overhead). Ringbuf and map helpers remain stable.

Overall, the helper set relevant to drop‑reason tracing is stable from 5.15 → 6.6; performance differences arise from probe choice and kernel internals (inlining, layout changes), not helper availability.


Symbol Stability and Its Effect

What Makes a Symbol Stable?

A symbol is stable for tracing when its name persists across builds and its address can be reliably resolved via /proc/kallsyms or BPF CO‑RE. Instability affects:

Symbol Stability per Kernel


Benchmarking Methodology and Tools

Tools

Procedure

  1. Prepare the testbed – two servers linked by a 25 GbE NIC (e.g., Mellanox ConnectX‑6) with flow control disabled, RSS enabled, and gro=off gso=off tso=off to prevent offload‑induced masking.
  2. Kernel configuration – ensure CONFIG_BPF_SYSCALL=y, CONFIG_BPF_JIT=y, CONFIG_DEBUG_INFO_BPF=y, CONFIG_TRACING=y, CONFIG_BPF_TRACING=y, CONFIG_KPROBES=y, CONFIG_FTRACE=y. Verify the tracepoint exists:
    grep kfree_skb /sys/kernel/debug/tracing/available_events
  3. Build the eBPF program – three variants (tracepoint, fentry, kprobe) using the same source; only the SEC() annotation changes.
  4. Run the benchmark – start traffic, attach the program, collect latency and CPU metrics, then detach and repeat for each probe/kernel combination.
  5. Analyze – compare per‑packet overhead, jitter, and CPU usage against the baseline to determine which probe offers the best trade‑off for each kernel version.

End of document.


Share this post on:

Previous Post
Why one backend stopped receiving service traffic
Next Post
Parser confidence as a deployment gate