From: Gu Bowen <gubowen5@huawei.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
<stable@vger.kernel.org>, <linux-mm@kvack.org>,
Waiman Long <llong@redhat.com>, Breno Leitao <leitao@debian.org>,
John Ogness <john.ogness@linutronix.de>,
Lu Jialin <lujialin4@huawei.com>
Subject: Re: [PATCH v2] mm: Fix possible deadlock in console_trylock_spinning
Date: Fri, 8 Aug 2025 08:56:25 +0800 [thread overview]
Message-ID: <eacf887c-7259-4827-8bdb-8a938f01dc0c@huawei.com> (raw)
In-Reply-To: <aJTCGrkg69Ytg-CC@arm.com>
On 8/7/2025 11:11 PM, Catalin Marinas wrote:
>
>> @@ -433,8 +439,15 @@ static struct kmemleak_object *mem_pool_alloc(gfp_t gfp)
>> list_del(&object->object_list);
>> else if (mem_pool_free_count)
>> object = &mem_pool[--mem_pool_free_count];
>> - else
>> + else {
>> + /*
>> + * Printk deferring due to the kmemleak_lock held.
>> + * This is done to avoid deadlock.
>> + */
>> + printk_deferred_enter();
>> pr_warn_once("Memory pool empty, consider increasing CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE\n");
>> + printk_deferred_exit();
>> + }
>> raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
>
> I wouldn't bother with printk deferring here, just set a bool warn
> variable and report it after unlocking. We recently merged another patch
> that does this.
>
That's fine, I will send another patch that does not include this part.
>>
>> return object;
>> @@ -632,6 +645,11 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,
>> else if (parent->pointer + parent->size <= ptr)
>> link = &parent->rb_node.rb_right;
>> else {
>> + /*
>> + * Printk deferring due to the kmemleak_lock held.
>> + * This is done to avoid deadlock.
>> + */
>> + printk_deferred_enter();
>> kmemleak_stop("Cannot insert 0x%lx into the object search tree (overlaps existing)\n",
>> ptr);
>> /*
>> @@ -639,6 +657,7 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,
>> * be freed while the kmemleak_lock is held.
>> */
>> dump_object_info(parent);
>> + printk_deferred_exit();
>
> This is part of __link_object(), called with the lock held, so easier to
> defer the printing as above.
>
> BTW, the function names in the diff don't match mainline. Which kernel
> version is this patch based on?
>
The kernel version of this patch is stable-5.10. This part of the code
exists in function __link_object() in the mainline.
prev parent reply other threads:[~2025-08-08 0:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 9:14 Gu Bowen
2025-08-07 15:11 ` Catalin Marinas
2025-08-08 0:56 ` Gu Bowen [this message]
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=eacf887c-7259-4827-8bdb-8a938f01dc0c@huawei.com \
--to=gubowen5@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=john.ogness@linutronix.de \
--cc=leitao@debian.org \
--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