Created
November 11, 2022 10:19
-
-
Save mschlumpp/a73c11ccf592cde6fc053ca8e455b809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 62a5e51c7c1bc3ff9d033b2eb15b35653a1ad9ce Mon Sep 17 00:00:00 2001 | |
From: Marco Schlumpp <marco@unikraft.io> | |
Date: Fri, 11 Nov 2022 11:16:46 +0100 | |
Subject: [PATCH] lib/ukschedcoop: Workaround for scheduler boot hang | |
Signed-off-by: Marco Schlumpp <marco@unikraft.io> | |
--- | |
lib/ukschedcoop/schedcoop.c | 10 +++++++++- | |
1 file changed, 9 insertions(+), 1 deletion(-) | |
diff --git a/lib/ukschedcoop/schedcoop.c b/lib/ukschedcoop/schedcoop.c | |
index 69e5622c..3843feab 100644 | |
--- a/lib/ukschedcoop/schedcoop.c | |
+++ b/lib/ukschedcoop/schedcoop.c | |
@@ -36,6 +36,7 @@ | |
#include <uk/sched.h> | |
#include <uk/schedcoop.h> | |
#include <uk/essentials.h> | |
+#include <uk/bitops.h> | |
struct schedcoop { | |
struct uk_sched sched; | |
@@ -173,10 +174,13 @@ static void schedcoop_thread_woken(struct uk_sched *s, struct uk_thread *t) | |
} | |
} | |
+extern unsigned long sched_have_pending_events; | |
+ | |
static __noreturn void idle_thread_fn(void *argp) | |
{ | |
struct schedcoop *c = (struct schedcoop *) argp; | |
__nsec now, wake_up_time; | |
+ unsigned long irqf; | |
UK_ASSERT(c); | |
@@ -193,7 +197,10 @@ static __noreturn void idle_thread_fn(void *argp) | |
wake_up_time = (volatile __nsec) c->idle_return_time; | |
now = ukplat_monotonic_clock(); | |
- if (wake_up_time > now) { | |
+ irqf = ukplat_lcpu_save_irqf(); | |
+ if (wake_up_time > now | |
+ && !__uk_test_and_clear_bit(0, | |
+ &sched_have_pending_events)) { | |
if (wake_up_time) | |
ukplat_lcpu_halt_to(wake_up_time); | |
else | |
@@ -202,6 +209,7 @@ static __noreturn void idle_thread_fn(void *argp) | |
/* handle pending events if any */ | |
ukplat_lcpu_irqs_handle_pending(); | |
} | |
+ ukplat_lcpu_restore_irqf(irqf); | |
/* try to schedule a thread that might now be available */ | |
schedcoop_schedule(&c->sched); | |
-- | |
2.38.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment