Re: Missing CLOCK_BOOTTIME_RAW?

From: Thomas Gleixner
Date: Mon May 18 2020 - 09:01:29 EST


Pali RohÃr <pali@xxxxxxxxxx> writes:
> On Monday 18 May 2020 14:13:48 Thomas Gleixner wrote:
>> Of course not, but the kernel relies on that application behaving
>> sanely. If it does not then the time stamps you are complaining about
>> are the least of your worries.
>
> I do not thing it is too bad... When I needed to deal in userspace with
> time/date/clock I just needed either "current time in UTC" to show it to
> user (possible in different timezone and pretty formatted) or I needed
> "timestamp since some epoch" suitable for measuring time differences.
>
> For first case I used CLOCK_REALTIME and for second case I used
> CLOCK_MONOTONIC_RAW (as it was not affected by adjtime()).
>
> And I would like to know, it is correct to use these two clocks in those
> situations?

It's your choice to do so. I prefer CLOCK_MONOTONIC simply because it's
in human understandable units and not some assumed frequency.

> Anyway, what would happen with CLOCK_BOOTTIME when during suspend is
> that external RTC source shifted back? Is kernel guarantee that
> CLOCK_BOOTTIME is always monotonic even in this case?

If the RTC delta is negative, then it's ignored, i.e. 0 sleep time
injected.

Thanks,

tglx