nixpkgs/pkgs/by-name/bp/bpftrace/runqlat-bt-no-includes.patch
Dominique Martinet 0bf9c7660f bpftrace: fix tcp*.bt/runqlat.bt scripts
tcp*.bt scripts tried to include glibc headers, which didn't work on
nixos because bpftrace tried to call clang-major with some options to
get the paths, but we never told it where to find it.
Give bpftrace the path directly instead of giving it a path to clang.

runqlat.bt doesn't work with glibc headers and requires kernel headers
which are no longer extracted, just provide its value.

Note the default clang output also had some clang-internal headers, but
these seem to be included anyway through libclang API without having to
give them here, so we only pass the glibc ones.

While here:
- also backport another bpftrace patch that made the tcp*.bt tools to
actually not require these includes
- and add tests that we can include these.

Co-authored-by: Arian van Putten <arian.vanputten@gmail.com>
2024-06-23 21:07:42 +09:00

46 lines
1.3 KiB
Diff

From 9b5f22854297aabb924969c25af66461d8d2fcb9 Mon Sep 17 00:00:00 2001
From: Dominique Martinet <asmadeus@codewreck.org>
Date: Fri, 21 Jun 2024 21:02:09 +0900
Subject: [PATCH] tools/runqlat: provide TASK_RUNNING as a define
runqlat requires kernel headers to run even with BTF, just because of a
define.
TASK_RUNNING isn't part of the stable API but it's never changed in all
of the linux git history so let's pretend it's stable and just define
it.
If we find a way to handle kheaders again in the future we might want to
consider reverting this.
Fixes: #3255
(cherry picked from commit aa041d9d85f9ec11235c39fdcb5833412ec27083)
---
tools/runqlat.bt | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/runqlat.bt b/tools/runqlat.bt
index 3d71b76062eb..1298f399aee7 100755
--- a/tools/runqlat.bt
+++ b/tools/runqlat.bt
@@ -11,7 +11,17 @@
* 17-Sep-2018 Brendan Gregg Created this.
*/
+#ifndef BPFTRACE_HAVE_BTF
#include <linux/sched.h>
+#else
+/*
+ * With BTF providing types, full headers are not needed.
+ * We only need to supply the preprocessor defines used in this script.
+ * TASK_RUNNING is not arch-dependant and has not changed in the linux
+ * git history (it is not part of the stable API though)
+ */
+#define TASK_RUNNING 0
+#endif
BEGIN
{
--
2.45.2