On 01/04/17 09:37, Paul Goyette wrote:
On Wed, 4 Jan 2017, Frank Kardel wrote:
I would also suggest a 64 bit fraction
like in struct bintime, which we already have and use internally
for timekeeping anyway along with the timespec, timeval
conversion functions.
Thus collecting can be faster as we don't need to make the
conversions when collectiing. I deem converting at userlevel the
least worry.
For time stamp fetching see "man 9 microtime" or
kern/kern_tc.c:{get,}bin{,up}time(). "get"-versions are cheaper,
but only updated at hardclock(). The non-get ones are directly
related
to the current time counter.
Using bintime as the "native" timestamp representation would
require
changes to the in-kernel structures, rather than just those used
for
I see - I didn't look at the event collection yet. bintime is the
native kernel timestamp format,
though it is not used everywhere.
exporting the data to userland. And if the in-kernel
structures are
changed, then we'll have to be able to print them from within the
kernel.
For userland we could just do float- or double-divide to convert
the
fraction to printable format;
Yep that's the usual procedure.
sys/time.h already has a non-fp conversion to timeval/timespec.
static __inline void
bintime2timespec(const struct bintime *bt, struct timespec *ts)
{
ts->tv_sec = bt->sec;
ts->tv_nsec =
(long)(((uint64_t)1000000000 * (uint32_t)(bt->frac
>> 32)) >> 32);
}
it's not clear how we could print these
values from within the kernel (where we're not allowed to use
fp?).
Would converting to timespec/timeval and the usual %d.%06?d
printf-fmt be an option without creating a horrible data wrangling
mess? (I don't know how many
printfs would be affected).
+------------------+--------------------------+------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail
addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at
whooppee.com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at
netbsd.org |
+------------------+--------------------------+------------------------+
Frank
|