<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ebpf on Shai Asher</title><link>https://slow-is-smooth.io/tags/ebpf/</link><description>Recent content in Ebpf on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Fri, 04 Dec 2026 09:00:00 +0200</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/ebpf/index.xml" rel="self" type="application/rss+xml"/><item><title>eBPF on Windows, Today</title><link>https://slow-is-smooth.io/blog/ebpf-on-windows-today/</link><pubDate>Fri, 04 Dec 2026 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/ebpf-on-windows-today/</guid><description>&lt;p&gt;On a Windows 11 virtual machine with Memory Integrity switched on, eBPF for Windows 1.8.0, released&#10;yesterday, loaded the bind counter I have now written three times, as an 11-kilobyte signed driver, and&#10;counted 100,001 socket binds out of 100,001. It attached to a hook with the same name as on Linux,&#10;kept its running total in a global variable, and a Go program built on ebpf-go read the same map&#10;without a line of Windows-specific BPF code. Five and a half years after Microsoft announced the&#10;port, it has reached version 1. All 34 of its GitHub releases are still marked pre-release, its&#10;kernel drivers are still signed with a test certificate, and when I switched on the check designed&#10;to replace test signing, no program I could build would load.&lt;/p&gt;</description></item><item><title>Who Is Allowed to Load a Program</title><link>https://slow-is-smooth.io/blog/who-is-allowed-to-load-a-program/</link><pubDate>Sun, 14 Dec 2025 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/who-is-allowed-to-load-a-program/</guid><description>&lt;p&gt;On Linux 6.18, a light skeleton carrying a 375-byte signature loaded a 162-instruction loader&#10;program, and the kernel checked that signature against a keyring before its verifier had read a&#10;single instruction. Then I changed fifteen bytes of the program the loader carried: the kernel&#10;still accepted the signature, and the loader refused to load its cargo. I patched the loader to&#10;match, and the kernel refused the signature. Then, as root, I signed the same program with a key I&#10;had made a minute earlier, and the kernel accepted it without complaint.&lt;/p&gt;</description></item><item><title>A CPU Scheduler Written in BPF</title><link>https://slow-is-smooth.io/blog/a-cpu-scheduler-written-in-bpf/</link><pubDate>Sun, 15 Dec 2024 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/a-cpu-scheduler-written-in-bpf/</guid><description>&lt;p&gt;On Linux 6.12, a scheduler of 156 lines of C, compiled to BPF, took over every ordinary task on an&#10;eight-CPU machine without a reboot, and one kill signal to its loader handed them all straight back. A&#10;36-line scheduler that deliberately never ran one shell script was thrown out by the kernel&amp;rsquo;s own&#10;watchdog after 5.02 seconds, and the script carried on as if nothing had happened. Measured against&#10;the kernel&amp;rsquo;s default scheduler, the simple one kept up on throughput and lost a hundredfold on&#10;wakeup latency under load: 15.7 milliseconds at the 99th percentile, against 165 microseconds.&lt;/p&gt;</description></item><item><title>eBPF Learns to Allocate</title><link>https://slow-is-smooth.io/blog/ebpf-learns-to-allocate/</link><pubDate>Sun, 21 Jul 2024 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/ebpf-learns-to-allocate/</guid><description>&lt;p&gt;On Linux 6.10, a sleep command ran for a tenth of a second, exited and was reaped by its parent,&#10;and the kernel duly reported that no process with its ID existed any more. A BPF map still held&#10;the kernel&amp;rsquo;s record of it, the task structure, with a reference count of exactly one: the map&amp;rsquo;s&#10;own. A red-black tree, built by a BPF program out of objects it had allocated itself, named the&#10;five most CPU-hungry of ten processes, in order. The loop from Part 4 that had spent the&#10;verifier&amp;rsquo;s entire budget of a million instructions loaded after 42, with one line added. And a&#10;user-space program walked a million-node linked list that a BPF program had built, following&#10;ordinary pointers, in about 2.2 milliseconds; through map lookups, the same walk took about 370.&lt;/p&gt;</description></item><item><title>eBPF on Windows, Two Years In</title><link>https://slow-is-smooth.io/blog/ebpf-on-windows-two-years-in/</link><pubDate>Sun, 28 Apr 2024 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/ebpf-on-windows-two-years-in/</guid><description>&lt;p&gt;In a Windows 11 virtual machine with Memory Integrity switched on, eBPF for Windows v0.16.0&#10;refused to JIT-compile a fifty-line BPF program before it had produced a single byte of machine&#10;code. The same program, translated ahead of time into C and built into an 11-kilobyte test-signed&#10;driver, loaded straight away and counted 100,001 socket binds out of 100,001. Its JIT-compiled&#10;twin, run with Memory Integrity off, lost up to 22 of them, because eighteen months after I last&#10;looked, the Windows JIT still cannot compile an atomic add.&lt;/p&gt;</description></item><item><title>The Network Plumbing Grows Up</title><link>https://slow-is-smooth.io/blog/the-network-plumbing-grows-up/</link><pubDate>Sun, 21 Jan 2024 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/the-network-plumbing-grows-up/</guid><description>&lt;p&gt;Three tools shared one network device&amp;rsquo;s ingress hook through classic tc. One of them stopped seeing packets the moment another arrived, and nobody told it. A third replaced the second&amp;rsquo;s program without the second finding out, and when the second shut down and cleaned up after itself, it deleted everyone&amp;rsquo;s programs. On Linux 6.7, four tools sharing the same hook through tcx kept a list the kernel will show to anyone who asks, could not remove each other&amp;rsquo;s programs, and got &lt;code&gt;ESTALE&lt;/code&gt; instead of a silent overwrite when two of them raced. In the same virtual machine, a pod plugged in with netkit, the new device meant to replace veth,&#10;pushed 1.21 million small packets a second out of the node against 1.14 million&#10;for a veth pod running the same BPF program, and two local processes completed a one-byte TCP round trip&#10;in 2.50 µs instead of 3.44 once a sockmap program carried the bytes from&#10;one socket to the other.&lt;/p&gt;</description></item><item><title>Watching Every Exec, and Saying No</title><link>https://slow-is-smooth.io/blog/watching-every-exec-and-saying-no/</link><pubDate>Sun, 09 Jul 2023 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/watching-every-exec-and-saying-no/</guid><description>&lt;p&gt;A tracepoint program that read the file name of every &lt;code&gt;open()&lt;/code&gt; at the moment the system call began&#10;was wrong 836 times in 100,000 on Linux 6.4, because a second thread kept rewriting&#10;the name after the program had read it. A second BPF program, on a hook a few microseconds further&#10;into the same system call, the kernel&amp;rsquo;s own security check, saw the file the kernel had actually&#10;resolved. Told to refuse, it turned away all 96,943 attempts to open the forbidden file and&#10;was never fooled once. Watching happens where the process can still change the answer; deciding&#10;has to happen where it cannot.&lt;/p&gt;</description></item><item><title>Every Function Is a Hook</title><link>https://slow-is-smooth.io/blog/every-function-is-a-hook/</link><pubDate>Sun, 12 Mar 2023 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/every-function-is-a-hook/</guid><description>&lt;p&gt;Attaching the same two-line BPF program to the &lt;code&gt;getpid()&lt;/code&gt; system call made each call 7.4&#10;nanoseconds slower when it went in through fentry, 27 through a kprobe, 89&#10;through a kretprobe, and 310 when the kprobe had to fall back to a breakpoint instruction.&#10;A uprobe on a two-instruction function in an ordinary program made each call of it&#10;8.1 microseconds slower, about 27,000 times what the function costs on its&#10;own. The program did the same thing every time: it added one to a counter. What changed was the road&#10;the kernel took to reach it.&lt;/p&gt;</description></item><item><title>Dropping Packets Before the Kernel Sees Them</title><link>https://slow-is-smooth.io/blog/dropping-packets-before-the-kernel-sees-them/</link><pubDate>Sun, 18 Dec 2022 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/dropping-packets-before-the-kernel-sees-them/</guid><description>&lt;p&gt;On Linux 6.1, one C function that reads a packet&amp;rsquo;s UDP destination port and decides whether to keep&#10;it ran in two places: in XDP, at the network driver, and in tc, one layer further up. Raced against&#10;iptables and nftables on one CPU of a virtual machine, the tc copy dropped 3.10 million packets a&#10;second, the best of the lot, and iptables&amp;rsquo; INPUT chain managed 2.19 million. XDP, the hook built to&#10;be the fastest place in the kernel to drop a packet, managed 2.10 million: the worst of the six&#10;filters, and no better than having no filter at all.&lt;/p&gt;</description></item><item><title>eBPF on Windows, the First Year</title><link>https://slow-is-smooth.io/blog/ebpf-on-windows-the-first-year/</link><pubDate>Sun, 30 Oct 2022 09:00:00 +0200</pubDate><guid>https://slow-is-smooth.io/blog/ebpf-on-windows-the-first-year/</guid><description>&lt;p&gt;On a Hyper-V virtual machine running Windows 11 with test signing on, I installed eBPF for&#10;Windows v0.5.0, wrote a small BPF program in C, compiled it with clang, and loaded it into the&#10;Windows kernel. It counted the socket binds made by each process, from inside the kernel, with no&#10;reboot. The same clang that builds BPF for Linux built this; the same libbpf function names loaded&#10;it. And when I deleted a NULL check, the program was rejected before it ran, exactly as on Linux,&#10;except that the verifier doing the rejecting was not in the kernel at all. It was a user-mode&#10;Windows service, and it had proved the program safe by a completely different method.&lt;/p&gt;</description></item><item><title>Compile Once, Run on Every Kernel</title><link>https://slow-is-smooth.io/blog/compile-once-run-on-every-kernel/</link><pubDate>Sun, 25 Sep 2022 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/compile-once-run-on-every-kernel/</guid><description>&lt;p&gt;On Linux 5.13 the process ID in the kernel&amp;rsquo;s &lt;code&gt;struct task_struct&lt;/code&gt; sits 2,336 bytes from the&#10;start of the structure. On Ubuntu 22.04&amp;rsquo;s 5.15 kernel it is at byte 2,384, and on 5.19 at byte&#10;2,496. I compiled one small BPF program on Ubuntu 22.04 that reads the field two ways, and&#10;loaded the same object file on all three kernels. Read at the offset the compiler had chosen,&#10;the process ID came back right on 5.15, as 0 on 5.19, and as -2,136,733,376 on 5.13. Read the other&#10;way, it was right on all three, because a moment before the program was loaded, libbpf had&#10;rewritten that one instruction for the kernel in front of it.&lt;/p&gt;</description></item><item><title>Maps Are the Only Memory You Get</title><link>https://slow-is-smooth.io/blog/maps-are-the-only-memory-you-get/</link><pubDate>Sun, 21 Aug 2022 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/maps-are-the-only-memory-you-get/</guid><description>&lt;p&gt;A hash map with room for a million entries cost 77.0 MiB of kernel memory on Linux 5.19&#10;the moment it was created, before a single key went in, while the memory figure bpftool printed for&#10;it said 15.3 MiB. Four CPUs adding one to the same counter in a map took&#10;140 nanoseconds per increment; giving each CPU its own copy of the counter took&#10;1.5 nanoseconds. And a program that handed one small event to user space paid&#10;54.8 nanoseconds for it through a ring buffer told not to wake the reader, and&#10;4,838 nanoseconds, nearly five microseconds, when it woke the reader every time.&lt;/p&gt;</description></item><item><title>The Verifier Said No</title><link>https://slow-is-smooth.io/blog/the-verifier-said-no/</link><pubDate>Sun, 17 Jul 2022 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/the-verifier-said-no/</guid><description>&lt;p&gt;A loop that clears the lowest set bit of a 32-bit number until none are left cannot go round&#10;more than 32 times, and any C programmer can see it. The Linux 5.15 verifier went round it&#10;166,665 times, spent its entire budget of a million instructions, and refused to load the&#10;program. I added a second condition, that a counter stay below 64, a bound the loop can never&#10;even reach, and the same kernel accepted the program after checking 707 instructions.&lt;/p&gt;</description></item><item><title>Three Ways to Load a Program</title><link>https://slow-is-smooth.io/blog/three-ways-to-load-a-program/</link><pubDate>Sun, 26 Jun 2022 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/three-ways-to-load-a-program/</guid><description>&lt;p&gt;On a stock Ubuntu 22.04, the same 27-instruction BPF program, a counter of every execve() call on the machine, took 282 milliseconds to start counting when its loader was BCC and 97 when it was bpftrace. Compiled ahead of time and loaded from C or from Go, it was counting in under 2 milliseconds. The BCC version peaked at 129 MB of memory and needed 355 MB of packages on the machine it ran on, a compiler and the kernel&amp;rsquo;s headers among them. The C version peaked at 1.3 MB and needed half a megabyte.&lt;/p&gt;</description></item><item><title>Eleven Registers and a 512-Byte Stack</title><link>https://slow-is-smooth.io/blog/eleven-registers-and-a-512-byte-stack/</link><pubDate>Sun, 29 May 2022 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/eleven-registers-and-a-512-byte-stack/</guid><description>&lt;p&gt;Part 1&amp;rsquo;s counter reached the kernel as 216 bytes: 27 slots of eight bytes each, which clang made&#10;out of about thirty lines of C. The kernel kept 29 slots, 232 bytes, and handed 141 bytes of x86-64 machine&#10;code to the processor. Every one of those bytes has a reason, and this post finds it: what each field&#10;of each instruction means, why the program keeps its key&amp;rsquo;s address in one register and the number 1&#10;in another, how a call into the kernel ends up as a single machine instruction, and which line of the&#10;program each of the 141 bytes came from.&lt;/p&gt;</description></item><item><title>A Program the Kernel Agreed to Run</title><link>https://slow-is-smooth.io/blog/a-program-the-kernel-agreed-to-run/</link><pubDate>Sun, 08 May 2022 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/a-program-the-kernel-agreed-to-run/</guid><description>&lt;p&gt;On a freshly installed Ubuntu 22.04, a program of 27 instructions counted every process the&#10;kernel started, from inside the kernel, with no kernel module, no reboot and no recompiled kernel.&#10;Before it ran even once, the kernel read all 27 instructions and proved to itself that none could&#10;crash it, loop forever or read memory it had no business reading. It then rewrote the program&amp;rsquo;s map&#10;lookup, added two instructions of its own, and compiled the result into 141 bytes of x86-64 machine&#10;code. In the virtual machine I tried it on, each run cost about 0.7 microseconds.&lt;/p&gt;</description></item></channel></rss>