-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trace.py -t has negative time #931
Comments
Hmm. I'm seeing an even bigger offset on my box, +1118 seconds! So something is definitely wrong. Looking at the code, I'm using Perhaps @4ast would have an idea? |
this doesn't look good indeed and i don't see anything in kernel/time/timekeeping.c that could have caused this behavior. Since you see it on 4.9-rc5, it's certainly not the commit 58bfea953255 ("timekeeping: Fix __ktime_get_fast_ns() regression"). Can you please reproduce it on 4.10 and report it to lkml. |
Switching trace.py to use CLOCK_MONOTONIC instead of CLOCK_MONOTONIC_RAW fixes it. AFAIK, CLOCK_MONOTONIC is NTP adjusted. Is bpf_ktime_get_ns() NTP adjusted too? I also wrote this, clocks.c, to confirm the delta between the clocks: #include <time.h>
#include <stdio.h>
int main()
{
struct timespec t1, t2;
double d;
clock_gettime(CLOCK_MONOTONIC, &t1);
printf("CLOCK_MONOTONIC %ld s %ld ns\n", t1.tv_sec, t1.tv_nsec);
clock_gettime(CLOCK_MONOTONIC_RAW, &t2);
printf("CLOCK_MONOTONIC_RAW %ld s %ld ns\n", t2.tv_sec, t2.tv_nsec);
d = t2.tv_sec + (double)t2.tv_nsec / 1000000000;
d -= t1.tv_sec + (double)t1.tv_nsec / 1000000000;
printf("delta (RAW - non-RAW): %.6f", d);
return 0;
} system 1:
system 2:
|
@brendangregg Are you planning to fix this in a PR, or should I do it? |
I was digging into why, but yes, if you can send in the PR go ahead since it should be fixed (CLOCK_MONOTONIC_RAW -> CLOCK_MONOTONIC). So far I had:
|
This allows all the tools (currently: trace and memleak) to use the `monotonic_time` facility, with the fix to use `CLOCK_MONOTONIC` instead of `CLOCK_MONOTONIC_RAW`. Resolves iovisor#931.
Something up with the initial timestamp? Seems to always start at negative 20.5 seconds on this machine (Linux 4.9-rc5).
The text was updated successfully, but these errors were encountered: