Re: [PATCH v4 1/3] hung_task: replace blocker_mutex with encoded blocker

From: Lance Yang
Date: Tue Apr 08 2025 - 08:38:13 EST


On Tue, Apr 8, 2025 at 4:08 AM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Thu, 20 Mar 2025 14:49:21 +0800 Lance Yang <ioworker0@xxxxxxxxx> wrote:
>
> > This patch replaces 'struct mutex *blocker_mutex' with 'unsigned long
> > blocker', as only one blocker is active at a time.
> >
> > The blocker filed can store both the lock addrees and the lock type, with
> > LSB used to encode the type as Masami suggested, making it easier to extend
> > the feature to cover other types of locks.
> >
> > Also, once the lock type is determined, we can directly extract the address
> > and cast it to a lock pointer ;)
> >
> > ...
> >
> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -1218,7 +1218,7 @@ struct task_struct {
> > #endif
> >
> > #ifdef CONFIG_DETECT_HUNG_TASK_BLOCKER
> > - struct mutex *blocker_mutex;
> > + unsigned long blocker;
>
> -ENOCOMMENT
>

Got it. Does the following change make sense and is it clear?

diff --git a/include/linux/sched.h b/include/linux/sched.h
index f27060dac499..27dad9aa99a0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1218,6 +1218,10 @@ struct task_struct {
#endif

#ifdef CONFIG_DETECT_HUNG_TASK_BLOCKER
+ /*
+ * Encoded lock address causing task block (lower 2 bits = type from
+ * <linux/hung_task.h>). Accessed via hung_task_*() helpers.
+ */
unsigned long blocker;
#endif
---

Thanks,
Lance