From: Oleg Nesterov <oleg@redhat.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Breno Leitao <leitao@debian.org>,
Andrew Morton <akpm@linux-foundation.org>,
lance.yang@linux.dev, Davidlohr Bueso <dave@stgolabs.net>,
Qian Cai <cai@lca.pw>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, stable@vger.kernel.org
Subject: Re: [PATCH v2] mm/kmemleak: avoid soft lockup when scanning task stacks
Date: Mon, 15 Jun 2026 20:18:26 +0200 [thread overview]
Message-ID: <ajBB8oXVOBd0NO6F@redhat.com> (raw)
In-Reply-To: <ajAWzSN_dgD9K_FY@arm.com>
On 06/15, Catalin Marinas wrote:
>
> On Mon, Jun 15, 2026 at 02:29:45PM +0200, Oleg Nesterov wrote:
> > On 06/12, Catalin Marinas wrote:
> > >
> > > if (kmemleak_stack_scan) {
> > > struct pid *pid;
> > > int nr = 1;
> > >
> > > do {
> > > struct task_struct *p = NULL;
> > >
> > > rcu_read_lock();
> > > pid = find_ge_pid(nr, &init_pid_ns);
> > > if (pid) {
> > > nr = pid_nr(pid) + 1;
> > > p = pid_task(pid, PIDTYPE_PID);
> > > if (p)
> > > get_task_struct(p);
> > > }
> > > rcu_read_unlock();
> >
> > I don't think we need get_task_struct(p), the code above can just do
> >
> > if (p)
> > stack = try_get_task_stack(p);
>
> I think we still need the task_struct around. It depends on whether
> CONFIG_THREAD_INFO_IN_TASK is set but even when it is, the refcount is
> still in task_struct and task->stack_refcount does not prevent freeing
> of the task_struct. Then we have the !CONFIG_THREAD_INFO_IN_TASK where
> try_get_task_stack() does not touch any refcount.
Indeed. Thanks for correcting me.
Oleg.
next prev parent reply other threads:[~2026-06-15 18:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 15:16 [PATCH v2] mm/kmemleak: avoid soft lockup when scanning task stacks Breno Leitao
2026-06-12 16:52 ` Lance Yang
2026-06-12 17:11 ` Catalin Marinas
2026-06-15 9:27 ` Breno Leitao
2026-06-15 11:15 ` Catalin Marinas
2026-06-15 12:29 ` Oleg Nesterov
2026-06-15 15:14 ` Catalin Marinas
2026-06-15 18:18 ` Oleg Nesterov [this message]
2026-06-13 0:53 ` SeongJae Park
2026-06-13 10:45 ` Oleg Nesterov
2026-06-13 11:42 ` Lance Yang
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=ajBB8oXVOBd0NO6F@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cai@lca.pw \
--cc=catalin.marinas@arm.com \
--cc=dave@stgolabs.net \
--cc=kernel-team@meta.com \
--cc=lance.yang@linux.dev \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.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