diff mbox series

[RESEND] blkcg: delete redundant get/put operations for queue

Message ID 1611551128-1238-1-git-send-email-brookxu@tencent.com (mailing list archive)
State New, archived
Headers show
Series [RESEND] blkcg: delete redundant get/put operations for queue | expand

Commit Message

Chunguang Xu Jan. 25, 2021, 5:05 a.m. UTC
From: Chunguang Xu <brookxu@tencent.com>

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>
---
 block/blk-cgroup.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Jens Axboe Jan. 26, 2021, 8:14 p.m. UTC | #1
On 1/24/21 10:05 PM, Chunguang Xu wrote:
> From: Chunguang Xu <brookxu@tencent.com>
> 
> When calling blkcg_schedule_throttle(), for the same queue,
> redundant get/put operations can be removed.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 031114d..e9b264b 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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);