
10/10/2022 · Jakub Sitnicki, Arthur Fabre
What this post added
This post delves into the concept of tail calls, both in traditional compilation (e.g., Fibonacci implementations) and specifically within the eBPF (extended Berkeley Packet Filter) ecosystem. It explains how tail call elimination optimizes recursive functions by reusing stack frames, contrasting 'okay' vs. 'cool' implementations. The core of the post focuses on BPF tail calls, detailing the `bpf_tail_call` helper, its use in chaining BPF programs (e.g., for XDP-based packet processing), and the historical limitations on arm64 regarding the co-existence of BPF tail calls and BPF-to-BPF function calls. It clarifies that BPF tail calls are an implementation of tail call elimination, reusing the same stack frame, rather than a program replacement mechanism, and explores the nuances of how they interact with BPF function calls and stack frames.