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

From: Steven Rostedt
Date: Wed Feb 19 2025 - 22:12:41 EST


On Thu, 20 Feb 2025 11:40:36 +0900
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:

> Hmm, right.
> Since the blocked_on must be NULL before setting flag, if we can ensure
> the writing order so that blocked_flags is always updated before
> blocked_on, may it be safe?
>
> Or, (this may introduce more memory overhead) don't use union but
> use different blocked_on_mutex, blocked_on_rwsem, etc.
>
> Another idea is to make the owner offset same, like introducing
>
> struct common_lock {
> atomic_long_t owner;
> };
>
> But the problem is that rt_mutex does not use atomic for storing
> the owner. (we can make it atomic using wrapper)

Either that, or add to the task_struct:

struct mutex *blocked_on_mutex;
struct rwsem *blocked_on_rwsem;
struct rtlock *blocked_on_rtlock;

And just have each type assign to its own type. Then you only need to look
at each one. But yeah, this adds even more bloat to task_struct.

:-/

-- Steve