RHEL-56962: Make systemtap compatible with kernel commit 68cbd415dd4b .

Resolves: RHEL-56962
This commit is contained in:
Martin Cermak 2024-09-09 09:57:54 +02:00
parent 7d308ecdb4
commit 6891bcb7fb
2 changed files with 87 additions and 2 deletions

79
RHEL-50107.patch Normal file
View File

@ -0,0 +1,79 @@
diff --git a/buildrun.cxx b/buildrun.cxx
index a7fcd6297..e3f2f83d1 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -400,6 +400,7 @@ compile_pass (systemtap_session& s)
output_exportconf(s, o2, "__module_text_address", "STAPCONF_MODULE_TEXT_ADDRESS");
output_exportconf(s, o2, "add_timer_on", "STAPCONF_ADD_TIMER_ON");
output_autoconf(s, o, cs, "autoconf-514-panic.c", "STAPCONF_514_PANIC", NULL);
+ output_autoconf(s, o, cs, "autoconf-task_work_cancel_func.c", "STAPCONF_TASK_WORK_CANCEL_FUNC", NULL);
output_dual_exportconf(s, o2, "probe_kernel_read", "probe_kernel_write", "STAPCONF_PROBE_KERNEL");
output_autoconf(s, o, cs, "autoconf-hw_breakpoint_context.c",
diff --git a/runtime/linux/autoconf-task_work_cancel_func.c b/runtime/linux/autoconf-task_work_cancel_func.c
new file mode 100644
index 000000000..0d460de6c
--- /dev/null
+++ b/runtime/linux/autoconf-task_work_cancel_func.c
@@ -0,0 +1,3 @@
+#include <linux/task_work.h>
+
+void* c = & task_work_cancel_func;
diff --git a/runtime/linux/runtime.h b/runtime/linux/runtime.h
index 0e9fe3fea..bd9307385 100644
--- a/runtime/linux/runtime.h
+++ b/runtime/linux/runtime.h
@@ -265,7 +265,7 @@ static void *kallsyms_uprobe_get_swbp_addr;
static void *kallsyms_task_work_add;
#endif
#if !defined(STAPCONF_TASK_WORK_CANCEL_EXPORTED)
-static void *kallsyms_task_work_cancel;
+static void *kallsyms_task_work_cancel_fn;
#endif
#if !defined(STAPCONF_TRY_TO_WAKE_UP_EXPORTED) && !defined(STAPCONF_WAKE_UP_STATE_EXPORTED)
diff --git a/runtime/stp_task_work.c b/runtime/stp_task_work.c
index 0dd3095b6..4818fecbf 100644
--- a/runtime/stp_task_work.c
+++ b/runtime/stp_task_work.c
@@ -3,14 +3,25 @@
#include "linux/task_work_compatibility.h"
+// Handle kernel commit 68cbd415dd4b9c5b9df69f0f091879e56bf5907a
+// task_work: s/task_work_cancel()/task_work_cancel_func()/
+#if defined(STAPCONF_TASK_WORK_CANCEL_FUNC)
+#define TASK_WORK_CANCEL_FN task_work_cancel_func
+#else
+#define TASK_WORK_CANCEL_FN task_work_cancel
+#endif
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+
#if !defined(STAPCONF_TASK_WORK_ADD_EXPORTED)
// First typedef from the original decls, then #define as typecasted calls.
typedef typeof(&task_work_add) task_work_add_fn;
#define task_work_add(a,b,c) ibt_wrapper(int, (* (task_work_add_fn)kallsyms_task_work_add)((a), (b), (c)))
#endif
#if !defined(STAPCONF_TASK_WORK_CANCEL_EXPORTED)
-typedef typeof(&task_work_cancel) task_work_cancel_fn;
-#define task_work_cancel(a,b) ibt_wrapper(struct callback_head *, (* (task_work_cancel_fn)kallsyms_task_work_cancel)((a), (b)))
+typedef typeof(&TASK_WORK_CANCEL_FN) task_work_cancel_fn;
+#define task_work_cancel(a,b) ibt_wrapper(struct callback_head *, (* (task_work_cancel_fn)kallsyms_task_work_cancel_fn)((a), (b)))
#endif
/* To avoid a crash when a task_work callback gets called after the
@@ -35,9 +46,9 @@ stp_task_work_init(void)
}
#endif
#if !defined(STAPCONF_TASK_WORK_CANCEL_EXPORTED)
- kallsyms_task_work_cancel = (void *)kallsyms_lookup_name("task_work_cancel");
- if (kallsyms_task_work_cancel == NULL) {
- _stp_error("Can't resolve task_work_cancel!");
+ kallsyms_task_work_cancel_fn = (void *)kallsyms_lookup_name(TOSTRING(TASK_WORK_CANCEL_FN));
+ if (kallsyms_task_work_cancel_fn == NULL) {
+ _stp_error("Can't resolve %s!", TOSTRING(TASK_WORK_CANCEL_FN));
return -ENOENT;
}
#endif

View File

@ -121,7 +121,7 @@ m stapdev stapdev
Name: systemtap
# PRERELEASE
Version: 5.1
Release: 3%{?release_override}%{?dist}
Release: 4%{?release_override}%{?dist}
# for version, see also configure.ac
@ -160,6 +160,7 @@ Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz
Patch1: RHEL-36199a.patch
Patch2: RHEL-36199b.patch
Patch3: PR31495.patch
Patch4: RHEL-50107.patch
# Build*
BuildRequires: make
@ -589,6 +590,7 @@ or within a container.
%patch -P1 -p1
%patch -P2 -p1
%patch -P3 -p1
%patch -P4 -p1
%build
@ -1316,7 +1318,11 @@ exit 0
# PRERELEASE
%changelog
* Tue May 16 2024 Martin Cermak <mcermak@redhat.com> - 5.1-3
* Mon Sep 9 2024 Martin Cermak <mcermak@redhat.com> - 5.1-4
- RHEL-50107.patch: Make systemtap compatible with kernel
commit 68cbd415dd4b . Related: RHEL-56962 .
* Thu May 16 2024 Martin Cermak <mcermak@redhat.com> - 5.1-3
- RHEL-7318
* Tue May 14 2024 William Cohen <wcohen@redhat.com> - 5.1-2