From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk
Cc: hannes@cmpxchg.org, linux-block@vger.kernel.org
Subject: [PATCH 2/4] block: cleanup the memory stall accounting in submit_bio
Date: Tue, 28 Apr 2020 13:27:54 +0200 [thread overview]
Message-ID: <20200428112756.1892137-3-hch@lst.de> (raw)
In-Reply-To: <20200428112756.1892137-1-hch@lst.de>
Instead of a convoluted chain just check for REQ_OP_READ directly,
and keep all the memory stall code together in a single unlikely
branch.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-core.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 68351ee94ad2e..81a291085c6ca 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1148,10 +1148,6 @@ EXPORT_SYMBOL_GPL(direct_make_request);
*/
blk_qc_t submit_bio(struct bio *bio)
{
- bool workingset_read = false;
- unsigned long pflags;
- blk_qc_t ret;
-
if (blkcg_punt_bio_submit(bio))
return BLK_QC_T_NONE;
@@ -1170,8 +1166,6 @@ blk_qc_t submit_bio(struct bio *bio)
if (op_is_write(bio_op(bio))) {
count_vm_events(PGPGOUT, count);
} else {
- if (bio_flagged(bio, BIO_WORKINGSET))
- workingset_read = true;
task_io_account_read(bio->bi_iter.bi_size);
count_vm_events(PGPGIN, count);
}
@@ -1187,20 +1181,24 @@ blk_qc_t submit_bio(struct bio *bio)
}
/*
- * If we're reading data that is part of the userspace
- * workingset, count submission time as memory stall. When the
- * device is congested, or the submitting cgroup IO-throttled,
- * submission can be a significant part of overall IO time.
+ * If we're reading data that is part of the userspace workingset, count
+ * submission time as memory stall. When the device is congested, or
+ * the submitting cgroup IO-throttled, submission can be a significant
+ * part of overall IO time.
*/
- if (workingset_read)
- psi_memstall_enter(&pflags);
-
- ret = generic_make_request(bio);
+ if (unlikely(bio_op(bio) == REQ_OP_READ &&
+ bio_flagged(bio, BIO_WORKINGSET))) {
+ unsigned long pflags;
+ blk_qc_t ret;
- if (workingset_read)
+ psi_memstall_enter(&pflags);
+ ret = generic_make_request(bio);
psi_memstall_leave(&pflags);
- return ret;
+ return ret;
+ }
+
+ return generic_make_request(bio);
}
EXPORT_SYMBOL(submit_bio);
--
2.26.2
next prev parent reply other threads:[~2020-04-28 11:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 11:27 a few small bio related cleanups Christoph Hellwig
2020-04-28 11:27 ` [PATCH 1/4] block: improve the submit_bio and generic_make_request documentation Christoph Hellwig
2020-04-28 14:16 ` Johannes Thumshirn
2020-04-28 14:17 ` Keith Busch
2020-04-28 11:27 ` Christoph Hellwig [this message]
2020-04-28 14:12 ` [PATCH 2/4] block: cleanup the memory stall accounting in submit_bio Johannes Thumshirn
2020-04-28 14:21 ` Christoph Hellwig
2020-04-28 15:06 ` Johannes Weiner
2020-04-28 11:27 ` [PATCH 3/4] block: replace BIO_QUEUE_ENTERED with BIO_CGROUP_ACCT Christoph Hellwig
2020-04-28 14:23 ` Johannes Thumshirn
2020-04-28 14:24 ` Christoph Hellwig
2020-04-28 14:26 ` Johannes Thumshirn
2020-04-28 11:27 ` [PATCH 4/4] block: add a bio_queue_enter helper Christoph Hellwig
2020-04-28 14:55 ` Johannes Thumshirn
2020-04-29 15:33 ` a few small bio related cleanups 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=20200428112756.1892137-3-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=hannes@cmpxchg.org \
--cc=linux-block@vger.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;
as well as URLs for NNTP newsgroup(s).