Re: [PATCH v4 1/2] hung_task: Show the blocker task if the task is hung on mutex

From: Google
Date: Thu Mar 13 2025 - 23:57:10 EST


On Thu, 13 Mar 2025 15:29:46 -0700
Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Tue, 25 Feb 2025 16:02:34 +0900 "Masami Hiramatsu (Google)" <mhiramat@xxxxxxxxxx> wrote:
>
> > From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> >
> > The "hung_task" shows a long-time uninterruptible slept task, but most
> > often, it's blocked on a mutex acquired by another task. Without
> > dumping such a task, investigating the root cause of the hung task
> > problem is very difficult.
> >
> > This introduce task_struct::blocker_mutex to point the mutex lock
> > which this task is waiting for. Since the mutex has "owner"
> > information, we can find the owner task and dump it with hung tasks.
> >
> > Note: the owner can be changed while dumping the owner task, so
> > this is "likely" the owner of the mutex.
> >
> > With this change, the hung task shows blocker task's info like below;
>
> Seems useful.
>
> > ...
> >
> > +static void debug_show_blocker(struct task_struct *task)
> > +{
> >
> > ...
> >
> > +}
> > +#else
> > +#define debug_show_blocker(t) do {} while (0)
> > +#endif
> > +
>
> Nit. It's unpleasing to have one side a C function and the other a
> macro. Plus C functions are simply better - only use a macro if one
> has to!

Ah, that's nice to know. Thanks for the fix!

>
> So,
>
> --- a/kernel/hung_task.c~hung_task-show-the-blocker-task-if-the-task-is-hung-on-mutex-fix
> +++ a/kernel/hung_task.c
> @@ -125,7 +125,9 @@ static void debug_show_blocker(struct ta
> }
> }
> #else
> -#define debug_show_blocker(t) do {} while (0)
> +static inline void debug_show_blocker(struct task_struct *task)
> +{
> +}
> #endif
>
> static void check_hung_task(struct task_struct *t, unsigned long timeout)
> _
>


--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>