Message ID | 3c908cb74959c631995341111a7ce116487da5c5.1634676157.git.asml.silence@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block optimisation round | expand |
On 10/19/21 2:24 PM, Pavel Begunkov wrote: > External email: Use caution opening links or attachments > > > If a bio was just allocated its flags should be zero and there is no > need to clear them. Add __bio_set_dev(), which is faster and doesn't > care about clering flags. > > Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Looks good. Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
On Tue, Oct 19, 2021 at 10:24:20PM +0100, Pavel Begunkov wrote: > If a bio was just allocated its flags should be zero and there is no > need to clear them. Add __bio_set_dev(), which is faster and doesn't > care about clering flags. This is entirely the wrong way around. Please add a new bio_reset_dev for the no more than about two hand full callers that actually had a device set and just optimize bio_set_dev.
On 10/20/21 07:20, Christoph Hellwig wrote: > On Tue, Oct 19, 2021 at 10:24:20PM +0100, Pavel Begunkov wrote: >> If a bio was just allocated its flags should be zero and there is no >> need to clear them. Add __bio_set_dev(), which is faster and doesn't >> care about clering flags. > > This is entirely the wrong way around. Please add a new bio_reset_dev > for the no more than about two hand full callers that actually had > a device set and just optimize bio_set_dev. makes sense, thanks
diff --git a/block/fops.c b/block/fops.c index 8e3790faafb8..7cf98db0595a 100644 --- a/block/fops.c +++ b/block/fops.c @@ -75,7 +75,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb, } bio_init(&bio, vecs, nr_pages); - bio_set_dev(&bio, bdev); + __bio_set_dev(&bio, bdev); bio.bi_iter.bi_sector = pos >> 9; bio.bi_write_hint = iocb->ki_hint; bio.bi_private = current; @@ -224,7 +224,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, blk_start_plug(&plug); for (;;) { - bio_set_dev(bio, bdev); + __bio_set_dev(bio, bdev); bio->bi_iter.bi_sector = pos >> 9; bio->bi_write_hint = iocb->ki_hint; bio->bi_private = dio; diff --git a/include/linux/bio.h b/include/linux/bio.h index c88700d1bdc3..0ab4fa2c89c3 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -453,13 +453,19 @@ static inline void bio_clone_blkg_association(struct bio *dst, struct bio *src) { } #endif /* CONFIG_BLK_CGROUP */ +/* can be used only with freshly allocated bios */ +static inline void __bio_set_dev(struct bio *bio, struct block_device *bdev) +{ + bio->bi_bdev = bdev; + bio_associate_blkg(bio); +} + static inline void bio_set_dev(struct bio *bio, struct block_device *bdev) { bio_clear_flag(bio, BIO_REMAPPED); if (bio->bi_bdev != bdev) bio_clear_flag(bio, BIO_THROTTLED); - bio->bi_bdev = bdev; - bio_associate_blkg(bio); + __bio_set_dev(bio, bdev); } static inline void bio_copy_dev(struct bio *dst, struct bio *src)
If a bio was just allocated its flags should be zero and there is no need to clear them. Add __bio_set_dev(), which is faster and doesn't care about clering flags. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- block/fops.c | 4 ++-- include/linux/bio.h | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-)