From: Xiao Ni <xni@redhat.com>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: song@kernel.org, linux-raid@vger.kernel.org,
linux-kernel@vger.kernel.org, yukuai3@huawei.com,
yi.zhang@huawei.com, yangerkun@huawei.com
Subject: Re: [PATCH -next 4/8] md/raid1: switch to use md_account_bio() for io accounting
Date: Tue, 20 Jun 2023 17:07:43 +0800 [thread overview]
Message-ID: <CALTww28AYb3Gi0qKHqsRuFrS0_P9-Fo1BYhsvTsrTFKnu084SA@mail.gmail.com> (raw)
In-Reply-To: <20230619204826.755559-5-yukuai1@huaweicloud.com>
On Mon, Jun 19, 2023 at 8:49 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> From: Yu Kuai <yukuai3@huawei.com>
>
> Two problems can be fixed this way:
>
> 1) 'active_io' will represent inflight io instead of io that is
> dispatching.
>
> 2) If io accounting is enabled or disabled while io is still inflight,
> bio_start_io_acct() and bio_end_io_acct() is not balanced and io
> inflight counter will be leaked.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/md/raid1.c | 14 ++++++--------
> drivers/md/raid1.h | 1 -
> 2 files changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index dd25832eb045..06fa1580501f 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -304,8 +304,6 @@ static void call_bio_endio(struct r1bio *r1_bio)
> if (!test_bit(R1BIO_Uptodate, &r1_bio->state))
> bio->bi_status = BLK_STS_IOERR;
>
> - if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
> - bio_end_io_acct(bio, r1_bio->start_time);
> bio_endio(bio);
> }
>
> @@ -1303,10 +1301,10 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
> }
>
> r1_bio->read_disk = rdisk;
> -
> - if (!r1bio_existed && blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
> - r1_bio->start_time = bio_start_io_acct(bio);
> -
> + if (!r1bio_existed) {
> + md_account_bio(mddev, &bio);
> + r1_bio->master_bio = bio;
> + }
> read_bio = bio_alloc_clone(mirror->rdev->bdev, bio, gfp,
> &mddev->bio_set);
>
> @@ -1500,8 +1498,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
> r1_bio->sectors = max_sectors;
> }
>
> - if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
> - r1_bio->start_time = bio_start_io_acct(bio);
> + md_account_bio(mddev, &bio);
> + r1_bio->master_bio = bio;
> atomic_set(&r1_bio->remaining, 1);
> atomic_set(&r1_bio->behind_remaining, 0);
>
> diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h
> index 468f189da7a0..14d4211a123a 100644
> --- a/drivers/md/raid1.h
> +++ b/drivers/md/raid1.h
> @@ -157,7 +157,6 @@ struct r1bio {
> sector_t sector;
> int sectors;
> unsigned long state;
> - unsigned long start_time;
> struct mddev *mddev;
> /*
> * original bio going to /dev/mdx
> --
> 2.39.2
>
Hi Kuai
After this patch, raid1 will have one more memory allocation in the
I/O path. Not sure if it can affect performance. Beside this, the
patch is good for me.
Reviewed-by: Xiao Ni <xni@redhat.com>
next prev parent reply other threads:[~2023-06-20 9:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 20:48 [PATCH -next 0/8] md: fix and refactor io accounting and 'active_io' Yu Kuai
2023-06-19 20:48 ` [PATCH -next 1/8] md: move initialization and destruction of 'io_acct_set' to md.c Yu Kuai
2023-06-20 8:35 ` Xiao Ni
2023-06-21 2:35 ` Yu Kuai
2023-06-19 20:48 ` [PATCH -next 2/8] md: also clone new io if io accounting is disabled Yu Kuai
2023-06-20 8:48 ` Xiao Ni
2023-06-19 20:48 ` [PATCH -next 3/8] raid5: fix missing io accounting in raid5_align_endio() Yu Kuai
2023-06-20 8:52 ` Xiao Ni
2023-06-20 9:57 ` Paul Menzel
2023-06-21 3:22 ` Yu Kuai
2023-06-19 20:48 ` [PATCH -next 4/8] md/raid1: switch to use md_account_bio() for io accounting Yu Kuai
2023-06-20 9:07 ` Xiao Ni [this message]
2023-06-20 13:38 ` Yu Kuai
2023-06-19 20:48 ` [PATCH -next 5/8] md/raid10: " Yu Kuai
2023-06-20 9:10 ` Xiao Ni
2023-06-19 20:48 ` [PATCH -next 6/8] md/md-multipath: enable " Yu Kuai
2023-06-20 9:11 ` Xiao Ni
2023-06-19 20:48 ` [PATCH -next 7/8] md/md-linear: " Yu Kuai
2023-06-20 9:12 ` Xiao Ni
2023-06-19 20:48 ` [PATCH -next 8/8] md/md-faulty: " Yu Kuai
2023-06-20 9:13 ` Xiao Ni
2023-06-20 17:45 ` [PATCH -next 0/8] md: fix and refactor io accounting and 'active_io' Song Liu
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=CALTww28AYb3Gi0qKHqsRuFrS0_P9-Fo1BYhsvTsrTFKnu084SA@mail.gmail.com \
--to=xni@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.com \
/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
all inboxes | Powered by JetHome®