From: Samuel Wu <wusamuel@google.com>
To: John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Miroslav Lichvar <mlichvar@redhat.com>
Cc: linux-pm@vger.kernel.org, rafael@kernel.org,
Samuel Wu <wusamuel@google.com>,
kernel-team@android.com, linux-kernel@vger.kernel.org
Subject: [PATCH 0/4] alarmtimer: Reject suspend earlier when alarm is imminent
Date: Mon, 30 Nov 2026 22:13:04 -0800 [thread overview]
Message-ID: <20261201061304.2825419-6-wusamuel@google.com> (raw)
alarmtimer_suspend() aborts suspend with -EBUSY when the next alarm is
due in less than 2 seconds, and holds a wakeup source for a fixed 2
seconds. This is suboptimal:
- The check runs quite late in the suspend sequence. An abort means
kernel spent time doing work it now has to undo.
- The fixed 2 second timeout has no relation to the time at which the
alarm is due.
This patchseries addresses both problems:
- 1/4: Hold wakeup source with grace period (100ms) after alarm is due.
- 2/4: Move the lookup of soonest alarm into helper function
- 3/4: Add a PM notifier (earlier in suspend sequence) to do an imminent
alarm check. This is the same idea as [1], but without the sysfs node.
- 4/4: Add alarm check in resume path, to handle wakeups that are earlier
than the actual alarm, since RTC has up to 1s error compared to an
alarm on hrtimer
With patch 3, the time spent on a suspend attempt that is aborted by an
imminent alarm drops from:
- ~220 ms to ~20 ms on Pixel 9 (v7.3)
- ~90 ms to ~0.1 ms on Pixel Watch (v6.12)
With patch 4, aborted suspend attempts due to alarmtimer are noticeably
lower.
[1]: https://lore.kernel.org/lkml/20240214092902.1908443-1-pranavpp@google.com/
Samuel Wu (4):
alarmtimer: Bound wakeup source timeout on suspend abort
alarmtimer: Extract alarmtimer_get_next_delta() helper
alarmtimer: Reject imminent-alarm suspend in PM_SUSPEND_PREPARE
alarmtimer: Hold wakeup source on resume for imminent alarms
kernel/time/alarmtimer.c | 124 ++++++++++++++++++++++++++++++---------
1 file changed, 97 insertions(+), 27 deletions(-)
--
2.56.1.911.g883d8bcb20-goog
next reply other threads:[~2026-12-01 6:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 6:13 Samuel Wu [this message]
2026-12-01 6:13 ` [PATCH 1/4] alarmtimer: Bound wakeup source timeout on suspend abort Samuel Wu
2026-12-01 6:13 ` [PATCH 3/4] alarmtimer: Reject imminent-alarm suspend in PM_SUSPEND_PREPARE Samuel Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201061304.2825419-6-wusamuel@google.com \
--to=wusamuel@google.com \
--cc=jstultz@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mlichvar@redhat.com \
--cc=rafael@kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox