Skip to content

Instantly share code, notes, and snippets.

@ElishaAz
Created August 18, 2024 11:04
Show Gist options
  • Select an option

  • Save ElishaAz/24b71cb72ff6d52cba5118a4681f64da to your computer and use it in GitHub Desktop.

Select an option

Save ElishaAz/24b71cb72ff6d52cba5118a4681f64da to your computer and use it in GitHub Desktop.
Bedrock Linux suspend kernel patch
diff -ura linux-6.9.7/kernel/power/process.c linux-6.9.7.new/kernel/power/process.c
--- linux-6.9.7/kernel/power/process.c 2024-07-18 14:51:49.353039741 +0300
+++ linux-6.9.7.new/kernel/power/process.c 2024-07-18 14:56:47.393032621 +0300
@@ -23,7 +23,7 @@
/*
* Timeout for stopping processes
*/
-unsigned int __read_mostly freeze_timeout_msecs = 20 * MSEC_PER_SEC;
+unsigned int __read_mostly freeze_timeout_msecs = 5 * MSEC_PER_SEC;
static int try_to_freeze_tasks(bool user_only)
{
@@ -31,7 +31,8 @@
"remaining freezable tasks";
struct task_struct *g, *p;
unsigned long end_time;
- unsigned int todo;
+ unsigned int todo, etcfs;
+ bool freeze_etcfs = false;
bool wq_busy = false;
ktime_t start, end, elapsed;
unsigned int elapsed_msecs;
@@ -49,8 +50,15 @@
while (true) {
todo = 0;
+ etcfs = 0;
read_lock(&tasklist_lock);
for_each_process_thread(g, p) {
+ if (!freeze_etcfs
+ && strcmp((const char*)p->comm, "etcfs") == 0) {
+ etcfs++;
+ continue;
+ }
+
if (p == current || !freeze_task(p))
continue;
@@ -63,7 +71,7 @@
todo += wq_busy;
}
- if (!todo || time_after(jiffies, end_time))
+ if ((!todo && !etcfs) || time_after(jiffies, end_time))
break;
if (pm_wakeup_pending()) {
@@ -71,6 +79,9 @@
break;
}
+ if (!todo)
+ freeze_etcfs = true;
+
/*
* We need to retry, but first give the freezing tasks some
* time to enter the refrigerator. Start with an initial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment