]> git.baikalelectronics.ru Git - kernel.git/commitdiff
blkcg: delete redundant get/put operations for queue
authorChunguang Xu <brookxu@tencent.com>
Mon, 25 Jan 2021 05:05:28 +0000 (13:05 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 26 Jan 2021 20:14:30 +0000 (13:14 -0700)
When calling blkcg_schedule_throttle(), for the same queue,
redundant get/put operations can be removed.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c

index 3465d6ee708edfb8b34dce95ac2389bc25278dd1..02ce2058c14b3155ffff67b16b28eb571abd87db 100644 (file)
@@ -1757,12 +1757,15 @@ void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay)
        if (unlikely(current->flags & PF_KTHREAD))
                return;
 
-       if (!blk_get_queue(q))
-               return;
+       if (current->throttle_queue != q) {
+               if (!blk_get_queue(q))
+                       return;
+
+               if (current->throttle_queue)
+                       blk_put_queue(current->throttle_queue);
+               current->throttle_queue = q;
+       }
 
-       if (current->throttle_queue)
-               blk_put_queue(current->throttle_queue);
-       current->throttle_queue = q;
        if (use_memdelay)
                current->use_memdelay = use_memdelay;
        set_notify_resume(current);