Skip to contentSkip to conversation

bfq: misc updates

PATCH In review brookxu 3 participants 12 messages Apr 20, 2021 – Jun 10, 2021 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

brookxu

author
#0 lore raw

cover bfq: misc updates

From: Chunguang Xu <[email protected]>

Some misc updates, put together mainly to facilitate patch management.

Chunguang Xu (8):
bfq: introduce bfq_entity_to_bfqg helper method
bfq: convert the type of bfq_group.bfqd to bfq_data*
bfq: limit the IO depth of CLASS_IDLE to 1
bfq: keep the minimun bandwidth for CLASS_BE
bfq: remove unnecessary initialization logic
bfq: optimize the calculation of bfq_weight_to_ioprio()
bfq: reset entity->prio_changed in bfq_init_entity()
bfq: remove unnecessary BFQ_DEFAULT_GRP_IOPRIO

 block/bfq-cgroup.c  | 13 +++-----
 block/bfq-iosched.c | 17 +++++++++--
 block/bfq-iosched.h | 15 ++++++----
 block/bfq-wf2q.c    | 86 +++++++++++++++++++++++++++++++++++++----------------
 4 files changed, 88 insertions(+), 43 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/8 bfq: introduce bfq_entity_to_bfqg helper method

From: Chunguang Xu <[email protected]>

Introduce bfq_entity_to_bfqg() to make it easier to obtain the bfq_group corresponding to the entity.

---
 block/bfq-cgroup.c  |  6 ++----
 block/bfq-iosched.h |  1 +
 block/bfq-wf2q.c    | 16 ++++++++++++----
 3 files changed, 15 insertions(+), 8 deletions(-)
block/bfq-cgroup.c +2 -4
index b791e20..a5f544a 100644
@@ -309,8 +309,7 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
 {
 	struct bfq_entity *group_entity = bfqq->entity.parent;
 
-	return group_entity ? container_of(group_entity, struct bfq_group,
-					   entity) :
+	return group_entity ? bfq_entity_to_bfqg(group_entity) :
 			      bfqq->bfqd->root_group;
 }
 
@@ -610,8 +609,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
 	 */
 	entity = &bfqg->entity;
 	for_each_entity(entity) {
-		struct bfq_group *curr_bfqg = container_of(entity,
-						struct bfq_group, entity);
+		struct bfq_group *curr_bfqg = bfq_entity_to_bfqg(entity);
 		if (curr_bfqg != bfqd->root_group) {
 			parent = bfqg_parent(curr_bfqg);
 			if (!parent)
block/bfq-iosched.h +1 -0
index b8e793c..a6f98e9 100644
@@ -941,6 +941,7 @@ struct bfq_group {
 #endif
 
 struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity);
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity);
 
 /* --------------- main algorithm interface ----------------- */
 
block/bfq-wf2q.c +12 -4
index 070e34a..5ff0028 100644
@@ -149,7 +149,7 @@ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq)
 	if (!group_entity)
 		group_entity = &bfqq->bfqd->root_group->entity;
 
-	return container_of(group_entity, struct bfq_group, entity);
+	return bfq_entity_to_bfqg(group_entity);
 }
 
 /*
@@ -208,7 +208,7 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity)
 	if (bfq_entity_to_bfqq(entity))
 		return true;
 
-	bfqg = container_of(entity, struct bfq_group, entity);
+	bfqg = bfq_entity_to_bfqg(entity);
 
 	/*
 	 * The field active_entities does not always contain the
@@ -266,6 +266,15 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity)
 	return bfqq;
 }
 
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity)
+{
+	struct bfq_group *bfqg = NULL;
+
+	if (entity->my_sched_data)
+		bfqg = container_of(entity, struct bfq_group, entity);
+
+	return bfqg;
+}
 
 /**
  * bfq_delta - map service into the virtual time domain.
@@ -1001,8 +1010,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
 
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
 	if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */
-		struct bfq_group *bfqg =
-			container_of(entity, struct bfq_group, entity);
+		struct bfq_group *bfqg = bfq_entity_to_bfqg(entity);
 		struct bfq_data *bfqd = bfqg->bfqd;
 
 		if (!entity->in_groups_with_pending_reqs) {
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/8 bfq: convert the type of bfq_group.bfqd to bfq_data*

In reply to brookxu

From: Chunguang Xu <[email protected]>

Setting bfq_group.bfqd to void* type does not seem to make much sense. This will cause unnecessary type conversion. Perhaps it would be better to change it to bfq_data* type.

---
 block/bfq-cgroup.c  | 2 +-
 block/bfq-iosched.h | 2 +-
 block/bfq-wf2q.c    | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
block/bfq-cgroup.c +1 -1
index a5f544a..50d06c7 100644
@@ -224,7 +224,7 @@ void bfqg_stats_update_io_add(struct bfq_group *bfqg, struct bfq_queue *bfqq,
 {
 	blkg_rwstat_add(&bfqg->stats.queued, op, 1);
 	bfqg_stats_end_empty_time(&bfqg->stats);
-	if (!(bfqq == ((struct bfq_data *)bfqg->bfqd)->in_service_queue))
+	if (!(bfqq == bfqg->bfqd->in_service_queue))
 		bfqg_stats_set_start_group_wait_time(bfqg, bfqq_group(bfqq));
 }
 
block/bfq-iosched.h +1 -1
index a6f98e9..28d8590 100644
@@ -914,7 +914,7 @@ struct bfq_group {
 	struct bfq_entity entity;
 	struct bfq_sched_data sched_data;
 
-	void *bfqd;
+	struct bfq_data *bfqd;
 
 	struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR];
 	struct bfq_queue *async_idle_bfqq;
block/bfq-wf2q.c +3 -3
index 5ff0028..276f225 100644
@@ -498,7 +498,7 @@ static void bfq_active_insert(struct bfq_service_tree *st,
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
 	sd = entity->sched_data;
 	bfqg = container_of(sd, struct bfq_group, sched_data);
-	bfqd = (struct bfq_data *)bfqg->bfqd;
+	bfqd = bfqg->bfqd;
 #endif
 	if (bfqq)
 		list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list);
@@ -597,7 +597,7 @@ static void bfq_active_extract(struct bfq_service_tree *st,
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
 	sd = entity->sched_data;
 	bfqg = container_of(sd, struct bfq_group, sched_data);
-	bfqd = (struct bfq_data *)bfqg->bfqd;
+	bfqd = bfqg->bfqd;
 #endif
 	if (bfqq)
 		list_del(&bfqq->bfqq_list);
@@ -743,7 +743,7 @@ struct bfq_service_tree *
 		else {
 			sd = entity->my_sched_data;
 			bfqg = container_of(sd, struct bfq_group, sched_data);
-			bfqd = (struct bfq_data *)bfqg->bfqd;
+			bfqd = bfqg->bfqd;
 		}
 #endif
 
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 3/8 bfq: limit the IO depth of CLASS_IDLE to 1

In reply to brookxu

From: Chunguang Xu <[email protected]>

The IO depth of queues belong to CLASS_IDLE is limited to 1, so that it can avoid introducing a larger tail latency under a device with a larger IO depth. Although limiting the IO depth may reduce the performance of idle_class, it is generally not a big problem, because idle_class usually does not have strict performance requirements.

---
 block/bfq-iosched.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
block/bfq-iosched.c +11 -0
index ec482e6..29940ec 100644
@@ -4808,6 +4808,17 @@ static struct request *__bfq_dispatch_request(struct blk_mq_hw_ctx *hctx)
 	if (!bfqq)
 		goto exit;
 
+	/*
+	 * Here, the IO depth of queues belong to CLASS_IDLE is limited
+	 * to 1, so that it can avoid introducing a larger tail latency
+	 * under a device with a larger IO depth. Although limiting the
+	 * IO depth may reduce the performance of idle_class, it is
+	 * generally not a big problem, because idle_class usually
+	 * does not have strict performance requirements.
+	 */
+	if (bfq_class_idle(bfqq) && bfqq->dispatched)
+		goto exit;
+
 	rq = bfq_dispatch_rq_from_bfqq(bfqd, bfqq);
 
 	if (rq) {
Signature · 1 line
1.8.3.1
author
#4 lore raw

PATCH 4/8 bfq: keep the minimun bandwidth for CLASS_BE

In reply to brookxu

From: Chunguang Xu <[email protected]>

CLASS_RT will preempt other classes, which may starve. At present, CLASS_IDLE has alleviated the starvation problem through the minimum bandwidth mechanism. Similarly, we should do the same for CLASS_BE.

---
 block/bfq-iosched.c |  6 ++++--
 block/bfq-iosched.h | 11 ++++++----
 block/bfq-wf2q.c    | 59 ++++++++++++++++++++++++++++++++++++++---------------
 3 files changed, 53 insertions(+), 23 deletions(-)
block/bfq-iosched.c +4 -2
index 29940ec..89d4646 100644
@@ -6537,9 +6537,11 @@ static void bfq_init_root_group(struct bfq_group *root_group,
 	root_group->bfqd = bfqd;
 #endif
 	root_group->rq_pos_tree = RB_ROOT;
-	for (i = 0; i < BFQ_IOPRIO_CLASSES; i++)
+	for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) {
 		root_group->sched_data.service_tree[i] = BFQ_SERVICE_TREE_INIT;
-	root_group->sched_data.bfq_class_idle_last_service = jiffies;
+		root_group->sched_data.bfq_class_last_service[i] = jiffies;
+	}
+	root_group->sched_data.class_timeout_last_check = jiffies;
 }
 
 static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
block/bfq-iosched.h +7 -4
index 28d8590..da636a8 100644
@@ -13,7 +13,7 @@
 #include "blk-cgroup-rwstat.h"
 
 #define BFQ_IOPRIO_CLASSES	3
-#define BFQ_CL_IDLE_TIMEOUT	(HZ/5)
+#define BFQ_CLASS_TIMEOUT	(HZ/5)
 
 #define BFQ_MIN_WEIGHT			1
 #define BFQ_MAX_WEIGHT			1000
@@ -97,9 +97,12 @@ struct bfq_sched_data {
 	struct bfq_entity *next_in_service;
 	/* array of service trees, one per ioprio_class */
 	struct bfq_service_tree service_tree[BFQ_IOPRIO_CLASSES];
-	/* last time CLASS_IDLE was served */
-	unsigned long bfq_class_idle_last_service;
-
+	/* last time the class was served */
+	unsigned long bfq_class_last_service[BFQ_IOPRIO_CLASSES];
+	/* last time class timeout was checked */
+	unsigned long class_timeout_last_check;
+	/* next index to check class timeout */
+	unsigned int next_class_index;
 };
 
 /**
block/bfq-wf2q.c +42 -17

84 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH 5/8 bfq: remove unnecessary initialization logic

In reply to brookxu

From: Chunguang Xu <[email protected]>

Since we will initialize sched_data.service_tree[] in bfq_init_root_group(), bfq_create_group_hierarchy() can ignore this part of the initialization, which can avoid repeated initialization.

---
 block/bfq-cgroup.c | 4 ----
 1 file changed, 4 deletions(-)
block/bfq-cgroup.c +0 -4
index 50d06c7..c8c68dc 100644
@@ -1429,15 +1429,11 @@ void bfqg_and_blkg_put(struct bfq_group *bfqg) {}
 struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node)
 {
 	struct bfq_group *bfqg;
-	int i;
 
 	bfqg = kmalloc_node(sizeof(*bfqg), GFP_KERNEL | __GFP_ZERO, node);
 	if (!bfqg)
 		return NULL;
 
-	for (i = 0; i < BFQ_IOPRIO_CLASSES; i++)
-		bfqg->sched_data.service_tree[i] = BFQ_SERVICE_TREE_INIT;
-
 	return bfqg;
 }
 #endif	/* CONFIG_BFQ_GROUP_IOSCHED */
Signature · 1 line
1.8.3.1
author
#6 lore raw

PATCH 6/8 bfq: optimize the calculation of bfq_weight_to_ioprio()

In reply to brookxu

From: Chunguang Xu <[email protected]>

The value range of ioprio is [0, 7], but the result of bfq_weight_to_ioprio() may exceed this range, so simple optimization is required.

---
 block/bfq-wf2q.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
block/bfq-wf2q.c +3 -2
index 619ed21..ea5b90d 100644
@@ -527,8 +527,9 @@ unsigned short bfq_ioprio_to_weight(int ioprio)
  */
 static unsigned short bfq_weight_to_ioprio(int weight)
 {
-	return max_t(int, 0,
-		     IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF - weight);
+	int ioprio = IOPRIO_BE_NR  - weight / BFQ_WEIGHT_CONVERSION_COEFF;
+
+	return ioprio < 0 ? 0 : min_t(int, ioprio, IOPRIO_BE_NR - 1);
 }
 
 static void bfq_get_entity(struct bfq_entity *entity)
Signature · 1 line
1.8.3.1
author
#7 lore raw

PATCH 7/8 bfq: reset entity->prio_changed in bfq_init_entity()

In reply to brookxu

From: Chunguang Xu <[email protected]>

Since weight, ioprio, ioprio_class will be updated in bfq_init_entity(), st->wsum will be updated in __bfq_activate_entity(), so when it is first active, it seems that __bfq_entity_update_weight_prio() has nothing to do. By resetting entity->prio_change in bfq_init_entity(), we can avoid unnecessary logic calls.

---
 block/bfq-cgroup.c | 1 +
 1 file changed, 1 insertion(+)
block/bfq-cgroup.c +1 -0
index c8c68dc..79a5aaa 100644
@@ -426,6 +426,7 @@ void bfq_init_entity(struct bfq_entity *entity, struct bfq_group *bfqg)
 
 	entity->weight = entity->new_weight;
 	entity->orig_weight = entity->new_weight;
+	entity->prio_changed = 0;
 	if (bfqq) {
 		bfqq->ioprio = bfqq->new_ioprio;
 		bfqq->ioprio_class = bfqq->new_ioprio_class;
Signature · 1 line
1.8.3.1
author
#8 lore raw

PATCH 8/8 bfq: remove unnecessary BFQ_DEFAULT_GRP_IOPRIO

In reply to brookxu

From: Chunguang Xu <[email protected]>

BFQ_DEFAULT_GRP_IOPRIO seems to be unused, maybe we can remove it.

---
 block/bfq-iosched.h | 1 -
 1 file changed, 1 deletion(-)
block/bfq-iosched.h +0 -1
index da636a8..91c8654 100644
@@ -22,7 +22,6 @@
 #define BFQ_DEFAULT_QUEUE_IOPRIO	4
 
 #define BFQ_WEIGHT_LEGACY_DFL	100
-#define BFQ_DEFAULT_GRP_IOPRIO	0
 #define BFQ_DEFAULT_GRP_CLASS	IOPRIO_CLASS_BE
 
 #define MAX_PID_STR_LENGTH 12
Signature · 1 line
1.8.3.1

A message that is not in the archive (sent off-list or not yet received): 20210610072230.TAxxdh-wsL4sihK2TJxF-Gz85ZgsFR7IwOuifnxFi0k@z

#10 lore raw

Re: [RESEND PATCH 1/8] bfq: introduce bfq_entity_to_bfqg helper method

Hello.

Quoted 99 lines · brookxu

From: Chunguang Xu <[email protected]>

Introduce bfq_entity_to_bfqg() to make it easier to obtain the bfq_group corresponding to the entity.

---
 block/bfq-cgroup.c  |  6 ++----
 block/bfq-iosched.h |  1 +
 block/bfq-wf2q.c    | 16 ++++++++++++----
 3 files changed, 15 insertions(+), 8 deletions(-)
block/bfq-cgroup.c +2 -4
index b791e20..a5f544a 100644
@@ -309,8 +309,7 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
 {
 	struct bfq_entity *group_entity = bfqq->entity.parent;
 
-	return group_entity ? container_of(group_entity, struct bfq_group,
-					   entity) :
+	return group_entity ? bfq_entity_to_bfqg(group_entity) :
 			      bfqq->bfqd->root_group;
 }
 
@@ -610,8 +609,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
 	 */
 	entity = &bfqg->entity;
 	for_each_entity(entity) {
-		struct bfq_group *curr_bfqg = container_of(entity,
-						struct bfq_group, entity);
+		struct bfq_group *curr_bfqg = bfq_entity_to_bfqg(entity);
 		if (curr_bfqg != bfqd->root_group) {
 			parent = bfqg_parent(curr_bfqg);
 			if (!parent)
block/bfq-iosched.h +1 -0
index b8e793c..a6f98e9 100644
@@ -941,6 +941,7 @@ struct bfq_group {
 #endif
 
 struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity);
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity);
 
 /* --------------- main algorithm interface ----------------- */
 
block/bfq-wf2q.c +12 -4
index 070e34a..5ff0028 100644
@@ -149,7 +149,7 @@ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq)
 	if (!group_entity)
 		group_entity = &bfqq->bfqd->root_group->entity;
 
-	return container_of(group_entity, struct bfq_group, entity);
+	return bfq_entity_to_bfqg(group_entity);
 }
 
 /*
@@ -208,7 +208,7 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity)
 	if (bfq_entity_to_bfqq(entity))
 		return true;
 
-	bfqg = container_of(entity, struct bfq_group, entity);
+	bfqg = bfq_entity_to_bfqg(entity);
 
 	/*
 	 * The field active_entities does not always contain the
@@ -266,6 +266,15 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity)
 	return bfqq;
 }
 
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity)
+{
+	struct bfq_group *bfqg = NULL;
+
+	if (entity->my_sched_data)
+		bfqg = container_of(entity, struct bfq_group, entity);
+
+	return bfqg;
+}
 
 /**
  * bfq_delta - map service into the virtual time domain.
@@ -1001,8 +1010,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
 
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
 	if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */
-		struct bfq_group *bfqg =
-			container_of(entity, struct bfq_group, entity);
+		struct bfq_group *bfqg = bfq_entity_to_bfqg(entity);
 		struct bfq_data *bfqd = bfqg->bfqd;
 
 		if (!entity->in_groups_with_pending_reqs) {
Signature · 1 line
1.8.3.1

If it is a resend only, I can offer my Tested-by since I'm running this series for quite some time already.

Thanks.

Signature · 1 line
  Oleksandr Natalenko (post-factum)
author
#11 lore raw

Re: [RESEND PATCH 1/8] bfq: introduce bfq_entity_to_bfqg helper method

Oleksandr Natalenko wrote on 2021/6/10 16:31:

Quoted 98 lines

Hello.

Quoted 95 lines · brookxu

From: Chunguang Xu <[email protected]>

Introduce bfq_entity_to_bfqg() to make it easier to obtain the bfq_group corresponding to the entity.

---
 block/bfq-cgroup.c  |  6 ++----
 block/bfq-iosched.h |  1 +
 block/bfq-wf2q.c    | 16 ++++++++++++----
 3 files changed, 15 insertions(+), 8 deletions(-)
block/bfq-cgroup.c +2 -4
index b791e20..a5f544a 100644
@@ -309,8 +309,7 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
 {
 	struct bfq_entity *group_entity = bfqq->entity.parent;
 
-	return group_entity ? container_of(group_entity, struct bfq_group,
-					   entity) :
+	return group_entity ? bfq_entity_to_bfqg(group_entity) :
 			      bfqq->bfqd->root_group;
 }
 
@@ -610,8 +609,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
 	 */
 	entity = &bfqg->entity;
 	for_each_entity(entity) {
-		struct bfq_group *curr_bfqg = container_of(entity,
-						struct bfq_group, entity);
+		struct bfq_group *curr_bfqg = bfq_entity_to_bfqg(entity);
 		if (curr_bfqg != bfqd->root_group) {
 			parent = bfqg_parent(curr_bfqg);
 			if (!parent)
block/bfq-iosched.h +1 -0
index b8e793c..a6f98e9 100644
@@ -941,6 +941,7 @@ struct bfq_group {
 #endif
 
 struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity);
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity);
 
 /* --------------- main algorithm interface ----------------- */
 
block/bfq-wf2q.c +12 -4
index 070e34a..5ff0028 100644
@@ -149,7 +149,7 @@ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq)
 	if (!group_entity)
 		group_entity = &bfqq->bfqd->root_group->entity;
 
-	return container_of(group_entity, struct bfq_group, entity);
+	return bfq_entity_to_bfqg(group_entity);
 }
 
 /*
@@ -208,7 +208,7 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity)
 	if (bfq_entity_to_bfqq(entity))
 		return true;
 
-	bfqg = container_of(entity, struct bfq_group, entity);
+	bfqg = bfq_entity_to_bfqg(entity);
 
 	/*
 	 * The field active_entities does not always contain the
@@ -266,6 +266,15 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity)
 	return bfqq;
 }
 
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity)
+{
+	struct bfq_group *bfqg = NULL;
+
+	if (entity->my_sched_data)
+		bfqg = container_of(entity, struct bfq_group, entity);
+
+	return bfqg;
+}
 
 /**
  * bfq_delta - map service into the virtual time domain.
@@ -1001,8 +1010,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
 
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
 	if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */
-		struct bfq_group *bfqg =
-			container_of(entity, struct bfq_group, entity);
+		struct bfq_group *bfqg = bfq_entity_to_bfqg(entity);
 		struct bfq_data *bfqd = bfqg->bfqd;
 
Quoted 8 lines
Quoted 4 lines
block/bfq-wf2q.c +0 -0
 		if (!entity->in_groups_with_pending_reqs) {
Signature · 1 line
1.8.3.1

If it is a resend only, I can offer my Tested-by since I'm running this series for quite some time already.

ok, thank you very much.

Quoted 2 lines

Thanks.

Tested-by
#12 lore raw

Re: [RESEND PATCH 1/8] bfq: introduce bfq_entity_to_bfqg helper method

In reply to Oleksandr Natalenko

I have been testing this since the first release and have not noticed any irregularities.

czw., 10 cze 2021 o 10:31 Oleksandr Natalenko
<[email protected]> napisał(a):

Quoted 111 lines

Hello.

Quoted 97 lines · brookxu

From: Chunguang Xu <[email protected]>

Introduce bfq_entity_to_bfqg() to make it easier to obtain the bfq_group corresponding to the entity.

---
 block/bfq-cgroup.c  |  6 ++----
 block/bfq-iosched.h |  1 +
 block/bfq-wf2q.c    | 16 ++++++++++++----
 3 files changed, 15 insertions(+), 8 deletions(-)
block/bfq-cgroup.c +2 -4
index b791e20..a5f544a 100644
@@ -309,8 +309,7 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
 {
      struct bfq_entity *group_entity = bfqq->entity.parent;
 
-     return group_entity ? container_of(group_entity, struct bfq_group,
-                                        entity) :
+     return group_entity ? bfq_entity_to_bfqg(group_entity) :
                            bfqq->bfqd->root_group;
 }
 
@@ -610,8 +609,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
       */
      entity = &bfqg->entity;
      for_each_entity(entity) {
-             struct bfq_group *curr_bfqg = container_of(entity,
-                                             struct bfq_group, entity);
+             struct bfq_group *curr_bfqg = bfq_entity_to_bfqg(entity);
              if (curr_bfqg != bfqd->root_group) {
                      parent = bfqg_parent(curr_bfqg);
                      if (!parent)
block/bfq-iosched.h +1 -0
index b8e793c..a6f98e9 100644
@@ -941,6 +941,7 @@ struct bfq_group {
 #endif
 
 struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity);
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity);
 
 /* --------------- main algorithm interface ----------------- */
 
block/bfq-wf2q.c +12 -5
index 070e34a..5ff0028 100644
@@ -149,7 +149,7 @@ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq)
      if (!group_entity)
              group_entity = &bfqq->bfqd->root_group->entity;
 
-     return container_of(group_entity, struct bfq_group, entity);
+     return bfq_entity_to_bfqg(group_entity);
 }
 
 /*
@@ -208,7 +208,7 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity)
      if (bfq_entity_to_bfqq(entity))
              return true;
 
-     bfqg = container_of(entity, struct bfq_group, entity);
+     bfqg = bfq_entity_to_bfqg(entity);
 
      /*
       * The field active_entities does not always contain the
@@ -266,6 +266,15 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity)
      return bfqq;
 }
 
+struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity)
+{
+     struct bfq_group *bfqg = NULL;
+
+     if (entity->my_sched_data)
+             bfqg = container_of(entity, struct bfq_group, entity);
+
+     return bfqg;
+}
 
 /**
  * bfq_delta - map service into the virtual time domain.
@@ -1001,8 +1010,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
 
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
      if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */
-             struct bfq_group *bfqg =
-                     container_of(entity, struct bfq_group, entity);
+             struct bfq_group *bfqg = bfq_entity_to_bfqg(entity);
              struct bfq_data *bfqd = bfqg->bfqd;
 
              if (!entity->in_groups_with_pending_reqs) {
--
Quoted 2 lines

1.8.3.1

If it is a resend only, I can offer my Tested-by since I'm running this series for quite some time already.

Thanks.

--
Oleksandr Natalenko (post-factum)