From: Mike Snitzer <snitzer@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, dm-devel@redhat.com,
Mikulas Patocka <mpatocka@redhat.com>
Subject: [PATCH v4 7/7] dm: remove the pending IO accounting
Date: Thu, 6 Dec 2018 11:41:22 -0500 [thread overview]
Message-ID: <20181206164122.2166-8-snitzer@redhat.com> (raw)
In-Reply-To: <20181206164122.2166-1-snitzer@redhat.com>
From: Mikulas Patocka <mpatocka@redhat.com>
Remove the "pending" atomic counters, that duplicate block-core's
in_flight counters, and update md_in_flight() to look at percpu
in_flight counters.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-core.h | 2 --
drivers/md/dm.c | 34 +++++++++++++++-------------------
2 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h
index 224d44503a06..6fe883fac471 100644
--- a/drivers/md/dm-core.h
+++ b/drivers/md/dm-core.h
@@ -65,7 +65,6 @@ struct mapped_device {
*/
struct work_struct work;
wait_queue_head_t wait;
- atomic_t pending[2];
spinlock_t deferred_lock;
struct bio_list deferred;
@@ -119,7 +118,6 @@ struct mapped_device {
struct srcu_struct io_barrier;
};
-int md_in_flight(struct mapped_device *md);
void disable_write_same(struct mapped_device *md);
void disable_write_zeroes(struct mapped_device *md);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a8ae7931bce7..d4bc4237b09a 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -646,25 +646,30 @@ static void free_tio(struct dm_target_io *tio)
bio_put(&tio->clone);
}
-int md_in_flight(struct mapped_device *md)
+static bool md_in_flight(struct mapped_device *md)
{
- return atomic_read(&md->pending[READ]) +
- atomic_read(&md->pending[WRITE]);
+ int cpu;
+ struct hd_struct *part = &dm_disk(md)->part0;
+
+ for_each_possible_cpu(cpu) {
+ if (part_stat_local_read_cpu(part, in_flight[0], cpu) ||
+ part_stat_local_read_cpu(part, in_flight[1], cpu))
+ return true;
+ }
+
+ return false;
}
static void start_io_acct(struct dm_io *io)
{
struct mapped_device *md = io->md;
struct bio *bio = io->orig_bio;
- int rw = bio_data_dir(bio);
io->start_time = jiffies;
generic_start_io_acct(md->queue, bio_op(bio), bio_sectors(bio),
&dm_disk(md)->part0);
- atomic_inc(&md->pending[rw]);
-
if (unlikely(dm_stats_used(&md->stats)))
dm_stats_account_io(&md->stats, bio_data_dir(bio),
bio->bi_iter.bi_sector, bio_sectors(bio),
@@ -676,8 +681,6 @@ static void end_io_acct(struct dm_io *io)
struct mapped_device *md = io->md;
struct bio *bio = io->orig_bio;
unsigned long duration = jiffies - io->start_time;
- int pending;
- int rw = bio_data_dir(bio);
generic_end_io_acct(md->queue, bio_op(bio), &dm_disk(md)->part0,
io->start_time);
@@ -687,16 +690,11 @@ static void end_io_acct(struct dm_io *io)
bio->bi_iter.bi_sector, bio_sectors(bio),
true, duration, &io->stats_aux);
- /*
- * After this is decremented the bio must not be touched if it is
- * a flush.
- */
- pending = atomic_dec_return(&md->pending[rw]);
- pending += atomic_read(&md->pending[rw^0x1]);
-
/* nudge anyone waiting on suspend queue */
- if (!pending)
- wake_up(&md->wait);
+ if (unlikely(waitqueue_active(&md->wait))) {
+ if (!md_in_flight(md))
+ wake_up(&md->wait);
+ }
}
/*
@@ -1904,8 +1902,6 @@ static struct mapped_device *alloc_dev(int minor)
if (!md->disk)
goto bad;
- atomic_set(&md->pending[0], 0);
- atomic_set(&md->pending[1], 0);
init_waitqueue_head(&md->wait);
INIT_WORK(&md->work, dm_wq_work);
init_waitqueue_head(&md->eventq);
--
2.15.0
next prev parent reply other threads:[~2018-12-06 16:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-06 16:41 [PATCH v4 0/7] per-cpu in_flight counters for bio-based drivers Mike Snitzer
2018-12-06 16:41 ` [PATCH v4 1/7] dm: dont rewrite dm_disk(md)->part0.in_flight Mike Snitzer
2018-12-06 16:41 ` [PATCH v4 2/7] dm rq: leverage blk_mq_queue_busy() to check for outstanding IO Mike Snitzer
2018-12-06 16:41 ` [PATCH v4 3/7] block: stop passing 'cpu' to all percpu stats methods Mike Snitzer
2018-12-06 16:41 ` [PATCH v4 4/7] block: delete part_round_stats and switch to less precise counting Mike Snitzer
2018-12-06 16:41 ` [PATCH v4 5/7] block: switch to per-cpu in-flight counters Mike Snitzer
2018-12-06 16:41 ` [PATCH v4 6/7] block: return just one value from part_in_flight Mike Snitzer
2018-12-06 16:41 ` Mike Snitzer [this message]
2018-12-06 18:00 ` [PATCH v4 0/7] per-cpu in_flight counters for bio-based drivers Mike Snitzer
2018-12-06 19:04 ` Mike Snitzer
2018-12-10 15:35 ` 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=20181206164122.2166-8-snitzer@redhat.com \
--to=snitzer@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=mpatocka@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;
as well as URLs for NNTP newsgroup(s).