Re: [PATCH] alarmtimer: Expose information about next alarm to userspace via sysfs

From: Thomas Gleixner
Date: Fri Jan 19 2024 - 14:39:16 EST


On Thu, Jan 18 2024 at 14:11, John Stultz wrote:
> I'm always a bit cautious when exposing stuff to userland,
> particularly if it's potentially racy as you mentioned in your
> description. One thought I had was might adding a similar check
> earlier in the suspend path on the kernel side provide similar benefit
> (without requiring userland changes)?
>
> Basically, if I understand the problem:
> echo mem > /sys/power/state
> <kernel goes through suspending everything>
> alarmtimer_suspend()
> if (next_alarm < TWO_SECONDS)
> return -EBUSY;
> <kernel has to resume everything, and all that time was wasted>
>
> So if instead we did:
> echo mem > /sys/power/state
> enter_state()
> if (alarmtimer_immenent())
> retrun -EBUSY
>
> So the kernel would come back much faster if the suspend was going to abort.
>
> I suspect you all have considered this already but wanted to
> understand what issues that approach has.

It has the same race issues as the user space readout has as far as I
understand and it's much simpler.

Thanks,

tglx