From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
linux-kernel@vger.kernel.org, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 3/6] block: don't allocate inline bvecs if this bioset needn't bvecs
Date: Wed, 30 Dec 2020 08:32:52 +0800 [thread overview]
Message-ID: <20201230003255.3450874-4-ming.lei@redhat.com> (raw)
In-Reply-To: <20201230003255.3450874-1-ming.lei@redhat.com>
The inline bvecs won't be used if user needn't bvecs by not passing
BIOSET_NEED_BVECS, so don't allocate bvecs in this situation.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/bio.c | 11 +++++++----
include/linux/bio.h | 1 +
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index aa657cdd7c8c..3991a5aab1bc 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -110,7 +110,7 @@ static void bio_put_slab(struct bio_set *bs)
{
struct bio_slab *bslab = NULL;
unsigned int slab_size = bs->front_pad + sizeof(struct bio) +
- BIO_INLINE_VECS * sizeof(struct bio_vec);
+ bs->back_pad;
mutex_lock(&bio_slab_lock);
@@ -1567,15 +1567,18 @@ int bioset_init(struct bio_set *bs,
unsigned int front_pad,
int flags)
{
- unsigned int back_pad = BIO_INLINE_VECS * sizeof(struct bio_vec);
-
bs->front_pad = front_pad;
+ if (flags & BIOSET_NEED_BVECS)
+ bs->back_pad = BIO_INLINE_VECS * sizeof(struct bio_vec);
+ else
+ bs->back_pad = 0;
+
spin_lock_init(&bs->rescue_lock);
bio_list_init(&bs->rescue_list);
INIT_WORK(&bs->rescue_work, bio_alloc_rescue);
- bs->bio_slab = bio_find_or_create_slab(front_pad + back_pad);
+ bs->bio_slab = bio_find_or_create_slab(bs->front_pad + bs->back_pad);
if (!bs->bio_slab)
return -ENOMEM;
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 1edda614f7ce..f606eb1e556f 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -703,6 +703,7 @@ struct bio_set {
mempool_t bvec_integrity_pool;
#endif
+ unsigned int back_pad;
/*
* Deadlock avoidance for stacking block drivers: see comments in
* bio_alloc_bioset() for details
--
2.28.0
next prev parent reply other threads:[~2020-12-30 0:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-30 0:32 [PATCH 0/6] block: improvement on bioset & bvec allocation Ming Lei
2020-12-30 0:32 ` [PATCH 1/6] block: manage bio slab cache by xarray Ming Lei
2021-01-04 8:54 ` Christoph Hellwig
2020-12-30 0:32 ` [PATCH 2/6] block: don't pass BIOSET_NEED_BVECS for q->bio_split Ming Lei
2021-01-04 18:13 ` Christoph Hellwig
2020-12-30 0:32 ` Ming Lei [this message]
2021-01-04 8:55 ` [PATCH 3/6] block: don't allocate inline bvecs if this bioset needn't bvecs Christoph Hellwig
2020-12-30 0:32 ` [PATCH 4/6] block: set .bi_max_vecs as actual allocated vector number Ming Lei
2021-01-04 8:55 ` Christoph Hellwig
2020-12-30 0:32 ` [PATCH 5/6] block: move three bvec helpers declaration into private helper Ming Lei
2021-01-04 8:56 ` Christoph Hellwig
2020-12-30 0:32 ` [PATCH 6/6] bcache: don't pass BIOSET_NEED_BVECS for the 'bio_set' embedded in 'cache_set' Ming Lei
2021-01-04 8:57 ` Christoph Hellwig
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=20201230003255.3450874-4-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).