From: Breno Leitao <leitao@debian.org>
To: Gu Bowen <gubowen5@huawei.com>, catalin.marinas@arm.com
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Waiman Long <llong@redhat.com>,
stable@vger.kernel.org, linux-mm@kvack.org,
John Ogness <john.ogness@linutronix.de>,
Lu Jialin <lujialin4@huawei.com>
Subject: Re: [PATCH v5] mm: Fix possible deadlock in kmemleak
Date: Fri, 19 Sep 2025 03:37:27 -0700 [thread overview]
Message-ID: <5ohuscufoavyezhy6n5blotk4hovyd2e23pfqylrfwhpu45nby@jxwe6jmkwdzb> (raw)
In-Reply-To: <20250822073541.1886469-1-gubowen5@huawei.com>
On Fri, Aug 22, 2025 at 03:35:41PM +0800, Gu Bowen wrote:
> To solve this problem, switch to printk_safe mode before printing warning
> message, this will redirect all printk()-s to a special per-CPU buffer,
> which will be flushed later from a safe context (irq work), and this
> deadlock problem can be avoided.
I am still thinking about this problem, given I got another deadlock
issue that I was not able to debug further given I do not have the
crashdump.
Should we have a wrapper around raw_spin_lock_irqsave(kmemleak_lock,
flags), that would defer printk at all?
Then, we can simply replace the raw_spin_lock_irqsave() by the helper,
avoiding spreading these printk_deferred_enter() in the kmemleak code.
For instance, something as this completely untested code, just to show
the idea.
void kmemleak_lock(unsigned long *flags) {
printk_deferred_enter();
raw_spin_lock_irqsave(&kmemleak_lock, flags);
}
void kmemleak_lock(unsigned long flags) {
raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
printk_deferred_exit();
}
next prev parent reply other threads:[~2025-09-19 10:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 7:35 Gu Bowen
2025-08-26 8:23 ` Breno Leitao
2025-08-26 19:37 ` Catalin Marinas
2025-08-26 23:23 ` Waiman Long
2025-09-19 10:37 ` Breno Leitao [this message]
2025-09-25 14:33 ` Catalin Marinas
2025-09-26 14:57 ` Breno Leitao
2025-09-29 14:07 ` John Ogness
2025-09-29 14:40 ` Breno Leitao
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=5ohuscufoavyezhy6n5blotk4hovyd2e23pfqylrfwhpu45nby@jxwe6jmkwdzb \
--to=leitao@debian.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=gubowen5@huawei.com \
--cc=john.ogness@linutronix.de \
--cc=linux-mm@kvack.org \
--cc=llong@redhat.com \
--cc=lujialin4@huawei.com \
--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