public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Support for inlined local_clock()/cpu_clock()
@ 2017-07-30  7:49 Torsten Polle
  2017-07-31 20:20 ` David Smith
  0 siblings, 1 reply; 2+ messages in thread
From: Torsten Polle @ 2017-07-30  7:49 UTC (permalink / raw)
  To: systemtap

[-- Attachment #1: Type: text/plain, Size: 192 bytes --]

Hi,

newer versions of the kernel inline the functions local_clock() and cpu_clock(). The checks based on the presence of these symbols in the kernel binary fail.

Kind Regards,
Torsten

[-- Attachment #2: 0001-Support-inlined-local_clock.patch --]
[-- Type: application/octet-stream, Size: 2700 bytes --]

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


[-- Attachment #3: 0002-Support-inlined-cpu_clock.patch --]
[-- Type: application/octet-stream, Size: 2696 bytes --]

From 7d6ee5c497337eaa8afdb01f972634a814682f37 Mon Sep 17 00:00:00 2001
From: Torsten Polle <Torsten.Polle@gmx.de>
Date: Sun, 30 Jul 2017 08:57:26 +0200
Subject: [PATCH 2/2] Support inlined cpu_clock().

The following commit inlines cpu_clock(), which breaks the detection
whether cpu_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-cpu-clock.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 runtime/linux/autoconf-cpu-clock.c

diff --git a/buildrun.cxx b/buildrun.cxx
index b2018dc..e21f0b5 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -405,7 +405,7 @@ compile_pass (systemtap_session& s)
   output_autoconf(s, o, "autoconf-sched-mm.c", "STAPCONF_SCHED_MM_H", NULL);
 
   // used by tapset/timestamp_monotonic.stp
-  output_exportconf(s, o, "cpu_clock", "STAPCONF_CPU_CLOCK");
+  output_autoconf(s, o, "autoconf-cpu-clock.c", "STAPCONF_CPU_CLOCK", NULL);
   output_autoconf(s, o, "autoconf-local-clock.c", "STAPCONF_LOCAL_CLOCK", NULL);
 
   // used by runtime/uprobe-inode.c
diff --git a/runtime/linux/autoconf-cpu-clock.c b/runtime/linux/autoconf-cpu-clock.c
new file mode 100644
index 0000000..d1ab73b
--- /dev/null
+++ b/runtime/linux/autoconf-cpu-clock.c
@@ -0,0 +1,31 @@
+#include <linux/sched.h>
+
+//
+// The following kernel commit inlined the cpu_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) cpu_clock(0);
+}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Support for inlined local_clock()/cpu_clock()
  2017-07-30  7:49 [PATCH] Support for inlined local_clock()/cpu_clock() Torsten Polle
@ 2017-07-31 20:20 ` David Smith
  0 siblings, 0 replies; 2+ messages in thread
From: David Smith @ 2017-07-31 20:20 UTC (permalink / raw)
  To: Torsten Polle; +Cc: systemtap

On Sun, Jul 30, 2017 at 2:49 AM, Torsten Polle <Torsten.Polle@gmx.de> wrote:
> Hi,
>
> newer versions of the kernel inline the functions local_clock() and cpu_clock(). The checks based on the presence of these symbols in the kernel binary fail.

I combined these patch and checked them in as c8bd6bf.

Thanks!

-- 
David Smith
Principal Software Engineer
Red Hat

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-31 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-30  7:49 [PATCH] Support for inlined local_clock()/cpu_clock() Torsten Polle
2017-07-31 20:20 ` David Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).