Linux Device Mapper development
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Mike Snitzer <snitzer@kernel.org>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	Christoph Hellwig <hch@infradead.org>,
	dm-devel@redhat.com, tj@kernel.org,
	Dennis Zhou <dennis@kernel.org>
Subject: Re: [dm-devel] can we reduce bio_set_dev overhead due to bio_associate_blkg?
Date: Mon, 11 Apr 2022 13:16:01 -0400	[thread overview]
Message-ID: <YlRiUVFK+a0DwQhu@redhat.com> (raw)
In-Reply-To: <YlReKjjWhvTZjfg/@redhat.com>

On Mon, Apr 11 2022 at 12:58P -0400,
Mike Snitzer <snitzer@kernel.org> wrote:

> On Sat, Apr 09 2022 at  1:15P -0400,
> Christoph Hellwig <hch@infradead.org> wrote:
> 
> > On Fri, Apr 08, 2022 at 11:42:51AM -0400, Mike Snitzer wrote:
> > > I think we can achieve the goal of efficient cloning/remapping for
> > > both usecases simply by splitting out the bio_set_dev() and leaving it
> > > to the caller to pick which interface to use (e.g. clone vs
> > > clone_and_remap).
> > 
> > You can just pass a NULL bdev to bio_alloc_clone/bio_init_clone.
> > I've been hoping to get rid of that, but if we have a clear use case
> > it will have to stay.
> 
> DM core is just using bio_alloc_clone. And bio_alloc_bioset() allows
> bdev to be NULL -- so you're likely referring to that (which will skip
> bio_init's bio_associate_blkg).
...

> diff --git a/block/bio.c b/block/bio.c
> index 7892f1108ca6..0340acc283a0 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -772,14 +772,16 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
> 	bio_set_flag(bio, BIO_CLONED);
> 	if (bio_flagged(bio_src, BIO_THROTTLED))
> 		bio_set_flag(bio, BIO_THROTTLED);
> -	if (bio->bi_bdev == bio_src->bi_bdev &&
> -	    bio_flagged(bio_src, BIO_REMAPPED))
> -		bio_set_flag(bio, BIO_REMAPPED);
> 	bio->bi_ioprio = bio_src->bi_ioprio;
> 	bio->bi_iter = bio_src->bi_iter;
> 
> -	bio_clone_blkg_association(bio, bio_src);
> -	blkcg_bio_issue_init(bio);
> +	if (bio->bi_bdev == bio_src->bi_bdev) {
> +		if (bio_flagged(bio_src, BIO_REMAPPED))
> +			bio_set_flag(bio, BIO_REMAPPED);
> +
> +		bio_clone_blkg_association(bio, bio_src);
> +		blkcg_bio_issue_init(bio);
> +	}
> 
> 	if (bio_crypt_clone(bio, bio_src, gfp) < 0)
> 		return -ENOMEM;
> 
> Think this will fix some of the performance penalty of redundant blkcg
> initialization that I reported (though like was also discussed: more
> work likely needed to further optimize bio_associate_blkg).

Looking closer at the case where bio_{alloc,init}_clone are passed a
bdev, bio_init() will call bio_associate_blkg() so the __bio_clone()
work to do anything with blkbg isn't needed at all. So this patch is
best:

diff --git a/block/bio.c b/block/bio.c
index 7892f1108ca6..6980f1b4b0f4 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -778,9 +778,6 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
	bio->bi_ioprio = bio_src->bi_ioprio;
	bio->bi_iter = bio_src->bi_iter;

-	bio_clone_blkg_association(bio, bio_src);
-	blkcg_bio_issue_init(bio);
-
	if (bio_crypt_clone(bio, bio_src, gfp) < 0)
		return -ENOMEM;
	if (bio_integrity(bio_src) &&

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2022-04-11 17:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 16:52 [dm-devel] can we reduce bio_set_dev overhead due to bio_associate_blkg? Mike Snitzer
2022-03-30 12:28 ` Dennis Zhou
2022-03-31  4:39   ` Christoph Hellwig
2022-03-31  5:52     ` Dennis Zhou
2022-03-31  9:15       ` Christoph Hellwig
2022-04-08 15:42         ` Mike Snitzer
2022-04-09  5:15           ` Christoph Hellwig
2022-04-11 16:58             ` Mike Snitzer
2022-04-11 17:16               ` Mike Snitzer [this message]
2022-04-11 17:33                 ` [dm-devel] [PATCH] block: remove redundant blk-cgroup init from __bio_clone Mike Snitzer
2022-04-12  5:27                   ` Christoph Hellwig
2022-04-12  7:52                     ` Dennis Zhou
2022-04-23 16:55                   ` Christoph Hellwig
2022-04-26 17:30                     ` [dm-devel] " Mike Snitzer

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=YlRiUVFK+a0DwQhu@redhat.com \
    --to=snitzer@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dennis@kernel.org \
    --cc=dm-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@kernel.org \
    --cc=tj@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