Re: [PATCH 7/7] selftests/proc: Remove idle time monotonicity assertions

From: Thomas Gleixner
Date: Mon Feb 20 2023 - 16:53:24 EST


On Mon, Feb 20 2023 at 13:41, Frederic Weisbecker wrote:

> Due to broken iowait task counting design (cf: comments above
> get_cpu_idle_time_us() and nr_iowait()), it is not possible to provide
> the guarantee that /proc/stat or /proc/uptime display monotonic idle
> time values.
>
> Remove the selftests that verify the related wrong assumption so that
> testers and maintainers don't spend more time on that.
>
> Reported-by: Yu Liao <liaoyu15@xxxxxxxxxx>
> Reported-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

I did really not ask you to remove the selftests alltogether.

Those tests check uptime and idle time. I asked you to remove the idle
time monotonicity assertion.

uptime is really supposed to be monotonically increasing. It's based on
CLOCK_BOOTTIME. If that goes backwards then we surely have more trouble
than /proc/uptime.

But it would be a good thing to change the test in the following way:

ut1 = parse("/proc/uptime");
bt1 = clock_gettime(CLOCK_BOOTTIME);
assert(ut1 <= bt1);
ut2 = parse("/proc/uptime");
bt2 = clock_gettime(CLOCK_BOOTTIME);
assert(ut2 <= bt2);
assert(ut1 <= ut2);
....

Hmm?

Thanks,

tglx