<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tracing on Shai Asher</title><link>https://slow-is-smooth.io/tags/tracing/</link><description>Recent content in Tracing on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 12 Mar 2023 09:00:00 +0200</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/tracing/index.xml" rel="self" type="application/rss+xml"/><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>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>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>