All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: Rob Landley <rob@landley.net>
Cc: Oleg Nesterov <oleg@redhat.com>,
	mtk.manpages@gmail.com, linux-kernel@vger.kernel.org,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: Question about /proc/uptime
Date: Thu, 2 Jan 2014 09:28:23 +0100	[thread overview]
Message-ID: <20140102092823.2434c96f@mschwide> (raw)
In-Reply-To: <52C486BC.50603@landley.net>

On Wed, 01 Jan 2014 15:21:00 -0600
Rob Landley <rob@landley.net> wrote:

> On 01/01/14 06:41, Martin Schwidefsky wrote:
> > On Tue, 31 Dec 2013 22:17:39 -0600
> > Rob Landley <rob@landley.net> wrote:
> >
> >> On 12/30/13 09:26, Martin Schwidefsky wrote:
> >>> On Mon, 30 Dec 2013 16:11:10 +0100
> >>> Oleg Nesterov <oleg@redhat.com> wrote:
> >>>> Not sure I understand... except that timekeeping_resume() does
> >>>> __timekeeping_inject_sleeptime().
> >>>
> >>> Hmm, you are right. The sleeptime is added to the monotonic boottime.
> >>> So the first value of /proc/uptime is the wall-time since boot.
> >>> And the second value is combined idle time over all cpus.
> >>
> >> Is there an obvious way to query the non-suspend uptime from userspace?
> >
> > clock_gettime with CLOCK_MONOTONIC gives you the uptime minus without the
> > suspend time.
> 
> Given that the clock_gettime man page says:
> 
>    CLOCK_MONOTONIC
>      Clock that cannot be set and  represents  monotonic  time  since
>      some unspecified starting point.
> 
> Can I rely on it _continuing_ to do so in future, and if so should the 
> man page be clarified?

Good point. CLOCK_MONOTONIC is implemented in a specific way now and I
doubt that this will change any time soon, but you have no guarantee that
it will keep the property 'monotonic-time = uptime - suspend-time'.
You can not use the values in /proc/stat either as you can set any CPU
offline, which means that no CPU line contains all ticks since boot.

Without the CLOCK_MONOTONIC option I do not see a way how to get the
non-suspend uptime from user space.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


      reply	other threads:[~2014-01-02  8:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-26  2:30 Question about /proc/uptime Rob Landley
2013-12-27 14:45 ` Oleg Nesterov
2013-12-30  8:56   ` Martin Schwidefsky
2013-12-30 15:11     ` Oleg Nesterov
2013-12-30 15:26       ` Martin Schwidefsky
2014-01-01  4:17         ` Rob Landley
2014-01-01 12:41           ` Martin Schwidefsky
2014-01-01 21:21             ` Rob Landley
2014-01-02  8:28               ` Martin Schwidefsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140102092823.2434c96f@mschwide \
    --to=schwidefsky@de.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=oleg@redhat.com \
    --cc=rob@landley.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.