From 017f3c6586bef8795adb9f3c9385daef77a2e3fe Mon Sep 17 00:00:00 2001 From: John Stultz Date: Tue, 9 Aug 2022 02:28:24 +0000 Subject: [PATCH] ANDROID: sched: Fix deadlock in sched_blocked_reason tracepoint The sched_blocked_reason tracepoint introduced in android common in commit 1f52bb8bfd30 ("ANDROID: trace: sched: add sched blocked tracepoint which dumps out context of sleep.") calls get_wchan(). Unfortunately, get_wchan() was reworked upstream in commit 42a20f86dc19 ("sched: Add wrapper for get_wchan() to keep task blocked"), such that it now takes the task pi_lock. This causes a deadlock, as we are already holding the pi_lock in try_to_wakeup() when we call trace_sched_blocked_reason(). This patch reworks the tracepoint so that it calls __get_wchan() which does not take the lock, avoiding the deadlock. Test: Manual: run perfetto with ftrace_events: "sched/sched_blocked_reason" in the config Fixes: 1f52bb8bfd30 ("ANDROID: trace: sched: add sched blocked tracepoint which dumps out context of sleep.") Signed-off-by: John Stultz Change-Id: I94e4251418d709a7b9292b3301c6cadd8fa3fb23 --- include/trace/events/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index fa8afbd7b343..cd969a6b61c0 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -504,7 +504,7 @@ TRACE_EVENT(sched_blocked_reason, TP_fast_assign( __entry->pid = tsk->pid; - __entry->caller = (void *)get_wchan(tsk); + __entry->caller = (void *)__get_wchan(tsk); __entry->io_wait = tsk->in_iowait; ),