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

From: Waiman Long
Date: Thu Feb 20 2025 - 08:15:41 EST



On 2/19/25 10:11 PM, Steven Rostedt wrote:
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.

:-/

Another alternative is to encode the locking type into the lowest 2 bits of the address and combined them into a single atomic_long_t data item. Of course, we can only support 4 different types with this scheme.

Cheers,
Longman


-- Steve