[PATCH v3] um: simplify os_idle_sleep() and sleep longer
Johannes Berg
johannes at sipsolutions.net
Mon Nov 23 13:08:42 EST 2020
On Mon, 2020-11-23 at 14:57 +0100, Johannes Berg wrote:
>
> -void time_travel_sleep(unsigned long long duration)
> +void time_travel_sleep(void)
> {
> + unsigned long long duration = NSEC_PER_SEC * 120;
> unsigned long long next = time_travel_time + duration;
>
> if (time_travel_mode == TT_MODE_BASIC)
> os_timer_disable();
>
> + /*
> + * In external mode, just tell the external controller we'll
> + * (essentially) wait "forever" (S64_MAX because there are
> + * some potential wrapping issues.)
> + */
> + if (time_travel_mode == TT_MODE_EXTERNAL)
> + next = S64_MAX;
Ahrg. That was stupid. I should just make that S64_MAX the default, and
probably in fact crash later if we ever reach that point ...
Otherwise now my suspend/resume only ever suspends for exactly 2
minutes, since the later event added by the fake RTC is, well, later.
I'd either have to loop here, or just start with a later time to start
with.
And really there's no reason _not_ to start with a later time. In a
normally operating system, this is always the fallback, since another
event has been added to the list already to wake up for e.g. the next
10ms (HZ=100) timer.
If you _actually_ hit this, your system is misconfigured in some way, or
you can't actually get it back out of this state anyway since it'd sleep
for millenia (if you had done this in a real system), so crashing on it
seems completely fine. I don't foresee anyone really wanting to test a
few thousand years.
So ... I guess I'll just resent v4 that makes it sleep forever, and
perhaps adds a "you did something stupid so I'll just crash" to when you
suspend without ever having anything to resume from (in time-travel
only, of course.)
johannes
More information about the linux-um
mailing list