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>
This commit is contained in:
Sultan Alsawaf 2022-05-03 23:21:44 -07:00 committed by Ksawlii
parent 5d3ff5040f
commit 2e3484e48b
2 changed files with 5 additions and 1 deletions

View file

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

@ -29,7 +29,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)
{