[DTrace-devel] [PATCH v2] Add support for built-in variable walltimestamp

Eugene Loh eugene.loh at oracle.com
Tue Jun 15 10:25:27 PDT 2021


On 6/15/21 11:08 AM, Kris Van Hees wrote:

> On Mon, Jun 14, 2021 at 05:52:01PM -0400, eugene.loh at oracle.com wrote:
>> From: Eugene Loh <eugene.loh at oracle.com>
>>
>> In the pre-compiled get_bvar() function, use bpf_ktime_get_ns() to
>> get the time (in nsec) since boot.  This value is adjusted by adding
>> the POSIX time when the system was booted.
>>
>> diff --git a/bpf/get_bvar.c b/bpf/get_bvar.c
>> +extern uint64_t BOOTTIMEHI;
>> +extern uint64_t BOOTTIMELO;
>> @@ -167,6 +169,10 @@ noinline uint64_t dt_get_bvar(dt_dctx_t *dctx, uint32_t id)
>> +	case DIF_VAR_WALLTIMESTAMP:
>> +		return bpf_ktime_get_ns()
>> +		    + (((uint64_t) &BOOTTIMEHI) << 32)
>> +		    + ((uint64_t) &BOOTTIMELO);
> Why do you use two variables when each is 64-bit bits wide and the adjustment
> itself is a 64-bit value.  So, a single variable ought to be enough.
Yup.  That's what I thought.  Nevertheless, only the lowest 32 bits 
survive.  I guess I can investigate more, but the single variable did 
not work for me.  To be picky, the width of the variable is 
unimportant;  we want the address.  But yeah, I agree with you, but it 
just did not work.



More information about the DTrace-devel mailing list