Repository navigation
Conversation
| oldStartTimeSinceBoot := oldLeader.StartTimeSinceBoot() | ||
| t.mu.Lock() | ||
| t.startTime = oldStartTime | ||
| t.startTimeSinceBoot = oldStartTimeSinceBoot |
There was a problem hiding this comment.
Please keep the new timestamp's instant/duration representation consistent. StartTimeSinceBoot() returns time.Duration, but startTimeSinceBoot is ktime.Time, so this assignment fails to compile. The focused //pkg/sentry/kernel:kernel_test build fails here with “cannot use oldStartTimeSinceBoot ... as ktime.Time value in assignment”. There is another mismatch in statData.Generate: uptime is now ktime.Time, while linux.ClockTFromDuration(uptime) requires time.Duration. Preserve the stored clock instant when copying it and explicitly convert to elapsed duration for the proc calculations (or consistently store a duration).
Codex posting on behalf of Ayush
|
|
||
| // Pretend that we've spent zero time sleeping (second number). | ||
| fmt.Fprintf(buf, "%.2f 0.00\n", now.Sub(k.Timekeeper().BootTime()).Seconds()) | ||
| fmt.Fprintf(buf, "%.2f 0.00\n", uptime.Seconds()) |
There was a problem hiding this comment.
Please convert the boot-clock instant to a duration before formatting its seconds. ktime.Time.Seconds() returns int64, whereas the previous time.Duration.Seconds() returned float64. With the unchanged %.2f, this now writes a token such as %!f(int64=123) 0.00 instead of numeric uptime, breaking readers of /proc/uptime even after the compilation errors are fixed. Using an elapsed duration's Seconds() preserves the fractional seconds and the existing numeric format. The existing ProcUptime.IsPresent test also depends on this parseable, advancing value.
Codex posting on behalf of Ayush
|
Please squash the three follow-up fix commits ( Codex posting on behalf of Ayush |
18889c1 to
3d5d7e7
Compare
|
Hi Ayush, I've fixed the issues you pointed out and squashed the follow-up commits into one. Please let me know if anything else needs to be fixed. Thanks for your feedback ❤️ |
|
@asimawdah I don't think the above comments are addressed. We still call |
afbe7a1 to
89857e9
Compare
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
The uptime values exposed by
/proc/uptimeand/proc/statare derived by subtracting the boot-time realtime timestamp from the current realtime clock.The
starttimefield in/proc/[pid]/statis derived from each task's realtime start timestamp.When the host realtime clock moves backwards, these values can move backwards too. A process created after the clock adjustment can appear to have started before an older process.
What is the new behavior?
/proc/uptimeand/proc/statuptime fromCLOCK_BOOTTIME.CLOCK_BOOTTIMEseparately from its realtime start timestamp./proc/[pid]/stat.The existing realtime
Task.StartTime()value remains unchanged for control, tracing, and other consumers.Fixes #17066
How was this tested?
Tests were not run locally.
The existing
pkg/sentry/kernel/timekeeper_test.goincludes coverage for realtime moving backwards while boot time remains continuous.