public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Subject: [PATCH 3/3] block: remove bvec_free
Date: Mon, 16 Mar 2026 17:11:31 +0100	[thread overview]
Message-ID: <20260316161144.1607877-4-hch@lst.de> (raw)
In-Reply-To: <20260316161144.1607877-1-hch@lst.de>

bvec_free is only called by bio_free, so inline it there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 5982bf069cef..b58bce6b5fea 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -161,17 +161,6 @@ static void bio_put_slab(struct bio_set *bs)
 	mutex_unlock(&bio_slab_lock);
 }
 
-static void bvec_free(struct mempool *pool, struct bio_vec *bv,
-		      unsigned short nr_vecs)
-{
-	BUG_ON(nr_vecs > BIO_MAX_VECS);
-
-	if (nr_vecs == BIO_MAX_VECS)
-		mempool_free(bv, pool);
-	else if (nr_vecs > BIO_INLINE_VECS)
-		kmem_cache_free(biovec_slab(nr_vecs)->slab, bv);
-}
-
 /*
  * Make the first allocation restricted and don't dump info on allocation
  * failures, since we'll fall back to the mempool in case of failure.
@@ -203,9 +192,14 @@ static void bio_free(struct bio *bio)
 	void *p = bio;
 
 	WARN_ON_ONCE(!bs);
+	WARN_ON_ONCE(bio->bi_max_vecs > BIO_MAX_VECS);
 
 	bio_uninit(bio);
-	bvec_free(&bs->bvec_pool, bio->bi_io_vec, bio->bi_max_vecs);
+	if (bio->bi_max_vecs == BIO_MAX_VECS)
+		mempool_free(bio->bi_io_vec, &bs->bvec_pool);
+	else if (bio->bi_max_vecs > BIO_INLINE_VECS)
+		kmem_cache_free(biovec_slab(bio->bi_max_vecs)->slab,
+				bio->bi_io_vec);
 	mempool_free(p - bs->front_pad, &bs->bio_pool);
 }
 
@@ -561,7 +555,7 @@ struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs,
 
 		/*
 		 * Upgrade nr_vecs to take full advantage of the allocation.
-		 * We also rely on this in bvec_free().
+		 * We also rely on this in bio_free().
 		 */
 		nr_vecs = bvs->nr_vecs;
 		bvecs = kmem_cache_alloc(bvs->slab, gfp);
-- 
2.47.3


  parent reply	other threads:[~2026-03-16 16:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 16:11 bio allocation cleanups Christoph Hellwig
2026-03-16 16:11 ` [PATCH 1/3] block: mark bvec_{alloc,free} static Christoph Hellwig
2026-03-17 13:38   ` Johannes Thumshirn
2026-03-18  0:26   ` Chaitanya Kulkarni
2026-03-16 16:11 ` [PATCH 2/3] block: split bio_alloc_bioset more clearly into a fast and slowpath Christoph Hellwig
2026-03-18  0:27   ` Chaitanya Kulkarni
2026-03-16 16:11 ` Christoph Hellwig [this message]
2026-03-17 13:40   ` [PATCH 3/3] block: remove bvec_free Johannes Thumshirn
2026-03-18  0:27   ` Chaitanya Kulkarni
2026-03-18  1:21 ` bio allocation cleanups Martin K. Petersen
2026-03-18  1:27 ` Jens Axboe

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=20260316161144.1607877-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox