sched/rt: move back to RT_GROUP_SCHED and rename it child
PATCH 1/1 sched/rt: move back to RT_GROUP_SCHED and rename it child
The member back in struct sched_rt_entity only related to RT_GROUP_SCHED, it should not place out of RT_GROUP_SCHED, move back to RT_GROUP_SCHED and rename it child.
Init child in init_tg_rt_entry(). Also, remove the case parent is NULL because this case is the same as rt_se is NULL and already returned.
Introduce for_each_sched_rt_entity_reverse() to iterate entries from top to down.
--- include/linux/sched.h | 2 +- kernel/sched/rt.c | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-)
include/linux/sched.h +1 -1
@@ -594,8 +594,8 @@ struct sched_rt_entity {unsigned short on_rq;unsigned short on_list; -struct sched_rt_entity *back;#ifdef CONFIG_RT_GROUP_SCHED +struct sched_rt_entity *child;struct sched_rt_entity *parent;/* rq on which this entity is (to be) queued: */ struct rt_rq *rt_rq;
kernel/sched/rt.c +15 -13
@@ -228,13 +228,10 @@ void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,if (!rt_se)return ; -if (!parent) - rt_se->rt_rq = &rq->rt; -else - rt_se->rt_rq = parent->my_q; - + rt_se->rt_rq = parent->my_q; rt_se->my_q = rt_rq; rt_se->parent = parent; + parent->child = rt_se;INIT_LIST_HEAD (&rt_se->run_list); }
@@ -564,6 +561,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_reverse (rt_se) \ + for (; rt_se; rt_se = rt_se->child) +static inline struct rt_rq *group_rt_rq (struct sched_rt_entity *rt_se) {return rt_se->my_q;
@@ -669,6 +669,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_reverse (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 ;
@@ -1481,22 +1484,21 @@ static void __dequeue_rt_entity(struct sched_rt_entity *rt_se, unsigned int flag*/ static void dequeue_rt_stack (struct sched_rt_entity *rt_se,unsigned int flags) { -struct sched_rt_entity *back =NULL ; +struct sched_rt_entity *parent =NULL ;unsigned int rt_nr_running; -for_each_sched_rt_entity (rt_se) { - rt_se->back = back; - back = rt_se; - } +for_each_sched_rt_entity (rt_se) + parent = rt_se; - rt_nr_running =rt_rq_of_se (back)->rt_nr_running; + rt_nr_running =rt_rq_of_se (parent)->rt_nr_running; -for (rt_se = back; rt_se; rt_se = rt_se->back) { + rt_se = parent; +for_each_sched_rt_entity_reverse (rt_se) {if (on_rt_rq (rt_se))__dequeue_rt_entity (rt_se, flags); } -dequeue_top_rt_rq (rt_rq_of_se (back), rt_nr_running); +dequeue_top_rt_rq (rt_rq_of_se (parent), rt_nr_running); }static void enqueue_rt_entity (struct sched_rt_entity *rt_se,unsigned int flags)
Signature · 1 line
2.25.1
Steven Rostedt
reviewerkernel/sched/rt.c void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, · line 231
Quoted 10 lines · On Tue, 1 Aug 2023 14:27:14 +0800 Yajun Deng <[email protected]> wrote:
kernel/sched/rt.c +1
-5@@ -228,13 +228,10 @@ void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,if (!rt_se)return ; -if (!parent) - rt_se->rt_rq = &rq->rt; -else - rt_se->rt_rq = parent->my_q; - + rt_se->rt_rq = parent->my_q;
So when this is called with parent = NULL, this will crash?
-- Steve
Quoted 6 lines
kernel/sched/rt.c +1
-0rt_se->my_q = rt_rq; rt_se->parent = parent; + parent->child = rt_se;INIT_LIST_HEAD (&rt_se->run_list); }
Steven Rostedt
reviewerQuoted 6 lines · On Tue, 1 Aug 2023 10:00:30 -0400 Steven Rostedt <[email protected]> wrote:
kernel/sched/rt.c void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, · line 229
Quoted 3 lines · On Tue, 1 Aug 2023 14:27:14 +0800 Yajun Deng <[email protected]> wrote:
kernel/sched/rt.c +0
-0@@ -228,13 +228,10 @@ void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,if (!rt_se)return ;
Ah, I missed the second part of your change log where you said parent is only NULL when rt_se is NULL.
I would then add:
if (!rt_se) return; if (WARN_ON_ONCE(!parent)) return;
-- Steve
Quoted 18 lines
kernel/sched/rt.c void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, · line 231
Quoted 7 lines
kernel/sched/rt.c +1
-5-if (!parent) - rt_se->rt_rq = &rq->rt; -else - rt_se->rt_rq = parent->my_q; - + rt_se->rt_rq = parent->my_q;So when this is called with parent = NULL, this will crash?
-- Steve
Quoted 6 lines
kernel/sched/rt.c +1
-0rt_se->my_q = rt_rq; rt_se->parent = parent; + parent->child = rt_se;INIT_LIST_HEAD (&rt_se->run_list); }