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 <sultan@kerneltoast.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
Sultan Alsawaf
2022-05-03 23:21:44 -07:00
committed by Pranav Vashi
parent aa82352a41
commit 691f53372e
2 changed files with 5 additions and 1 deletions

View File

@@ -801,6 +801,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;

View File

@@ -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)
{