Messages in this thread Patch in this message | | | Date | Tue, 17 Aug 2004 01:08:10 +0200 (CEST) | From | Tim Schmielau <> | Subject | Re: boot time, process start time, and NOW time |
| |
On Mon, 16 Aug 2004, Andrew Morton wrote:
> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> wrote: > > > > Albert Cahalan <albert@users.sf.net> writes: > > > > > Even with the 2.6.7 kernel, I'm still getting reports of process > > > start times wandering. Here is an example: > > > > > > "About 12 hours since reboot to 2.6.7 there was already a > > > difference of about 7 seconds between the real start time > > > and the start time reported by ps. Now, 24 hours since reboot > > > the difference is 10 seconds." > > > > > > The calculation used is: > > > > > > now - uptime + time_from_boot_to_process_start > > > > Start-time and uptime is using different source. Looks like the > > jiffies was added bogus lost counts. > > > > quick hack. Does this change the behavior? > > Where did this all end up? Complaints about wandering start times are > persistent, and it'd be nice to get some fix in place...
The trouble seems to be due to the patch below, part of a larger cleanup (http://linus.bkbits.net:8080/linux-2.5/cset%403ef4851dGg0fxX58R9Zv8SIq9fzNmQ?nav=index.html|src/.|src/fs|src/fs/proc|related/fs/proc/proc_misc.c) by George.
Quoting from the changelog entry:
"Changes the uptime code to use the posix_clock_monotonic notion of uptime instead of the jiffies. This time will track NTP changes and so should be better than your standard wristwatch (if your using ntp)."
George is absolutely right that it's more precise. However, it's also inconsistent with the process start times which use plain uncorrected jiffies. ps stumbles over this inconsistency.
Simple fix: revert the patch below. Complicated fix: correct process start times in fork.c (no patch provided, too complicated for me to do).
George?
diff -Nru a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c --- a/fs/proc/proc_misc.c 2004-08-16 15:48:44 -07:00 +++ b/fs/proc/proc_misc.c 2004-08-16 15:48:44 -07:00 @@ -137,36 +137,19 @@ static int uptime_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { - u64 uptime; - unsigned long uptime_remainder; + struct timespec uptime; + struct timespec idle; int len; + u64 idle_jiffies = init_task.utime + init_task.stime; - uptime = get_jiffies_64() - INITIAL_JIFFIES; - uptime_remainder = (unsigned long) do_div(uptime, HZ); + do_posix_clock_monotonic_gettime(&uptime); + jiffies_to_timespec(idle_jiffies, &idle); + len = sprintf(page,"%lu.%02lu %lu.%02lu\n", + (unsigned long) uptime.tv_sec, + (uptime.tv_nsec / (NSEC_PER_SEC / 100)), + (unsigned long) idle.tv_sec, + (idle.tv_nsec / (NSEC_PER_SEC / 100))); -#if HZ!=100 - { - u64 idle = init_task.utime + init_task.stime; - unsigned long idle_remainder; - - idle_remainder = (unsigned long) do_div(idle, HZ); - len = sprintf(page,"%lu.%02lu %lu.%02lu\n", - (unsigned long) uptime, - (uptime_remainder * 100) / HZ, - (unsigned long) idle, - (idle_remainder * 100) / HZ); - } -#else - { - unsigned long idle = init_task.utime + init_task.stime; - - len = sprintf(page,"%lu.%02lu %lu.%02lu\n", - (unsigned long) uptime, - uptime_remainder, - idle / HZ, - idle % HZ); - } -#endif return proc_calc_metrics(page, start, off, count, eof, len); }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |