Message ID | 0cf2d7dca8c0ee6322f4e068c2d0f56ac731e551.1666886282.git.asml.silence@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iopoll bio pcpu cache fix | expand |
diff --git a/block/bio.c b/block/bio.c index 0a14af923738..e00c93be368a 100644 --- a/block/bio.c +++ b/block/bio.c @@ -526,6 +526,8 @@ struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs, } if (unlikely(!p)) return NULL; + if (!mempool_is_saturated(&bs->bio_pool)) + opf &= ~REQ_ALLOC_CACHE; bio = p + bs->front_pad; if (nr_vecs > BIO_INLINE_VECS) {
Biosets keep a mempool, so as long as requests complete we can always can allocate and have forward progress. Percpu bio caches break that assumptions as we may complete into the cache of one CPU and after try and fail to allocate with another CPU. We also can't grab from another CPU's cache without tricky sync. If we're allocating with a bio while the mempool is undersaturated, remove REQ_ALLOC_CACHE flag, so on put it will go straight to mempool. It might try to free into mempool more requests than required, but assuming than there is no memory starvation in the system it'll stabilise and never hit that path. Fixes: be4d234d7aebb ("bio: add allocation cache abstraction") Cc: <stable@vger.kernel.org> # 5.15+ Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- block/bio.c | 2 ++ 1 file changed, 2 insertions(+)