diff options
author | Hongnan Li <hongnan.li@linux.alibaba.com> | 2020-07-01 11:09:38 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-07-01 17:02:38 +0300 |
commit | 6e2fa4dd683a22a7697e7ff51dad499406094d28 (patch) | |
tree | 2d90f66acae2e7111558a25e587b93cbae0dfd4e /block/blk-iolatency.c | |
parent | 5a6c35f9af416114588298aa7a90b15bbed15a41 (diff) | |
download | linux-6e2fa4dd683a22a7697e7ff51dad499406094d28.tar.xz |
blk-iolatency: only call ktime_get() if needed
ktime_to_ns(ktime_get()), which is expensive, does not need to be called
if blk_iolatency_enabled() return false in blkcg_iolatency_done_bio().
Postponing ktime_to_ns(ktime_get()) execution reduces the CPU usage when
blk_iolatency is disabled.
Signed-off-by: Hongnan Li <hongnan.li@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-iolatency.c')
-rw-r--r-- | block/blk-iolatency.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index c128d50cb410..f90429cf4edf 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -591,7 +591,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) struct rq_wait *rqw; struct iolatency_grp *iolat; u64 window_start; - u64 now = ktime_to_ns(ktime_get()); + u64 now; bool issue_as_root = bio_issue_as_root_blkg(bio); bool enabled = false; int inflight = 0; @@ -608,6 +608,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) if (!enabled) return; + now = ktime_to_ns(ktime_get()); while (blkg && blkg->parent) { iolat = blkg_to_lat(blkg); if (!iolat) { |