[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0jtYE+yp57t60szEbtzFVc-kbeMcxAiWuYc-cf1q2HxMA@mail.gmail.com>
Date: Thu, 2 Mar 2023 15:54:16 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: John Stultz <jstultz@...gle.com>,
Michael Nazzareno Trimarchi <michael@...rulasolutions.com>,
LKML <linux-kernel@...r.kernel.org>,
Stephen Boyd <sboyd@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Michael <michael@...isi.de>, kernel-team@...roid.com,
Peter Zijlstra <peterz@...radead.org>,
"Rafael J. Wysocki" <rafael@...nel.org>
Subject: Re: [RFC][PATCH 2/2] time: alarmtimer: Use TASK_FREEZABLE to cleanup
freezer handling
On Wed, Mar 1, 2023 at 11:11 PM Thomas Gleixner <tglx@...utronix.de> wrote:
>
> On Mon, Feb 27 2023 at 20:06, John Stultz wrote:
> > On Mon, Feb 27, 2023 at 4:03 PM John Stultz <jstultz@...gle.com> wrote:
> >> > On Mon, Feb 20 2023 at 19:11, Michael Nazzareno Trimarchi wrote:
> >> > +static int alarmtimer_pm_notifier_fn(struct notifier_block *bl, unsigned long state,
> >> > + void *unused)
> >> > +{
> >> > + switch (state) {
> >> > + case PM_HIBERNATION_PREPARE:
> >> > + case PM_POST_HIBERNATION:
> >> > + atomic_set(&alarmtimer_wakeup, 0);
> >> > + break;
> >> > + }
> >> > + return NOTIFY_DONE;
> >>
> >> But here, we're setting the alarmtimer_wakeup count to zero if we get
> >> PM_HIBERNATION_PREPARE or PM_POST_HIBERNATION notifications?
> >> And Michael noted we need to add PM_SUSPEND_PREPARE and
> >> PM_POST_SUSPEND there for this to seemingly work.
>
> Yup. I missed those when sending out that hack.
>
> > So Thomas's notifier method of zeroing at the begining of suspend and
> > tracking any wakeups after that point makes more sense now. It still
> > feels a bit messy, but I'm not sure there's something better.
>
> I'm not enthused about it either.
>
> > My only thought is this feels a little bit like its mirroring what the
> > pm_wakeup_event() logic is supposed to do. Should we be adding a
> > pm_wakeup_event() to alarmtimer_fired() to try to prevent suspend from
> > occuring for 500ms or so after an alarmtimer has fired so there is
> > enough time for it to be re-armed if needed?
>
> The question is whether this can be called unconditionally and how that
> interacts with the suspend logic. Rafael?
The pm_wakeup_event() doesn't need the timeout, but it is conditional
on using /sys/power/wakeup_count.
However, in any case it doesn't guarantee that the target user of the
alarm timer will be able to handle the signal on time AFAICS. To my
eyes, it is entirely possible for alarmtimer_fired() to run before
/sys/power/wakeup_count is written to while the signal will be sent to
the given task later, in which case there is no guarantee that the
task will not be frozen in the meantime.
Moreover, I'm wondering if all alarm timers should always wake up the
system from sleep or abort suspends in progress? If the answer is
"no" here, it changes the problem at hand quite a bit.
Powered by blists - more mailing lists