This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Problems with gettimeofday_ns()
- From: "Julio M. Merino Vidal" <jmerino at ac dot upc dot edu>
- To: systemtap at sources dot redhat dot com
- Date: Thu, 21 Feb 2008 12:05:08 +0100
- Subject: Problems with gettimeofday_ns()
Hello,
[ Please CC me any replies as I am not currently subscribed to this
list. ]
I am using SystemTap to obtain traces of process scheduling. This is
on a machine with a SMT-enabled processor (a Cell). To do this, I
have added some markers to the kernel and then use small probes in
stap to print a line mentioning when the probe fired, what was it and
any parameters I may be interested in.
To add a timestamp to each line I was using gettimeofday_ns(). I
have found, however, that I receive events with duplicate timestamps,
which is OK if it is not supposed to be strict monotonically increasing.
But the big problem is that sometimes I receive events in the
incorrect order! That is, I place a marker B after a marker A in the
code, and I know it is impossible for B to appear before A in a
trace. However, sometimes, I get B before A in the final trace with
the timings (supposedly) reversed. I also print the CPU that fired
the events, and both are happening from the same virtual CPU, so the
possibility of both CPUs using different timings is not relevant.
If I change the gettimeofday_ns call to get_cycles or to a custom
counter instead, things go perfectly.
Any idea about why this is happening? May it be a bug in stap, or am
I missing something in the way gettimeofday works?
Thanks.