From: Mike Snitzer <snitzer@kernel.org>
To: dm-devel@redhat.com
Cc: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com
Subject: [dm-devel] [dm-5.19 PATCH 20/21] dm: simplify bio-based IO accounting further
Date: Sun, 17 Apr 2022 22:27:32 -0400 [thread overview]
Message-ID: <20220418022733.56168-21-snitzer@kernel.org> (raw)
In-Reply-To: <20220418022733.56168-1-snitzer@kernel.org>
Now that io splitting is recorded prior to, or during, ->map IO
accounting can happen immediately rather than defer until after
bio splitting in dm_split_and_process_bio().
Remove the DM_IO_START_ACCT flag and also remove dm_io's map_task
member because there is no longer any need to wait for splitting to
occur before accounting.
Also move dm_io struct's 'flags' member to consolidate struct holes.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
drivers/md/dm-core.h | 6 +-----
drivers/md/dm.c | 34 +++++-----------------------------
2 files changed, 6 insertions(+), 34 deletions(-)
diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h
index f3cfc7affd12..d21648a923ea 100644
--- a/drivers/md/dm-core.h
+++ b/drivers/md/dm-core.h
@@ -255,15 +255,12 @@ static inline bool dm_tio_is_normal(struct dm_target_io *tio)
#define DM_IO_MAGIC 19577
struct dm_io {
unsigned short magic;
-
+ blk_short_t flags;
spinlock_t lock;
unsigned long start_time;
void *data;
struct dm_io *next;
- struct task_struct *map_task;
struct dm_stats_aux stats_aux;
-
- blk_short_t flags;
blk_status_t status;
atomic_t io_count;
struct mapped_device *md;
@@ -281,7 +278,6 @@ struct dm_io {
* dm_io flags
*/
enum {
- DM_IO_START_ACCT,
DM_IO_ACCOUNTED,
DM_IO_WAS_SPLIT
};
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index c5a79712de1d..3b87d151ef88 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -596,7 +596,6 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
this_cpu_inc(*md->pending_io);
io->orig_bio = bio;
io->md = md;
- io->map_task = current;
spin_lock_init(&io->lock);
io->start_time = jiffies;
io->flags = 0;
@@ -1242,13 +1241,6 @@ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors)
}
EXPORT_SYMBOL_GPL(dm_accept_partial_bio);
-static inline void __dm_submit_bio_remap(struct bio *clone,
- dev_t dev, sector_t old_sector)
-{
- trace_block_bio_remap(clone, dev, old_sector);
- submit_bio_noacct(clone);
-}
-
/*
* @clone: clone bio that DM core passed to target's .map function
* @tgt_clone: clone of @clone bio that target needs submitted
@@ -1263,8 +1255,6 @@ void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone)
struct dm_target_io *tio = clone_to_tio(clone);
struct dm_io *io = tio->io;
- WARN_ON_ONCE(!tio->ti->accounts_remapped_io);
-
/* establish bio that will get submitted */
if (!tgt_clone)
tgt_clone = clone;
@@ -1273,15 +1263,11 @@ void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone)
* Account io->origin_bio to DM dev on behalf of target
* that took ownership of IO with DM_MAPIO_SUBMITTED.
*/
- if (io->map_task == current) {
- /* Still in target's map function */
- dm_io_set_flag(io, DM_IO_START_ACCT);
- } else {
- dm_start_io_acct(io, clone);
- }
+ dm_start_io_acct(io, clone);
- __dm_submit_bio_remap(tgt_clone, disk_devt(io->md->disk),
+ trace_block_bio_remap(tgt_clone, disk_devt(io->md->disk),
tio->old_sector);
+ submit_bio_noacct(tgt_clone);
}
EXPORT_SYMBOL_GPL(dm_submit_bio_remap);
@@ -1341,16 +1327,10 @@ static void __map_bio(struct bio *clone)
case DM_MAPIO_SUBMITTED:
/* target has assumed ownership of this io */
if (!ti->accounts_remapped_io)
- dm_io_set_flag(io, DM_IO_START_ACCT);
+ dm_start_io_acct(io, clone);
break;
case DM_MAPIO_REMAPPED:
- /*
- * the bio has been remapped so dispatch it, but defer
- * dm_start_io_acct() until after possible bio_split().
- */
- __dm_submit_bio_remap(clone, disk_devt(md->disk),
- tio->old_sector);
- dm_io_set_flag(io, DM_IO_START_ACCT);
+ dm_submit_bio_remap(clone, NULL);
break;
case DM_MAPIO_KILL:
case DM_MAPIO_REQUEUE:
@@ -1668,7 +1648,6 @@ static void dm_split_and_process_bio(struct mapped_device *md,
}
error = __split_and_process_bio(&ci);
- io->map_task = NULL;
if (error || !ci.sector_count)
goto out;
/*
@@ -1680,9 +1659,6 @@ static void dm_split_and_process_bio(struct mapped_device *md,
bio_inc_remaining(bio);
submit_bio_noacct(bio);
out:
- if (dm_io_flagged(io, DM_IO_START_ACCT))
- dm_start_io_acct(io, NULL);
-
/*
* Drop the extra reference count for non-POLLED bio, and hold one
* reference for POLLED bio, which will be released in dm_poll_bio
--
2.15.0
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2022-04-18 2:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-18 2:27 [dm-devel] [dm-5.19 PATCH 00/21] dm: changes staged for 5.19 Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 01/21] block: change exported IO accounting interface from gendisk to bdev Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 02/21] dm: conditionally enable BIOSET_PERCPU_CACHE for dm_io bioset Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 03/21] dm: factor out dm_io_set_error and __dm_io_dec_pending Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 04/21] dm: simplify dm_io access in dm_split_and_process_bio Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 05/21] dm: simplify dm_start_io_acct Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 06/21] dm: mark various branches unlikely Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 07/21] dm: add local variables to clone_endio and __map_bio Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 08/21] dm: move hot dm_io members to same cacheline as dm_target_io Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 09/21] dm: introduce dm_{get, put}_live_table_bio called from dm_submit_bio Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 10/21] dm: conditionally enable branching for less used features Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 11/21] dm: simplify basic targets Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 12/21] dm: use bio_sectors in dm_aceept_partial_bio Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 13/21] dm: don't pass bio to __dm_start_io_acct and dm_end_io_acct Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 14/21] dm: pass dm_io instance to dm_io_acct directly Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 15/21] dm: switch to bdev based IO accounting interfaces Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 16/21] dm: improve bio splitting and associated IO accounting Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 17/21] dm: don't grab target io reference in dm_zone_map_bio Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 18/21] dm: improve dm_io reference counting Mike Snitzer
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 19/21] dm: put all polled dm_io instances into a single list Mike Snitzer
2022-04-18 2:27 ` Mike Snitzer [this message]
2022-04-18 2:27 ` [dm-devel] [dm-5.19 PATCH 21/21] dm: improve abnormal bio processing Mike Snitzer
2022-04-21 4:06 ` Shinichiro Kawasaki
2022-04-22 13:13 ` Mike Snitzer
2022-04-22 13:26 ` Mike Snitzer
2022-04-25 23:57 ` Shinichiro Kawasaki
2022-04-18 3:00 ` [dm-devel] [dm-5.19 PATCH 00/21] dm: changes staged for 5.19 Damien Le Moal
2022-04-18 3:16 ` Mike Snitzer
2022-04-18 12:49 ` Jens Axboe
2022-04-18 12:51 ` [dm-devel] (subset) " Jens Axboe
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=20220418022733.56168-21-snitzer@kernel.org \
--to=snitzer@kernel.org \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=ming.lei@redhat.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