From 79d0c97f1988ee13777d774f21c8b389f5fa9a69 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sat, 20 Jul 2019 13:11:54 -0400 Subject: [PATCH] runtime: adapt to inconsistent export of task_work_add and task_work_cancel Ubuntu user reports their kernel 5.0.0-17-generic #18-Ubuntu SMP encounters pass-5 errors with an unresolved task_work_cancel() symbol. It turns out this is due to a ubuntu-specific (android-related) kernel commit that exports only task_work_add(). Updated buildrun.cxx and relevant runtime files to separately check for exportedness of task_work_cancel(). commit 2cc291a463c42641b4146b2507fa4499da35d335 Author: Christian Brauner Date: Wed Jan 16 23:13:25 2019 +0100 UBUNTU: SAUCE: binder: turn into module --- buildrun.cxx | 1 + runtime/linux/runtime.h | 2 ++ runtime/stp_task_work.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/buildrun.cxx b/buildrun.cxx index 9f6603777..5e8d3b961 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -448,6 +448,7 @@ compile_pass (systemtap_session& s) // used by runtime/stp_utrace.c output_exportconf(s, o, "task_work_add", "STAPCONF_TASK_WORK_ADD_EXPORTED"); + output_exportconf(s, o, "task_work_cancel", "STAPCONF_TASK_WORK_CANCEL_EXPORTED"); output_exportconf(s, o, "wake_up_state", "STAPCONF_WAKE_UP_STATE_EXPORTED"); output_exportconf(s, o, "try_to_wake_up", "STAPCONF_TRY_TO_WAKE_UP_EXPORTED"); output_exportconf(s, o, "signal_wake_up_state", "STAPCONF_SIGNAL_WAKE_UP_STATE_EXPORTED"); diff --git a/runtime/linux/runtime.h b/runtime/linux/runtime.h index df9b74c5c..5b42c5fb6 100644 --- a/runtime/linux/runtime.h +++ b/runtime/linux/runtime.h @@ -195,6 +195,8 @@ static void *kallsyms_uprobe_get_swbp_addr; /* task_work functions lack the necessary SYMBOL_EXPORT's */ #if !defined(STAPCONF_TASK_WORK_ADD_EXPORTED) static void *kallsyms_task_work_add; +#endif +#if !defined(STAPCONF_TASK_WORK_CANCEL_EXPORTED) static void *kallsyms_task_work_cancel; #endif diff --git a/runtime/stp_task_work.c b/runtime/stp_task_work.c index 93f56a5c2..67d34ccec 100644 --- a/runtime/stp_task_work.c +++ b/runtime/stp_task_work.c @@ -7,6 +7,8 @@ // First typedef from the original decls, then #define as typecasted calls. typedef typeof(&task_work_add) task_work_add_fn; #define task_work_add (* (task_work_add_fn)kallsyms_task_work_add) +#endif +#if !defined(STAPCONF_TASK_WORK_CANCEL_EXPORTED) typedef typeof(&task_work_cancel) task_work_cancel_fn; #define task_work_cancel (* (task_work_cancel_fn)kallsyms_task_work_cancel) #endif @@ -30,6 +32,8 @@ stp_task_work_init(void) _stp_error("Can't resolve task_work_add!"); return -ENOENT; } +#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!"); -- 2.43.5