[PATCH v4 2/8] bthread: add debug print for scheduler context switches

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jun 22 01:26:11 PDT 2021


When debugging around bthreads, it's often useful to log context
switches. Make this easier by adding a ready-to-use pr_debug at the
correct location.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/bthread.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/bthread.c b/common/bthread.c
index c811797130eb..80651344da64 100644
--- a/common/bthread.c
+++ b/common/bthread.c
@@ -163,7 +163,10 @@ void bthread_info(void)
 
 void bthread_reschedule(void)
 {
-	bthread_schedule(list_next_entry(current, list));
+	struct bthread *next = list_next_entry(current, list);
+	if (current != next)
+		pr_debug("switch %s -> %s\n", current->name, next->name);
+	bthread_schedule(next);
 }
 
 void bthread_schedule(struct bthread *to)
-- 
2.29.2




More information about the barebox mailing list