From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Waiman Long <llong@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Boqun Feng <boqun.feng@gmail.com>,
Joel Granados <joel.granados@kernel.org>,
Anna Schumaker <anna.schumaker@oracle.com>,
Lance Yang <ioworker0@gmail.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
Yongliang Gao <leonylgao@tencent.com>,
Steven Rostedt <rostedt@goodmis.org>,
Tomasz Figa <tfiga@chromium.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] hung_task: Show the blocker task if the task is hung on mutex
Date: Sat, 22 Feb 2025 10:07:16 +0900 [thread overview]
Message-ID: <20250222100716.23c55ef04d48d313211bef21@kernel.org> (raw)
In-Reply-To: <63fc7bff-168e-478b-a3fc-4897f2ee9d69@redhat.com>
On Fri, 21 Feb 2025 15:29:57 -0500
Waiman Long <llong@redhat.com> wrote:
>
> On 2/21/25 1:59 PM, Peter Zijlstra wrote:
> > On Fri, Feb 21, 2025 at 11:30:01PM +0900, Masami Hiramatsu (Google) wrote:
> >> +static void debug_show_blocker(struct task_struct *task)
> >> +{
> >> + struct task_struct *g, *t;
> >> + unsigned long owner;
> >> + struct mutex *lock;
> >> +
> >> + lock = READ_ONCE(task->blocker_mutex);
> >> + if (!lock)
> >> + return;
> >> +
> >> + owner = mutex_get_owner(lock);
> >> + if (likely(owner)) {
> >> + /* Ensure the owner information is correct. */
> >> + for_each_process_thread(g, t)
> >> + if ((unsigned long)t == owner) {
> >> + pr_err("INFO: task %s:%d is blocked on a mutex owned by task %s:%d.\n",
> >> + task->comm, task->pid, t->comm, t->pid);
> >> + sched_show_task(t);
> >> + return;
> >> + }
> > - that for_each_process_thread() scope needs { }
OK, let me add it.
> >
> > - that for_each_process_thread() loop needs RCU or tasklist_lock
>
> The call chain should be
>
> check_hung_uninterruptible_tasks()
> -> check_hung_task()
> -> debug_show_blocker()
>
> check_hung_uninterruptible_tasks() takes rcu_read_lock() before calling
> check_hung_task(). Perhaps add a statement like
>
> RCU_LOCKDEP_WARN(!rcu_read_lock_held(), "no rcu lock held");
Agreed. It needs to add assertion.
>
> >
> > - there is no saying that the owner you read with mutex_get_owner() is
> > still the owner by the time you do the compare, there can have been
> > owner changes.
>
> Maybe change "owned by" to "likely owned by" :-)
Indeed :-)
Thank you!
>
> Cheers,
> Longman
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2025-02-22 1:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 14:29 [PATCH v2 0/2] hung_task: Dump the blocking task stacktrace Masami Hiramatsu (Google)
2025-02-21 14:30 ` [PATCH v2 1/2] hung_task: Show the blocker task if the task is hung on mutex Masami Hiramatsu (Google)
2025-02-21 18:59 ` Peter Zijlstra
2025-02-21 20:29 ` Waiman Long
2025-02-22 1:07 ` Masami Hiramatsu [this message]
2025-02-21 14:30 ` [PATCH v2 2/2] samples: Add hung_task detector mutex blocking sample Masami Hiramatsu (Google)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250222100716.23c55ef04d48d313211bef21@kernel.org \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anna.schumaker@oracle.com \
--cc=boqun.feng@gmail.com \
--cc=ioworker0@gmail.com \
--cc=joel.granados@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=leonylgao@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llong@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tfiga@chromium.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox