LWN: Comments on "Kernel analysis with bpftrace" https://lwn.net/Articles/793749/ This is a special feed containing comments posted to the individual LWN article titled "Kernel analysis with bpftrace". en-us Wed, 22 Oct 2025 10:15:08 +0000 Wed, 22 Oct 2025 10:15:08 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Kernel analysis with bpftrace https://lwn.net/Articles/888629/ https://lwn.net/Articles/888629/ ideal <div class="FormattedComment"> # bpftrace -e &#x27;t:timer:hrtimer_start { @[ksym(args-&gt;function)] = count(); }&#x27;<br> <p> on kernel v5.16.x,need to include &lt;linux/hrtimer.h&gt;,or else enum hrtimer_mode is not defined.<br> </div> Mon, 21 Mar 2022 13:25:57 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794745/ https://lwn.net/Articles/794745/ flussence <div class="FormattedComment"> I was wondering what that new CONFIG_IKHEADERS in kernel 5.2 could possibly be useful for; this scenario (kernel image living outside the known filesystem) sounds like exactly it.<br> </div> Sat, 27 Jul 2019 05:56:04 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794712/ https://lwn.net/Articles/794712/ BenHutchings <div class="FormattedComment"> If you build the kernel with "make bindeb-pkg" you'll get those kernel headers packaged up in a linux-headers-&lt;release&gt; package, same as for a distribution kernel.<br> </div> Fri, 26 Jul 2019 16:59:14 +0000 CTF https://lwn.net/Articles/794202/ https://lwn.net/Articles/794202/ mjw <div class="FormattedComment"> It is already in the upstream binutils git repo:<br> <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=history;f=libctf;hb=HEAD">https://sourceware.org/git/?p=binutils-gdb.git;a=history;...</a><br> <p> With additional work being discussed on the binutils mailinglist:<br> <a href="http://sourceware.org/ml/binutils/current">http://sourceware.org/ml/binutils/current</a><br> <p> Support for the linker posted here:<br> <a href="https://sourceware.org/ml/binutils/2019-07/msg00159.html">https://sourceware.org/ml/binutils/2019-07/msg00159.html</a><br> <p> The GCC support just saw its V4 RFC:<br> <a href="https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01209.html">https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01209.html</a><br> </div> Fri, 19 Jul 2019 21:03:53 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794197/ https://lwn.net/Articles/794197/ dw <div class="FormattedComment"> FreeBSD is a heavy user<br> </div> Fri, 19 Jul 2019 15:43:49 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794196/ https://lwn.net/Articles/794196/ bgregg <div class="FormattedComment"> Who are still the end users of CTF? I wanted it years ago, but now we have BTF.<br> </div> Fri, 19 Jul 2019 15:25:01 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794191/ https://lwn.net/Articles/794191/ nivedita76 <div class="FormattedComment"> is there a doc somewhere? What is the use case for type info for binaries without debug info?<br> </div> Fri, 19 Jul 2019 13:57:01 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794166/ https://lwn.net/Articles/794166/ nilsmeyer <div class="FormattedComment"> That still doesn't make up for Netflix cancelling shows I like. <br> </div> Fri, 19 Jul 2019 09:13:53 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794159/ https://lwn.net/Articles/794159/ dgc <div class="FormattedComment"> Ok, so there's no /lib/modules/&lt;vers&gt;/build directories on any of my machines. And my test VMs don't even run a modular kernel (it's supplied externally by qemu invocation) so I'm guessing this is the issue. I'll have a bit of a look around to see if I can get this populated and whether than makes the problem go away. If I can't solve it easily, then I'll raise an issue for it.<br> <p> Thanks!<br> <p> -Dave.<br> </div> Fri, 19 Jul 2019 00:44:41 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794157/ https://lwn.net/Articles/794157/ bgregg <div class="FormattedComment"> I'd raise this as a bpftrace issue please[0]; my guess is you've got an older version of LLVM, but the Debian package description does say llvm-7, which should be fine.<br> <p> Using bpftrace to check how bpftrace is running that tool on my system:<br> <p> # BPFTRACE_STRLEN=128 bpftrace -e 't:syscalls:sys_enter_openat /comm == "bpftrace"/ { printf("opening: %s\n", str(args-&gt;filename)); }' | grep sched<br> opening: /lib/modules/4.15.0-54-generic/build/include/linux/sched.h<br> opening: /lib/modules/4.15.0-54-generic/build/include/uapi/linux/sched.h<br> opening: /lib/modules/4.15.0-54-generic/build/include/asm-generic/bitops/sched.h<br> opening: /lib/modules/4.15.0-54-generic/build/include/linux/sched/prio.h<br> <p> (We're switching from BPF stack to map storage for strings, so needing to increase BPFTRACE_STRLEN should become a thing of the past.)<br> <p> [0] <a href="https://github.com/iovisor/bpftrace/issues">https://github.com/iovisor/bpftrace/issues</a><br> </div> Thu, 18 Jul 2019 23:44:42 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794155/ https://lwn.net/Articles/794155/ dgc <div class="FormattedComment"> Brendan, running on debian and installing the distro bpftrace package, stuff like your off-wake.bt script doesn't work.<br> <p> The problem is that your script does this:<br> <p> #include &lt;linux/sched.h&gt;<br> <p> and it assume that it picks up a kernel internal header file, not the uapi/linux/sched.h that the distro has installed in /usr/include/linux/. Hence:<br> <p> $ sudo ./offwake.bt<br> Unknown struct/union: 'task_struct'<br> Unknown struct/union: 'task_struct'<br> $<br> <p> And pointing it at the installed kernel header package via:<br> <p> $ sudo ./offwake.bt -I /usr/src/linux-headers-5.0.0-trunk-common/include -I /usr/src/linux-headers-5.0.0-trunk-common/arch/x86/include/<br> /usr/src/linux-headers-5.0.0-trunk-common/arch/x86/include/asm/bitops.h:134:2: warning: implicit declaration of function 'barrier' is invalid in C99 [-Wimplicit-function-declaration]<br> .....<br> fatal error: too many errors emitted, stopping now [-ferror-limit=]<br> <p> Throws so many warnings/errors that it aborts.<br> <p> So there's some magic in your setup that is not apparent from either the article, your code samples or the documentation. Any ideas?<br> <p> -Dave.<br> </div> Thu, 18 Jul 2019 23:17:19 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794156/ https://lwn.net/Articles/794156/ unixbhaskar <div class="FormattedComment"> Wonderful! Brendan ...enjoyed very much! <br> </div> Thu, 18 Jul 2019 23:14:24 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794146/ https://lwn.net/Articles/794146/ bgregg <div class="FormattedComment"> Don't overlook how much can be done from linux headers, without BTF. Out of the 100+ new tools I developed in the BPF book, only three of them hit issues with missing structs where I needed to manually declare them. Although, that ratio will get higher (worse) the deeper you dig into things.<br> <p> Facebook have already added BTF to the build process as CONFIG_DEBUG_INFO_BTF, and I've heard that it can be included in vmlinux, so the kernel is self describing. We will need to convince distros to enable this and whatever options to deliver BTF-embedded vmlinux's by default (I can ask Canonical for Ubuntu). The BTF dedup work keeps it small, so adding it by default should be acceptable.<br> <p> I don't think there is a howto about building vmlinux with BTF yet. Arnarldo did talk about the recent BTF work[0] and there's an older post from Andrii about it[1], and there's the BTF docs in the kernel [2].<br> <p> [0] <a href="http://vger.kernel.org/~acme/perf/btf-perf-pahole-lsfmm-san-juan-2019/#/3/2">http://vger.kernel.org/~acme/perf/btf-perf-pahole-lsfmm-s...</a><br> [1] <a href="https://facebookmicrosites.github.io/bpf/blog/2018/11/14/btf-enhancement.html">https://facebookmicrosites.github.io/bpf/blog/2018/11/14/...</a><br> [2] <a href="https://www.kernel.org/doc/html/latest/bpf/btf.html#btf-generation">https://www.kernel.org/doc/html/latest/bpf/btf.html#btf-g...</a><br> </div> Thu, 18 Jul 2019 20:58:23 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794143/ https://lwn.net/Articles/794143/ SEJeff <div class="FormattedComment"> Is there a git repo you have so we can follow along by chance?<br> </div> Thu, 18 Jul 2019 20:23:41 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794141/ https://lwn.net/Articles/794141/ nix <div class="FormattedComment"> As a side note -- tangential but I can't resist -- CTF support has already landed in binutils (only the library at first, but the linker portion is under review now and does work in my testing). This should let us have CTF type info in the kernel as well, built from the toolchain-generated CTF info :) and it's not stripped by strip(1), either, so the thing is always present in the binaries. (I will eventually teach it to handle FreeBSD etc CTF info as well -- but BTF is off the table, it's just too different.)<br> <p> (Obviously, it's non-loaded info, but it's crazy to parse this sort of stuff in kernel space anyway. This is for userspace tools to use when analysing other things... like, say, the kernel. The kernel is actually a special case: because of network booting, boots from /boot that is then unmounted etc it is quite common to boot from a kernel you can't actually access, and the kernel has *vast* amounts of type info in it, far too much to sanely load all of it at once. So we'll keep the kernel's type info in a separate, compressed, loadable archive. It's only every other binary that gets its type info in a built-in .ctf section.)<br> <p> <p> </div> Thu, 18 Jul 2019 20:16:05 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794135/ https://lwn.net/Articles/794135/ dw <div class="FormattedComment"> Very excited about BTF arriving, but I'm a little confused. I expected this would mean every typical kernel would ship with type info, but read a few things in the past week to suggest this isn't quite how distros are actually going to treat it? (Sorry, lost links). The advantage of BTF for me is not having to mess with essentially getting a 'development setup' on any random machine that might need to be touched, but separate dbginfo-type package installation is exactly that<br> </div> Thu, 18 Jul 2019 19:14:22 +0000 Kernel analysis with bpftrace https://lwn.net/Articles/794134/ https://lwn.net/Articles/794134/ SPYFF <div class="FormattedComment"> Really good introduction to bpftrace. Finally a good alternative to perf probe creation then perf trace. I would really like to see something BPF based function flow tracing/graphing, that would be a true killer!<br> </div> Thu, 18 Jul 2019 19:04:42 +0000