userspace absolute timer value
All,
The issue that I had with userspace absolute time to start a timer (what latency test does) was due to a quirk on my board where the powerpc timebase was coming up as 0xdXXXXXXXXXXXXXXX which was causing the 32-bit userland to lose precision when getting the monotonic clock value. The latency test gets the time, adds a millisecond, and uses this time to start the process. However on my machine the time was way off due to the loss of precision. (there were more than 2^32 seconds, but time_t is only 32-bit) On my board adding some code to set the timebase to 0 in head_44x.S and that cleared up all the issues. Everything is working for me now. This appears to be a problem with how cobalt deals with 64-bit ns counters and 32-bit userspace clocks, however I could be missing something.
Steven
Quoted 13 lines · Steven Seeger
All,
The issue that I had with userspace absolute time to start a timer (what latency test does) was due to a quirk on my board where the powerpc timebase was coming up as 0xdXXXXXXXXXXXXXXX which was causing the 32-bit userland to lose precision when getting the monotonic clock value. The latency test gets the time, adds a millisecond, and uses this time to start the process. However on my machine the time was way off due to the loss of precision. (there were more than 2^32 seconds, but
time_tis only 32-bit) On my board adding some code to set the timebase to 0 inhead_44x.Sand that cleared up all the issues. Everything is working for me now. This appears to be a problem with how cobalt deals with 64-bit ns counters and 32-bit userspace clocks, however I could be missing something.
If I understand correctly, your problem is that struct timespec tv_sec member has 32 bits. Well, I am afraid there is not much we can do about that (I heard mainline has a plan to switch to a new timespec with a 64 bits tv_sec, but I do not know how much of that plan has been implemented).
Can you not call clock_settime to set a wallclock offset which will at least allow CLOCK_REALTIME to behave as expected ?
Regards.
Signature · 2 lines
Gilles. https://click-hack.org
Quoted 5 lines · On Wednesday, December 23, 2015 19:43:41 Gilles Chanteperdrix wrote:
If I understand correctly, your problem is that struct timespec
tv_secmember has 32 bits. Well, I am afraid there is not much we can do about that (I heard mainline has a plan to switch to a new timespec with a 64 bitstv_sec, but I do not know how much of that plan has been implemented).
Yes, this is exactly my problem.
Quoted 3 lines
Can you not call
clock_settimeto set a wallclock offset which will at least allowCLOCK_REALTIMEto behave as expected ?
The issue is with the testsuite/latency app. It uses clock_gettime(CLOCK_MONOTONIC) and adds a millisecond to that value and then uses that as the absolute start time of the latency thread. All calculates are based off this primed value.
There really is no reason for my board to come up with such a ridiculous timebase value. I have no idea why it does that. I set it to 0 very early in the kernel boot cycle and it fixed the issue. (This board is loaded via jtag so there may be some weirdness there.) This fix will last 136 years, right? :) My point was just that if the timebase is not a reasonable value I think this bug will manifest.
IMHO there is no benefit to allowing us to say we want some task to start in the year 500,000,000,000 so there isn't really a need for such large numbers in this one use-case.
Your idea of a fix is essentially correct, and should work across all systems. However, I was trying to run the standard latency app which should also work across all systems! :)
Steven