Chapter 8: Data-Plane Threading — Control, Spare, Core Loop

DP Thread Model

┌─────────────────────────────────────────────────────────┐ │ data-plane process │ │ │ │ ┌──────────────────────┐ ┌──────────────────────────┐│ │ │ Control Thread │ │ Spare Thread ││ │ │ │ │ ││ │ │ • PFCP session logic │ │ • DB I/O (db-proxy runs ││ │ │ • State machines │ │ here currently) ││ │ │ • Rule installation │ │ • Background tasks ││ │ │ • Signaling (HTTP) │ │ • Replication client ││ │ │ • Has its own EVL │ │ • Has its own EVL ││ │ └──────────────────────┘ └──────────────────────────┘│ │ │ │ ┌──────────────────────────────────────────────────────┐│ │ │ Core Loop Threads (fast path) ││ │ │ • Packet forwarding (GTP-U encap/decap) ││ │ │ • DPI, firewall, NAT ││ │ │ • No DB access, no EVL (tight poll loop) ││ │ │ • One per CPU core ││ │ └──────────────────────────────────────────────────────┘│ └─────────────────────────────────────────────────────────┘

Why This Matters for the Feature

Communication Between Threads

// Control → Spare: "please write this to DB"
// Uses EVL defer or mbox to cross thread boundary
evl_defer_start(spare_evl, db_write_callback, data);

// Spare → Control: "DB write complete"
evl_defer_start(control_evl, completion_callback, result);
⚠️ Thread Boundary = Latency

Every cross-thread communication adds latency (wakeup + context switch). If db-mux runs on the control thread directly (no thread crossing), it could be faster for latency but uses control thread CPU. Trade-off: latency vs CPU distribution.

Key Takeaways