[1/2] sched/rt: Introduce for_each_sched_rt_entity_back() & use it

Message ID 20231005162317.3343678-2-yajun.deng@linux.dev
State New
Headers
Series Move sched_rt_entity::back to RT_GROUP_SCHED |

Commit Message

Yajun Deng Oct. 5, 2023, 4:23 p.m. UTC
  The member back in struct sched_rt_entity only related to RT_GROUP_SCHED,
it should not place out of RT_GROUP_SCHED.

Introduce for_each_sched_rt_entity_back() & use it, it safe move back to
under the CONFIG_RT_GROUP_SCHED in next patch.

No functional changes.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 kernel/sched/rt.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Patch

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 88fc98601413..642edbd24ffb 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -520,6 +520,9 @@  static inline struct task_group *next_task_group(struct task_group *tg)
 #define for_each_sched_rt_entity(rt_se) \
 	for (; rt_se; rt_se = rt_se->parent)
 
+#define for_each_sched_rt_entity_back(rt_se) \
+	for (; rt_se; rt_se = rt_se->back)
+
 static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se)
 {
 	return rt_se->my_q;
@@ -625,6 +628,9 @@  typedef struct rt_rq *rt_rq_iter_t;
 #define for_each_sched_rt_entity(rt_se) \
 	for (; rt_se; rt_se = NULL)
 
+#define for_each_sched_rt_entity_back(rt_se) \
+	for_each_sched_rt_entity(rt_se)
+
 static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se)
 {
 	return NULL;
@@ -1445,7 +1451,8 @@  static void dequeue_rt_stack(struct sched_rt_entity *rt_se, unsigned int flags)
 
 	rt_nr_running = rt_rq_of_se(back)->rt_nr_running;
 
-	for (rt_se = back; rt_se; rt_se = rt_se->back) {
+	rt_se = back;
+	for_each_sched_rt_entity_back(rt_se) {
 		if (on_rt_rq(rt_se))
 			__dequeue_rt_entity(rt_se, flags);
 	}