From: Eric Biggers <ebiggers@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-block@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Vlastimil Babka <vbabka@kernel.org>, Harry Yoo <harry@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>
Subject: Re: [PATCH 2/3] mm: support fallible mempool_alloc_bulk()
Date: Mon, 10 Aug 2026 18:22:15 +0000 [thread overview]
Message-ID: <20260810182215.GA270444@google.com> (raw)
In-Reply-To: <anoIiy0V-m-05yZc@infradead.org>
On Mon, Aug 10, 2026 at 10:21:15AM -0700, Christoph Hellwig wrote:
> On Mon, Aug 10, 2026 at 09:14:04AM -0700, Eric Biggers wrote:
> > On Mon, Aug 10, 2026 at 09:00:11AM -0700, Christoph Hellwig wrote:
> > > On Thu, Aug 06, 2026 at 03:10:30PM -0700, Eric Biggers wrote:
> > > > To fix a deadlock, blk-crypto-fallback needs to be able to make fallible
> > > > mempool_alloc_bulk() allocations.
> > >
> > > It doesn't. fallible mempool allocations are a concept that doesn't
> > > make much sense. Please just go straight to the backing page allocator
> > > instead for callers that do not need the mempool guarantees.
> >
> > It does make sense. When alloc_pages_bulk() doesn't completely succeed,
> > there still might be pages available in the mempool.
>
> But they should not go to a caller that does not need the mempool.
The caller does need the mempool.
> > blk_crypto_alloc_enc_bio() should try to take them before falling back
> > to scheduling the rescuer kworker. The rescuer encounters scheduling
> > overhead and is single-threaded, so it's slow and should be used only
> > when absolutely necessary.
>
> No, it should just try a regular non-bulk alloc_pages (and eventually
> alloc_pages_bulk should do that fallback for the callers, but that's
> a separate discussion).
It already does that. blk_crypto_alloc_enc_bio() first calls
alloc_pages_bulk(). If it doesn't completely succeed, it calls
mempool_alloc_bulk() to get the rest. That itself tries regular
allocations again before actually using the mempool. It needs a
guaranteed allocation, so it needs the mempool.
Now, as I explained in this patchset, whether this code can wait forever
for the mempool actually depends on whether it's a recursive bio
submission or not. If it is, then it cannot wait, but ultimately it
does still need to use the mempool to get a guaranteed allocation.
Falling back to the rescuer kthread (which can wait on the mempool)
solves that. But before taking that slow fallback, it's much more
efficient to check the mempool directly first, since pages may be
available there (and in fact it's fairly likely that they will be, since
regular allocations are always used first). The whole point of the
mempool is that it can be used when the regular allocation fails.
This is also the only caller of mempool_alloc_bulk(). So I'm kind of
confused why it would not be allowed to implement the behavior that is
desired here, especially when the non-bulk API offers it already.
- Eric
next prev parent reply other threads:[~2026-08-10 18:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 22:10 [PATCH 0/3] Fix a deadlock in blk-crypto-fallback Eric Biggers
2026-08-06 22:10 ` [PATCH 1/3] mm: make mempool_alloc_from_pool() return bool Eric Biggers
2026-08-10 15:59 ` Christoph Hellwig
2026-08-06 22:10 ` [PATCH 2/3] mm: support fallible mempool_alloc_bulk() Eric Biggers
2026-08-10 16:00 ` Christoph Hellwig
2026-08-10 16:14 ` Eric Biggers
2026-08-10 17:21 ` Christoph Hellwig
2026-08-10 18:22 ` Eric Biggers [this message]
2026-08-06 22:10 ` [PATCH 3/3] blk-crypto-fallback: Fix deadlock when encrypting large bio in dm layer Eric Biggers
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=20260810182215.GA270444@google.com \
--to=ebiggers@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@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.