From: Peter Zijlstra <peterz@infradead.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Boqun Feng <boqun.feng@gmail.com>,
Waiman Long <longman@redhat.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: Fri, 21 Feb 2025 19:59:39 +0100 [thread overview]
Message-ID: <20250221185939.GB7373@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <174014820133.967666.5855819828684207404.stgit@mhiramat.tok.corp.google.com>
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 { }
- that for_each_process_thread() loop needs RCU or tasklist_lock
- 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.
> + }
> + pr_err("INFO: task %s:%d is blocked on a mutex, but the owner is not found.\n",
> + task->comm, task->pid);
> +}
next prev parent reply other threads:[~2025-02-21 18:59 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 [this message]
2025-02-21 20:29 ` Waiman Long
2025-02-22 1:07 ` Masami Hiramatsu
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=20250221185939.GB7373@noisy.programming.kicks-ass.net \
--to=peterz@infradead.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=longman@redhat.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--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
all inboxes | Powered by JetHome®