summaryrefslogtreecommitdiffstats
path: root/tapset/timestamp_gtod.stp
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-02-23 14:22:38 -0800
committerJosh Stone <jistone@redhat.com>2009-02-23 14:22:38 -0800
commit5780cc7f8208ebca519d6e076fe403b1220ab865 (patch)
treec0c54c18bab0ad61963f7efc972cb2b773806909 /tapset/timestamp_gtod.stp
parent3c1f71d54d487806d4dfde0421b43e95d3662ea5 (diff)
downloadsystemtap-steved-5780cc7f8208ebca519d6e076fe403b1220ab865.tar.gz
systemtap-steved-5780cc7f8208ebca519d6e076fe403b1220ab865.tar.xz
systemtap-steved-5780cc7f8208ebca519d6e076fe403b1220ab865.zip
Add selective use of _stp_time_init/kill (PR9822)
Our gettimeofday runtime has frequent wakeups to stay in sync with kernel time, but this is wasted effort if gettimeofday is not used in the script. This patch moves the calls to _stp_time_init and _stp_time_kill into begin and end/error probes, which only get pulled in if one of the gettimeofday variants is called.
Diffstat (limited to 'tapset/timestamp_gtod.stp')
-rw-r--r--tapset/timestamp_gtod.stp68
1 files changed, 68 insertions, 0 deletions
diff --git a/tapset/timestamp_gtod.stp b/tapset/timestamp_gtod.stp
new file mode 100644
index 00000000..43b127dc
--- /dev/null
+++ b/tapset/timestamp_gtod.stp
@@ -0,0 +1,68 @@
+// timestamp tapset -- gettimeofday variants
+// Copyright (C) 2005-2009 Red Hat Inc.
+// Copyright (C) 2006 Intel Corporation.
+//
+// This file is part of systemtap, and is free software. You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+
+function _gettimeofday_init:long() %{
+ THIS->__retvalue = _stp_init_time(); /* Kick off the Big Bang. */
+%}
+
+probe begin(-0x8000000000000000) {
+ if (_gettimeofday_init() != 0)
+ error("couldn't initialize gettimeofday")
+}
+
+function _gettimeofday_kill() %{
+ _stp_kill_time(); /* Go to a beach. Drink a beer. */
+%}
+
+probe end(0x7FFFFFFFFFFFFFFF), error(0x7FFFFFFFFFFFFFFF) {
+ _gettimeofday_kill()
+}
+
+
+/**
+ * sfunction gettimeofday_ns - Number of nanoseconds since UNIX epoch.
+ *
+ * Return the number of nanoseconds since the UNIX epoch.
+ */
+function gettimeofday_ns:long () %{ /* pure */
+ /* NOTE: we can't use do_gettimeofday because we could be called from a
+ * context where xtime_lock is already held. See bug #2525. */
+ THIS->__retvalue = _stp_gettimeofday_ns();
+ if (THIS->__retvalue < 0)
+ CONTEXT->last_error = "gettimeofday not initialized";
+%}
+
+/**
+ * sfunction gettimeofday_us - Number of microseconds since UNIX epoch.
+ *
+ * Return the number of microseconds since the UNIX epoch.
+ */
+function gettimeofday_us:long () {
+ return gettimeofday_ns() / 1000;
+}
+
+/**
+ * sfunction gettimeofday_ms - Number of milliseconds since UNIX epoch.
+ *
+ * Return the number of milliseconds since the UNIX epoch.
+ */
+function gettimeofday_ms:long () {
+ return gettimeofday_ns() / 1000000;
+}
+
+/**
+ * sfunction gettimeofday_s - Number of seconds since UNIX epoch.
+ *
+ * Return the number of seconds since the UNIX epoch.
+ */
+function gettimeofday_s:long () {
+ return gettimeofday_ns() / 1000000000;
+}
+
+// likewise jiffies, monotonic_clock ...