]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
blk-iolatency: only call ktime_get() if needed
authorHongnan Li <hongnan.li@linux.alibaba.com>
Wed, 1 Jul 2020 08:09:38 +0000 (16:09 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 1 Jul 2020 14:02:38 +0000 (08:02 -0600)
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>
block/blk-iolatency.c

index c128d50cb4107969cab6460e3447b93f7c54553f..f90429cf4edf77ddd1457c6ad2aca3d28905f37d 100644 (file)
@@ -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) {