linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-block@vger.kernel.org
Cc: axboe@kernel.dk, ming.lei@redhat.com, yukuai1@huaweicloud.com,
	hch@lst.de, shinichiro.kawasaki@wdc.com, kch@nvidia.com,
	gjoyce@ibm.com
Subject: [PATCHv3 2/3] block: decrement block_rq_qos static key in rq_qos_del()
Date: Thu, 14 Aug 2025 13:54:58 +0530	[thread overview]
Message-ID: <20250814082612.500845-3-nilay@linux.ibm.com> (raw)
In-Reply-To: <20250814082612.500845-1-nilay@linux.ibm.com>

rq_qos_add() increments the block_rq_qos static key when a QoS
policy is attached. When a QoS policy is removed via rq_qos_del(),
we must symmetrically decrement the static key. If this removal drops
the last QoS policy from the queue (q->rq_qos becomes NULL), the
static branch can be disabled and the jump label patched to a NOP,
avoiding overhead on the hot path.

This change ensures rq_qos_add()/rq_qos_del() keep the
block_rq_qos static key balanced and prevents leaving the branch
permanently enabled after the last policy is removed.

Fixes: 033b667a823e ("block: blk-rq-qos: guard rq-qos helpers by static key")
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
 block/blk-rq-qos.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index 848591fb3c57..b1e24bb85ad2 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -374,6 +374,7 @@ void rq_qos_del(struct rq_qos *rqos)
 	for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) {
 		if (*cur == rqos) {
 			*cur = rqos->next;
+			static_branch_dec(&block_rq_qos);
 			break;
 		}
 	}
-- 
2.50.1


  parent reply	other threads:[~2025-08-14  8:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14  8:24 [PATCHv3 0/3] block: blk-rq-qos: replace static key with atomic bitop Nilay Shroff
2025-08-14  8:24 ` [PATCHv3 1/3] block: skip q->rq_qos check in rq_qos_done_bio() Nilay Shroff
2025-08-14  8:59   ` Yu Kuai
2025-08-14 11:12   ` Ming Lei
2025-08-14  8:24 ` Nilay Shroff [this message]
2025-08-14  9:14   ` [PATCHv3 2/3] block: decrement block_rq_qos static key in rq_qos_del() Yu Kuai
2025-08-14 11:33   ` Ming Lei
2025-08-14  8:24 ` [PATCHv3 3/3] block: avoid cpu_hotplug_lock depedency on freeze_lock Nilay Shroff
2025-08-14  9:21   ` Yu Kuai
2025-08-14 12:44   ` Ming Lei
2025-08-14 12:57     ` Nilay Shroff
2025-08-14 13:38       ` Ming Lei
2025-08-14 14:31         ` Nilay Shroff
2025-08-15  0:13           ` Ming Lei
2025-08-15  1:04             ` Yu Kuai
2025-08-15  7:59               ` Ming Lei
2025-08-15  8:39                 ` Yu Kuai
2025-08-15  9:43             ` Nilay Shroff
2025-08-15 13:24               ` Ming Lei
2025-08-15 18:33                 ` Nilay Shroff
2025-08-16  1:01                   ` Yu Kuai
2025-08-16  1:59   ` Ming Lei
2025-08-21 12:19 ` [PATCHv3 0/3] block: blk-rq-qos: replace static key with atomic bitop Nilay Shroff
2025-08-21 13:11   ` Jens Axboe
2025-08-21 13:11 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250814082612.500845-3-nilay@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=gjoyce@ibm.com \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=shinichiro.kawasaki@wdc.com \
    --cc=yukuai1@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).