From c09e657655ec7149bbf9327f578a6256a071e4f2 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Tue, 3 May 2022 23:21:44 -0700 Subject: [PATCH] PM / freezer: Reduce freeze timeout to 1 second for Android Freezing processes on Android usually takes less than 100 ms, and if it takes longer than that to the point where the 20 second freeze timeout is reached, it's because the remaining processes to be frozen are deadlocked waiting for something from a process which is already frozen. There's no point in burning power trying to freeze for that long, so reduce the freeze timeout to a very generous 1 second for Android and don't let anything mess with it. Signed-off-by: Sultan Alsawaf --- kernel/power/main.c | 3 +++ kernel/power/process.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/power/main.c b/kernel/power/main.c index 641255b47d52..e80b947848e5 100755 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -984,6 +984,9 @@ static ssize_t pm_freeze_timeout_store(struct kobject *kobj, { unsigned long val; + if (IS_ENABLED(CONFIG_ANDROID)) + return n; + if (kstrtoul(buf, 10, &val)) return -EINVAL; diff --git a/kernel/power/process.c b/kernel/power/process.c index 1ae7f93efde9..3c697433dc0a 100755 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -27,7 +27,8 @@ /* * Timeout for stopping processes */ -unsigned int __read_mostly freeze_timeout_msecs = 20 * MSEC_PER_SEC; +unsigned int __read_mostly freeze_timeout_msecs = + IS_ENABLED(CONFIG_ANDROID) ? MSEC_PER_SEC : 20 * MSEC_PER_SEC; static int try_to_freeze_tasks(bool user_only) {