summaryrefslogtreecommitdiffstats
path: root/runtime/time.c
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 /runtime/time.c
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 'runtime/time.c')
-rw-r--r--runtime/time.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/time.c b/runtime/time.c
index ad7cef9d..58c23e57 100644
--- a/runtime/time.c
+++ b/runtime/time.c
@@ -223,6 +223,7 @@ _stp_kill_time(void)
#endif
_stp_free_percpu(stp_time);
+ stp_time = NULL;
}
}
@@ -232,6 +233,8 @@ _stp_init_time(void)
{
int ret = 0;
+ _stp_kill_time();
+
stp_time = _stp_alloc_percpu(sizeof(stp_time_t));
if (unlikely(stp_time == 0))
return -1;
@@ -263,7 +266,7 @@ _stp_init_time(void)
}
}
#endif
- if (ret)
+ if (ret)
_stp_kill_time();
return ret;
}
@@ -278,6 +281,9 @@ _stp_gettimeofday_ns(void)
stp_time_t *time;
int i = 0;
+ if (!stp_time)
+ return -1;
+
preempt_disable();
time = per_cpu_ptr(stp_time, smp_processor_id());