Re: boot time, process start time, and NOW time

From: Tim Schmielau
Date: Mon Aug 16 2004 - 19:02:04 EST


> > Where did this all end up? Complaints about wandering start times are
> > persistent, and it'd be nice to get some fix in place...
[...]

> Simple fix: revert the patch below.
> Complicated fix: correct process start times in fork.c (no patch provided,
> too complicated for me to do).

Well, if we actually revert the patch, we'd also need to revert the
changes made to jiffies_to_clock_t() & Co. in response to the patch.
Otherwise we again end up inconsistent.

I could make a patch for that tomorrow, if there's interest. At least to
show that my analysis actually is correct.

Alternatively we might formulate uptime in terms of jiffies_to_clock_t()).


Tim



> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/