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