Re: [PATCH 1/2] hung_task: Show the blocker task if the task is hung on mutex
From: Google
Date: Wed Feb 19 2025 - 21:40:48 EST
On Wed, 19 Feb 2025 20:41:53 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> On Wed, 19 Feb 2025 20:36:13 -0500
> Waiman Long <llong@xxxxxxxxxx> wrote:
>
>
> > >>>> this field, we don't need to take lock, though taking the wait_lock may
> > >>>> still be needed to examine other information inside the mutex.
> > > Do we need to take it just for accessing owner, which is in an atomic?
> >
> > Right. I forgot it is an atomic_long_t. In that case, no lock should be
> > needed.
>
> Now if we have a two fields to read:
>
> block_flags (for the type of lock) and blocked_on (for the lock)
>
> We need a way to synchronize the two. What happens if we read the type, and
> the task wakes up and and then blocks on a different type of lock?
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)
Thank you,
>
> Then the lock read from blocked_on could be a different type of lock than
> what is expected.
>
> -- Steve
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>