public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: info@engel-internet.de, linux-kernel@vger.kernel.org
Subject: Re: CLOCK_MONOTONIC after suspend
Date: Wed, 15 Dec 2021 20:17:58 +0100	[thread overview]
Message-ID: <87o85hr82h.ffs@tglx> (raw)
In-Reply-To: <91eaa528-9605-134e-8e38-ecc37a0360e1@engel-internet.de>

Dirk,

On Wed, Dec 15 2021 at 18:30, info@engel-internet.de wrote:
> dT = (T_KS_asleep – T_US_asleep) + (T_US_awake – T_KS_awake) // T: point
> in time, KS: kernel space, US: user space
>
> With a simple user space program that prints out the monotonic time each
> 100ms along with the day time, I did some measurements on my notebook.
> It reveals the following discrepancies (time gaps) between the last time
> stamp written before suspend and the first time stamp after resume:
>
> dT in [s]     #1      #2      #3      #4      #5      #6      #7
>
> Suspend2RAM   6.409   6.423   7.451   3.444   7.815   5.655   7.178
>
> Suspend2Disk  5.228   2.683   5.072   5.198   4.806   5.763   6.908
>
> Is this effect known and accepted or is there some way to prevent or
> mitigate it?

there is not much the kernel can do about that.

Timekeeping can only stop at the very latest moment and has to resume
immediately when the CPU comes back. That's a matter of internal
correctness.

Yes, user space has to be frozen first in order to make that work and is
obviously unfrozen last. So the timeline looks like this:

T0        suspend is initiated
T1        user space freeze
T2        kernel shuts down    - timekeeping freeze
T3        kernel resumes       - timekeeping resume
T4        user space unfreeze

So the deltas T2 - T1, T4 - T3 are what matter for your user space
program. Those deltas heavily depend on the amount of drivers,
outstanding disk operations etc. So your milage will vary.

Thanks,

        tglx




      reply	other threads:[~2021-12-15 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 17:30 CLOCK_MONOTONIC after suspend info
2021-12-15 19:17 ` Thomas Gleixner [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=87o85hr82h.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=info@engel-internet.de \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox