From: Andrew Morton <akpm@linux-foundation.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Breno Leitao <leitao@debian.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
vlad.wing@gmail.com, harry@kernel.org, kernel-team@meta.com
Subject: Re: [PATCH] mm: kmemleak: drop kmemleak_lock in scan_block() when it is contended
Date: Thu, 12 Nov 2026 17:46:38 -0800 [thread overview]
Message-ID: <20261112174638.d467922035f9adeabc04589b@linux-foundation.org> (raw)
In-Reply-To: <avXgd-aE8QazfR1G@arm.com>
On Thu, 12 Nov 2026 15:51:19 +0000 Catalin Marinas <catalin.marinas@arm.com> wrote:
> On Thu, Nov 12, 2026 at 03:48:01AM -0800, Breno Leitao wrote:
> > kernel_lock is a damn hot lock, used on allocations, free, NET_RX, etc.
>
> Nit: s/kernel_lock/kmemleak_lock/
aww man, I had flashbacks.
Then came along
https://github.com/torvalds/linux/commit/4ba8216cd90560bc402f52076f64d8546e8aefcb
things were so much simpler in those days.
> > It is also used on the scan, so, while scanning, most of the system is
> > mostly waiting for the lock.
> >
> > On meta fleet, this is, by far, the most contented lock. This is not
> > a big deal, because very few hosts run with kmemleak enabled, but,
> > I think we can do better here.
> >
> > scan_block() takes kmemleak_lock once per block and keeps it, with
> > interrupts disabled, for up to MAX_SCAN_SIZE bytes: 512 words, each
> > needing up to two object tree lookups. Every allocation and free in the
> > system needs the same lock to insert or remove its object, so each of
> > them can wait for a whole block.
> >
> > Keep taking the lock once per block, but in auto scan mode, check every
> > 64 words whether anybody is waiting for it and, if so, breathe (aka
> > release it and take it again so that the waiters go first)
> >
> > Releasing the lock is seems safe because it only keeps the object trees
>
> Nit: s/is//
De-nitted and grabbed, thanks.
prev parent reply other threads:[~2026-11-13 1:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 11:48 Breno Leitao
2026-11-12 15:51 ` Catalin Marinas
2026-11-13 1:46 ` Andrew Morton [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=20261112174638.d467922035f9adeabc04589b@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=harry@kernel.org \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vlad.wing@gmail.com \
/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®