2023-10-24 18:07:48

by Kalesh Singh

[permalink] [raw]
Subject: [PATCH] PM/sleep: Instrument start of filesystems sync

Systems, such as Android, that implement opportunistic sleep from
a userspace power manager service need to guard the acquisition of
new wakelocks (incrementing a counter in userspace) while attempting
a suspend (write to /sys/power/state).

While attempting to suspend, processes attempting to acquire a
userspace wakelock are also blocked. If the suspend is blocked for
too long it can cause a watchdog bite in android.

Some device vendors reported this issue in cases where the filesystem
sync is not fast enough (sometimes > 100s):

[ 2742.247785] [07-10 15:08:02.247] Filesystems sync: 107.127 seconds

Commit b5dee3130bb4 ("PM / sleep: Refactor filesystems sync to reduce
duplication") introduced ksys_sync_helper() which logged both the start
and end of the filesystems sync.

Commit c64546b17bc9 ("PM / sleep: Measure the time of filesystems syncing")
improved on this by adding the elapsed time, but also removed instrumentation
indicating the start of filesystems sync.

Re-add the log indicating the start of filesystem sync. This helps to
identify when the above scenario has occurred in production devices in
the field.

Cc: Rafael J. Wysocki <[email protected]>
Cc: Harry Pan <[email protected]>
Signed-off-by: Kalesh Singh <[email protected]>
---
kernel/power/main.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index f6425ae3e8b0..b6a88b43b6da 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -87,6 +87,7 @@ void ksys_sync_helper(void)
ktime_t start;
long elapsed_msecs;

+ pr_info("Syncing filesystems ... ");
start = ktime_get();
ksys_sync();
elapsed_msecs = ktime_to_ms(ktime_sub(ktime_get(), start));

base-commit: 05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1
--
2.42.0.758.gaed0368e0e-goog