Re: Question about /proc/uptime

From: Oleg Nesterov
Date: Mon Dec 30 2013 - 10:10:37 EST


On 12/30, Martin Schwidefsky wrote:
<
> On Fri, 27 Dec 2013 15:45:04 +0100
> Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> > Add Frederic, I am not sure I understand this correctly.
> >
> > On 12/25, Rob Landley wrote:
> > >
> > > There are two values here, the first is seconds since boot time (which
> > > is just elapsed time; at one point it was ajusted for suspend and that
> > > was revered as confusing).
> >
> > Hmm, uptime_proc_show() still uses get_monotonic_boottime(), this should
> > include suspend time?
>
> The first value of /proc/uptime is the amount of time the system has been
> running, the sum of the suspend time is not included.

Hmm. It uses get_monotonic_boottime() and this helper adds
timekeeper->total_sleep_time to the returned value? Even the comment says

* This is similar to CLOCK_MONTONIC/ktime_get_ts, but also
* includes the time spent in suspend.

> timekeeping_resume()
> is supposed to take care of that.

Not sure I understand... except that timekeeping_resume() does
__timekeeping_inject_sleeptime().

> > > The second value isn't documented but looking at fs/proc/uptime.c I
> > > think it's idle time?
> >
> > And this cpustat[CPUTIME_IDLE] doesn't match get_idle_time(), I guess
> > it only counts ticks.
>
> The second value of /proc/uptime is the sum of the idle time of all cpus.
> The value should roughly match the sum over get_idle_time() for all cpus.
> The difference is that get_idle_time() uses arch_idle_time to add the
> time for the currently running idle period as well (at least for s390).

Only if defined(arch_idle_time) ?

Otherwise get_idle_time() uses get_cpu_idle_time_us() and
CONFIG_NO_HZ_COMMON makes a difference.

> That does make a difference if the cpus stay idle for long periods of
> time.

Yes.

Oleg.

--
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/