This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] tapset: add a tapset function for reading epoch time in ARM
- From: Jey Jay <rjayavrp2 at gmail dot com>
- To: systemtap at sourceware dot org, "Frank Ch. Eigler" <fche at redhat dot com>, jistone at redhat dot com, wcohen at redhat dot com
- Cc: jeyaraman dot rangasamy at lge dot com
- Date: Thu, 12 Jun 2014 15:24:57 +0530
- Subject: [PATCH] tapset: add a tapset function for reading epoch time in ARM
- Authentication-results: sourceware.org; auth=none
gettimeofday_ns() for ARM is implemented to return a fake value because
it depends on get_cycles() which returns 0 in ARM. This patch adds
a tapset function which uses getnstimeofday() for collecting epoch time.
Signed-off-by: Jeyaraman Rangasamy <rjayavrp2@gmail.com>
---
runtime/time.c | 6 ++++++
tapset/indent-default.stp | 7 ++++++-
tapset/linux/timestamp_gtod.stp | 43 +++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/runtime/time.c b/runtime/time.c
index b4c2012..3d94c6d 100644
--- a/runtime/time.c
+++ b/runtime/time.c
@@ -411,3 +411,9 @@ _stp_gettimeofday_ns(void)
return base + delta;
}
+
+static int64_t _stp_getnstimeofday_ns(void){
+ struct timespec ts;
+ getnstimeofday(&ts);
+ return timespec_to_ns(&ts);
+}
diff --git a/tapset/indent-default.stp b/tapset/indent-default.stp
index fb9ff57..d2980f2 100644
--- a/tapset/indent-default.stp
+++ b/tapset/indent-default.stp
@@ -1 +1,6 @@
-function __indent_timestamp() { return gettimeofday_us() }
+function __indent_timestamp() {
+ #if defined (__arm__)
+ return getnstimeofday_us()
+ #endif
+ return gettimeofday_us()
+}
diff --git a/tapset/linux/timestamp_gtod.stp b/tapset/linux/timestamp_gtod.stp
index 668f79b..a16f9b9 100644
--- a/tapset/linux/timestamp_gtod.stp
+++ b/tapset/linux/timestamp_gtod.stp
@@ -55,3 +55,46 @@ function gettimeofday_ms:long () {
function gettimeofday_s:long () {
return gettimeofday_ns() / 1000000000;
}
+
+/**
+ * sfunction getnstimeofday_ns - Number of nanoseconds since UNIX epoch
+ *
+ * Description: This function returns the number of nanoseconds
+ * since the UNIX epoch.
+ */
+function getnstimeofday_ns:long () %{ /* pure */ /* unprivileged */
+
+ STAP_RETVALUE = _stp_getnstimeofday_ns();
+ if (STAP_RETVALUE < 0)
+ CONTEXT->last_error = "getnstimeofday not initialized";
+%}
+
+/**
+ * sfunction getnstimeofday_us - Number of microseconds since UNIX epoch
+ *
+ * Description: This function returns the number of microseconds
+ * since the UNIX epoch.
+ */
+function getnstimeofday_us:long () {
+ return getnstimeofday_ns() / 1000;
+}
+
+/**
+ * sfunction getnstimeofday_ms - Number of milliseconds since UNIX epoch
+ *
+ * Description: This function returns the number of milliseconds
+ * since the UNIX epoch.
+ */
+function getnstimeofday_ms:long () {
+ return getnstimeofday_ns() / 1000000;
+}
+
+/**
+ * sfunction gettimeofday_s - Number of seconds since UNIX epoch
+ *
+ * Description: This function returns the number of seconds since
+ * the UNIX epoch.
+ */
+function getnstimeofday_s:long () {
+ return getnstimeofday_ns() / 1000000000;
+}
--
1.7.9.5