All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Waiman Long <llong@redhat.com>
Cc: Gu Bowen <gubowen5@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, linux-mm@kvack.org,
	Breno Leitao <leitao@debian.org>,
	John Ogness <john.ogness@linutronix.de>,
	Lu Jialin <lujialin4@huawei.com>
Subject: Re: [PATCH v4] mm: Fix possible deadlock in kmemleak
Date: Wed, 20 Aug 2025 12:02:33 +0100	[thread overview]
Message-ID: <aKWrSfLD5f1r5rg_@arm.com> (raw)
In-Reply-To: <113a8332-b35c-4d00-b8b1-21c07d133f1f@redhat.com>

On Tue, Aug 19, 2025 at 11:27:23PM -0400, Waiman Long wrote:
> On 8/18/25 5:09 AM, Gu Bowen wrote:
> > @@ -858,8 +870,14 @@ static void delete_object_part(unsigned long ptr, size_t size,
> >   	object = __find_and_remove_object(ptr, 1, objflags);
> >   	if (!object) {
> >   #ifdef DEBUG
> > +		/*
> > +		 * Printk deferring due to the kmemleak_lock held.
> > +		 * This is done to avoid deadlock.
> > +		 */
> > +		printk_deferred_enter();
> >   		kmemleak_warn("Partially freeing unknown object at 0x%08lx (size %zu)\n",
> >   			      ptr, size);
> > +		printk_deferred_exit();
> >   #endif
> 
> This particular warning message can be moved after unlock by adding a
> warning flag. Locking is done outside of the other two helper functions
> above, so it is easier to use printk_deferred_enter/exit() for those.

I thought about this as well but the above is under an #ifdef DEBUG so
we end up adding more lines on the unlock path (not sure which one looks
better; I'd say the above, marginally).

Another option would be to remove the #ifdef and try to identify the
call sites that trigger the warning. Last time I checked (many years
ago) they were fairly benign and decided to hide them before an #ifdef.

-- 
Catalin


  reply	other threads:[~2025-08-20 11:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-18  9:09 [PATCH v4] mm: Fix possible deadlock in kmemleak Gu Bowen
2025-08-18  8:59 ` kernel test robot
2025-08-19 15:30 ` Catalin Marinas
2025-08-19 22:49   ` Andrew Morton
2025-08-20  1:23   ` Gu Bowen
2025-08-20  3:27 ` Waiman Long
2025-08-20 11:02   ` Catalin Marinas [this message]
2025-08-20 15:01     ` Waiman Long
2025-08-20 17:00       ` Catalin Marinas
2025-08-21 11:45         ` Gu Bowen

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=aKWrSfLD5f1r5rg_@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gubowen5@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.