* [dm-devel] [PATCH] dm: fix dm_stats accounting
@ 2022-02-11 15:01 Mikulas Patocka
2022-02-11 16:08 ` [dm-devel] " Mike Snitzer
0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2022-02-11 15:01 UTC (permalink / raw)
To: Mike Snitzer; +Cc: dm-devel
Exactly the same sector number and length must be passed to both calls of
dm_stats_account_io, otherwise its per-zone in_flight counters go out of
sync. This patch fixes it.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/md/dm.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
Index: linux-dm/drivers/md/dm.c
===================================================================
--- linux-dm.orig/drivers/md/dm.c 2022-02-11 15:32:56.000000000 +0100
+++ linux-dm/drivers/md/dm.c 2022-02-11 15:40:11.000000000 +0100
@@ -487,16 +487,20 @@ EXPORT_SYMBOL_GPL(dm_start_time_ns_from_
static void start_io_acct(struct dm_io *io, struct bio *bio)
{
+ struct bio *orig_bio;
+
/* Ensure IO accounting is only ever started once */
if (xchg(&io->was_accounted, 1) == 1)
return;
+ orig_bio = io->orig_bio;
+
bio_start_io_acct_remapped(bio, io->start_time,
- io->orig_bio->bi_bdev);
+ orig_bio->bi_bdev);
if (unlikely(dm_stats_used(&io->md->stats)))
- dm_stats_account_io(&io->md->stats, bio_data_dir(bio),
- bio->bi_iter.bi_sector, bio_sectors(bio),
+ dm_stats_account_io(&io->md->stats, bio_data_dir(orig_bio),
+ orig_bio->bi_iter.bi_sector, bio_sectors(orig_bio),
false, 0, &io->stats_aux);
}
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dm-devel] dm: fix dm_stats accounting
2022-02-11 15:01 [dm-devel] [PATCH] dm: fix dm_stats accounting Mikulas Patocka
@ 2022-02-11 16:08 ` Mike Snitzer
0 siblings, 0 replies; 2+ messages in thread
From: Mike Snitzer @ 2022-02-11 16:08 UTC (permalink / raw)
To: Mikulas Patocka; +Cc: Mike Snitzer, dm-devel
On Fri, Feb 11 2022 at 10:01P -0500,
Mikulas Patocka <mpatocka@redhat.com> wrote:
> Exactly the same sector number and length must be passed to both calls of
> dm_stats_account_io, otherwise its per-zone in_flight counters go out of
> sync. This patch fixes it.
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
>
> ---
> drivers/md/dm.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> Index: linux-dm/drivers/md/dm.c
> ===================================================================
> --- linux-dm.orig/drivers/md/dm.c 2022-02-11 15:32:56.000000000 +0100
> +++ linux-dm/drivers/md/dm.c 2022-02-11 15:40:11.000000000 +0100
> @@ -487,16 +487,20 @@ EXPORT_SYMBOL_GPL(dm_start_time_ns_from_
>
> static void start_io_acct(struct dm_io *io, struct bio *bio)
> {
> + struct bio *orig_bio;
> +
> /* Ensure IO accounting is only ever started once */
> if (xchg(&io->was_accounted, 1) == 1)
> return;
>
> + orig_bio = io->orig_bio;
> +
> bio_start_io_acct_remapped(bio, io->start_time,
> - io->orig_bio->bi_bdev);
> + orig_bio->bi_bdev);
>
> if (unlikely(dm_stats_used(&io->md->stats)))
> - dm_stats_account_io(&io->md->stats, bio_data_dir(bio),
> - bio->bi_iter.bi_sector, bio_sectors(bio),
> + dm_stats_account_io(&io->md->stats, bio_data_dir(orig_bio),
> + orig_bio->bi_iter.bi_sector, bio_sectors(orig_bio),
> false, 0, &io->stats_aux);
> }
>
>
You cannot account using the orig_bio because it doesn't reflect
splits that occurred. orig_bio will be updated to reflect the split
after __map_bio returns all the way back to dm_split_and_process_bio.
So there is no imbalance between start_io_acct and end_io_acct's calls
to dm_stats_account_io.
Also, in_flight counters don't (or shouldn't) care about the payload.
So again, I'm not following the reasoning on this patch.
Mike
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-11 16:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-11 15:01 [dm-devel] [PATCH] dm: fix dm_stats accounting Mikulas Patocka
2022-02-11 16:08 ` [dm-devel] " Mike Snitzer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox