Skip to content

Commit 6e2fa4d

Browse files
Hongnan Liaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 5a6c35f commit 6e2fa4d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

block/blk-iolatency.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)
591591
struct rq_wait *rqw;
592592
struct iolatency_grp *iolat;
593593
u64 window_start;
594-
u64 now = ktime_to_ns(ktime_get());
594+
u64 now;
595595
bool issue_as_root = bio_issue_as_root_blkg(bio);
596596
bool enabled = false;
597597
int inflight = 0;
@@ -608,6 +608,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)
608608
if (!enabled)
609609
return;
610610

611+
now = ktime_to_ns(ktime_get());
611612
while (blkg && blkg->parent) {
612613
iolat = blkg_to_lat(blkg);
613614
if (!iolat) {

0 commit comments

Comments
 (0)