[DTrace-devel] semantics of "timestamp"
Kris Van Hees
kris.van.hees at oracle.com
Thu Jul 16 13:16:47 PDT 2020
On Thu, Jul 16, 2020 at 12:57:17PM -0700, Eugene Loh wrote:
> What are the semantics of the built-in variable "timestamp"?
> Specifically, does it record a fresh time stamp each time it is called?
> Or it is measured once upon probe (or clause) entry and then reused?
>
> The documentation isn't real specific, but it seems to imply a fresh
> time on each call. Meanwhile, DTv1 seems to get a fresh call for each
> clause and then reuse that value during that clause. In contrast, DTv2
> seems to get a fresh value with each clause. Is the change from DTv1 to
> DTv2 intentional? Should the legacy behavior be preserved?
The correct behaviour based on the reference implementation is that the value
of 'timestamp' is consistent within the scope of a clause (and its predicate).
Therefore, yes, we need to fix this.
What needs to happen is that the mstate structure needs to get a new field
to hold the timestamp value, and it should be initialized to 0 in the
prologue code generated in dt_cg_prologue(). Then, in get_bvar() we need to
check to see if mst->timestamp is 0. If it is, we use the BPF helper to obtain
the timestamp value and we store that in mst->timestamp. Either way, we then
return mst->timestamp as value.
That will ensure that the value is consistent for multiple timestamp references
within a clause (and its predicate) while ensuring that between clauses we get
a new value.
Want to tackle that?
More information about the DTrace-devel
mailing list