Skip to content

Commit

Permalink
blk-iolatency: only call ktime_get() if needed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Hongnan Li authored and axboe committed Jul 1, 2020
1 parent 5a6c35f commit 6e2fa4d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion block/blk-iolatency.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 6e2fa4d

Please sign in to comment.