ANDROID: sched: Fix deadlock in sched_blocked_reason tracepoint

The sched_blocked_reason tracepoint introduced in android common
in commit 1f52bb8bfd ("ANDROID: trace: sched: add sched
blocked tracepoint which dumps out context of sleep.") calls
get_wchan().

Unfortunately, get_wchan() was reworked upstream in commit
42a20f86dc ("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: 1f52bb8bfd ("ANDROID: trace: sched: add sched blocked tracepoint which dumps out context of sleep.")
Signed-off-by: John Stultz <jstultz@google.com>
Change-Id: I94e4251418d709a7b9292b3301c6cadd8fa3fb23
This commit is contained in:
John Stultz
2022-08-09 02:28:24 +00:00
committed by Saravana Kannan
parent 2c74e83fc1
commit 017f3c6586

View File

@@ -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;
),