>From f103ce07fcc4b1e6c69105f77ac323a380062571 Mon Sep 17 00:00:00 2001
From: Torsten Polle <Torsten.Polle@gmx.de>
Date: Sun, 30 Jul 2017 08:54:36 +0200
Subject: [PATCH 1/2] Support inlined local_clock().

The following commit inlines local_clock(), which breaks the detection
whether local_clock() is supported by the kernel.

commit 2c923e94cd9c6acff3b22f0ae29cfe65e2658b40
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date:   Mon Apr 11 16:38:34 2016 +0200
---
 buildrun.cxx                         |  2 +-
 runtime/linux/autoconf-local-clock.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 runtime/linux/autoconf-local-clock.c

diff --git a/buildrun.cxx b/buildrun.cxx
index 8bf122d..b2018dc 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -406,7 +406,7 @@ compile_pass (systemtap_session& s)
 
   // used by tapset/timestamp_monotonic.stp
   output_exportconf(s, o, "cpu_clock", "STAPCONF_CPU_CLOCK");
-  output_exportconf(s, o, "local_clock", "STAPCONF_LOCAL_CLOCK");
+  output_autoconf(s, o, "autoconf-local-clock.c", "STAPCONF_LOCAL_CLOCK", NULL);
 
   // used by runtime/uprobe-inode.c
   output_either_exportconf(s, o, "uprobe_register", "register_uprobe",
diff --git a/runtime/linux/autoconf-local-clock.c b/runtime/linux/autoconf-local-clock.c
new file mode 100644
index 0000000..d0439fd
--- /dev/null
+++ b/runtime/linux/autoconf-local-clock.c
@@ -0,0 +1,31 @@
+#include <linux/sched.h>
+
+//
+// The following kernel commit inlined the local_clock()
+//
+// commit 2c923e94cd9c6acff3b22f0ae29cfe65e2658b40
+// Author: Daniel Lezcano <daniel.lezcano@linaro.org>
+// Date:   Mon Apr 11 16:38:34 2016 +0200
+//
+//     sched/clock: Make local_clock()/cpu_clock() inline
+//
+//     The local_clock/cpu_clock functions were changed to prevent a double
+//     identical test with sched_clock_cpu() when HAVE_UNSTABLE_SCHED_CLOCK
+//     is set. That resulted in one line functions.
+//
+//     As these functions are in all the cases one line functions and in the
+//     hot path, it is useful to specify them as static inline in order to
+//     give a strong hint to the compiler.
+//
+//     After verification, it appears the compiler does not inline them
+//     without this hint. Change those functions to static inline.
+//
+//     sched_clock_cpu() is called via the inlined local_clock()/cpu_clock()
+//     functions from sched.h. So any module code including sched.h will
+//     reference sched_clock_cpu(). Thus it must be exported with the
+//     EXPORT_SYMBOL_GPL macro.
+//
+
+void foo (void) {
+   (void) local_clock();
+}
-- 
2.7.4

