[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211127101132.486806-2-yukuai3@huawei.com>
Date: Sat, 27 Nov 2021 18:11:24 +0800
From: Yu Kuai <yukuai3@...wei.com>
To: <tj@...nel.org>, <axboe@...nel.dk>, <paolo.valente@...aro.org>
CC: <cgroups@...r.kernel.org>, <linux-block@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <yukuai3@...wei.com>,
<yi.zhang@...wei.com>
Subject: [PATCH RFC 1/9] block, bfq: add new apis to iterate bfq entities
The old and the new apis are the same currently, prepare to count
root group into 'num_groups_with_pending_reqs'. The old apis will be
used to iterate with root group's entity, and the new apis will be
used to iterate without root group's entity.
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
block/bfq-iosched.h | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index a73488eec8a4..f5afc80ff11c 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -1034,9 +1034,20 @@ extern struct blkcg_policy blkcg_policy_bfq;
#define for_each_entity_safe(entity, parent) \
for (; entity && ({ parent = entity->parent; 1; }); entity = parent)
+#define is_root_entity(entity) \
+ (entity->sched_data == NULL)
+
+#define for_each_entity_not_root(entity) \
+ for (; entity && !is_root_entity(entity); entity = entity->parent)
+
+#define for_each_entity_not_root_safe(entity, parent) \
+ for (; entity && !is_root_entity(entity) && \
+ ({ parent = entity->parent; 1; }); entity = parent)
#else /* CONFIG_BFQ_GROUP_IOSCHED */
+#define is_root_entity(entity) (false)
+
/*
- * Next two macros are fake loops when cgroups support is not
+ * Next four macros are fake loops when cgroups support is not
* enabled. I fact, in such a case, there is only one level to go up
* (to reach the root group).
*/
@@ -1045,6 +1056,12 @@ extern struct blkcg_policy blkcg_policy_bfq;
#define for_each_entity_safe(entity, parent) \
for (parent = NULL; entity ; entity = parent)
+
+#define for_each_entity_not_root(entity) \
+ for (; entity ; entity = NULL)
+
+#define for_each_entity_not_root_safe(entity, parent) \
+ for (parent = NULL; entity ; entity = parent)
#endif /* CONFIG_BFQ_GROUP_IOSCHED */
struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq);
--
2.31.1
Powered by blists - more mailing lists