diff mbox series

[02/17] block, bfq: try preemption if bfqq has higher weight and the same priority class

Message ID 20230219104309.1511562-3-shikemeng@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series Some bugfix and cleanup patches for bfq | expand

Commit Message

Kemeng Shi Feb. 19, 2023, 10:42 a.m. UTC
We will compare priority class and weight of current bfqq with
in_service_queue to check if bfqq could preempt in_service_queue.
Currently we will try to preempt in_service_queue if bfqq has higher
weight than in_service_queue even with lower priority class. Actually,
we will only serve bfqq with higher priority class (see
bfq_lookup_next_entity), so bfqq with higher weight and lower priority
class will not be a candidate to preempt in_service_queue.
Compare weight of bfqqs with the same priority in
bfq_bfqq_higher_class_or_weight to make preemption check more reasonable.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 block/bfq-iosched.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 3f5c740664ce..4868538c9745 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -1768,6 +1768,10 @@  static bool bfq_bfqq_higher_class_or_weight(struct bfq_queue *bfqq,
 	if (bfqq->ioprio_class < in_serv_bfqq->ioprio_class)
 		return true;
 
+	/* only try weight comparison with same priority class */
+	if (bfqq->ioprio_class != in_serv_bfqq->ioprio_class)
+		return false;
+
 	if (in_serv_bfqq->entity.parent == bfqq->entity.parent) {
 		bfqq_weight = bfqq->entity.weight;
 		in_serv_weight = in_serv_bfqq->entity.weight;