public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>, linux-block@vger.kernel.org
Cc: Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCH] bio: fix kmemleak false positives from percpu bio alloc cache
Date: Thu, 26 Mar 2026 07:29:10 -0600	[thread overview]
Message-ID: <c0c9becb-7ec7-4774-99f4-a265f53166e4@kernel.dk> (raw)
In-Reply-To: <20260324090052.1782766-1-ming.lei@redhat.com>

On 3/24/26 3:00 AM, Ming Lei wrote:
> When a bio is allocated from the mempool with REQ_ALLOC_CACHE set and
> later completed, bio_put() places it into the per-cpu bio_alloc_cache
> via bio_put_percpu_cache() instead of freeing it back to the
> mempool/slab. The slab allocation remains tracked by kmemleak, but the
> only reference to the bio is through the percpu cache's free_list,
> which kmemleak fails to trace through percpu memory. This causes
> kmemleak to report the cached bios as unreferenced objects.
> 
> Use symmetric kmemleak_free()/kmemleak_alloc() calls to properly track
> bios across percpu cache transitions:
> 
>  - bio_put_percpu_cache: call kmemleak_free() when a bio enters the
>    cache, unregistering it from kmemleak tracking.
> 
>  - bio_alloc_percpu_cache: call kmemleak_alloc() when a bio is taken
>    from the cache for reuse, re-registering it so that genuine leaks
>    of reused bios remain detectable.
> 
>  - __bio_alloc_cache_prune: call kmemleak_alloc() before bio_free() so
>    that kmem_cache_free()'s internal kmemleak_free() has a matching
>    allocation to pair with.

Looks fine to me, but can you please do it against for-7.1/block
instead? It's not a huge issue, and I'd rather not introduce a merge
conflict by shoving it into 7.0 if that can be avoided.

-- 
Jens Axboe

  reply	other threads:[~2026-03-26 13:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24  9:00 [PATCH] bio: fix kmemleak false positives from percpu bio alloc cache Ming Lei
2026-03-26 13:29 ` Jens Axboe [this message]
2026-03-26 13:45   ` Ming Lei

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=c0c9becb-7ec7-4774-99f4-a265f53166e4@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=yi.zhang@redhat.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