Re: In DTrace, why does timestamp increase after a call to chill() but vtimestamp and walltimestamp do not?
- Reply: Mark Johnston : "Re: In DTrace, why does timestamp increase after a call to chill() but vtimestamp and walltimestamp do not?"
- In reply to: Mateusz Piotrowski : "In DTrace, why does timestamp increase after a call to chill() but vtimestamp and walltimestamp do not?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 23 Nov 2022 14:07:23 UTC
On Mon, Nov 21, 2022 at 06:19:16PM +0100, Mateusz Piotrowski wrote: > Hello all, > > I'd like to understand why calling chill() in a DTrace action block increases the timestampvariable, but not vtimestamp and walltimestamp. > Here's an example showing timestamp increasing after a call to chill(): I think you found a bug in dtrace. When a dtrace probe fires and actions attached to that probe are executed, the value of *timestamp is cached in a struct dtrace_mstate on the firing CPU's stack. This means that in D, within a probe body, multiple accesses of *timestamp will return the same cached value. As it turns out, the implementation of chill() will invalidate that cached value, but only for "timestamp", not for walltimestamp, which seems incorrect. Below is an untested patch which should fix your example. I think the behaviour of vtimestamp that you observe is expected. From the description, "The counter does not include the time that is spent in DTrace predicates and actions", so I wouldn't expect it to advance while dtrace_probe() is running. And indeed, it gets advanced once at the beginning of dtrace_probe(). diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 44a85db65117..cd6ed332af7b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -7082,11 +7082,12 @@ dtrace_action_chill(dtrace_mstate_t *mstate, hrtime_t val) continue; /* - * Normally, we assure that the value of the variable "timestamp" does - * not change within an ECB. The presence of chill() represents an - * exception to this rule, however. + * Normally, we assure that the value of the variables "timestamp" and + * "walltimestamp" do not change within an ECB. The presence of chill() + * represents an exception to this rule, however. */ - mstate->dtms_present &= ~DTRACE_MSTATE_TIMESTAMP; + mstate->dtms_present &= + ~(DTRACE_MSTATE_TIMESTAMP | DTRACE_MSTATE_WALLTIMESTAMP); cpu->cpu_dtrace_chilled += val; }