sched/rt.c: use list_is_singular() instead of '->prev != ->next'
PATCH 1/1 sched/rt.c: use list_is_singular() instead of '->prev != ->next'
Use the list_is_singular(&rt_se->run_list) api instead of 'rt_se->run_list.prev != rt_se->run_list.next'. Fix a comment by the way, and make the comment more clearly.
--- kernel/sched/rt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sched/rt.c +4 -4
@@ -2381,7 +2381,7 @@ static inline void watchdog(struct rq *rq, struct task_struct *p) { }* * NOTE: This function can be called remotely by the tick offload that * goes along full dynticks. Therefore no local assumption can be made -* and everything must be accessed through the @rq and @curr passed in +* and everything must be accessed through the @rq and @p passed in * parameters. */ static void task_tick_rt (struct rq *rq,struct task_struct *p,int queued)
@@ -2406,11 +2406,11 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued) p->rt.time_slice = sched_rr_timeslice;/* -* Requeue to the end of queue if we (and all of our ancestors) are not -* the only element on the queue +* Requeue to the end of rt_prio_array queue if we (and all of our +* ancestors) are not the only element on the rt_prio_array queue. */ for_each_sched_rt_entity (rt_se) { -if (rt_se->run_list.prev != rt_se->run_list.next) { +if (!list_is_singular (&rt_se->run_list)) {requeue_task_rt (rq, p,0 );resched_curr (rq);return ;
Signature · 1 line
2.25.1
Steven Rostedt
reviewerQuoted 24 lines · On Tue, 27 Oct 2020 01:41:52 +0800 Hui Su <[email protected]> wrote:
Use the
list_is_singular(&rt_se->run_list)api instead of 'rt_se->run_list.prev!=rt_se->run_list.next'. Fix a comment by the way, and make the comment more clearly.Signed-off-by Hui Su <[email protected]>--- kernel/sched/rt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)kernel/sched/rt.c +1
-1@@ -2381,7 +2381,7 @@ static inline void watchdog(struct rq *rq, struct task_struct *p) { }* * NOTE: This function can be called remotely by the tick offload that * goes along full dynticks. Therefore no local assumption can be made -* and everything must be accessed through the @rq and @curr passed in +* and everything must be accessed through the @rq and @p passed in * parameters. */ static void task_tick_rt (struct rq *rq,struct task_struct *p,int queued)@@ -2406,11 +2406,11 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued) p->rt.time_slice = sched_rr_timeslice;
kernel/sched/rt.c static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued) · line 2413
Quoted 10 lines
kernel/sched/rt.c +3
-3/* -* Requeue to the end of queue if we (and all of our ancestors) are not -* the only element on the queue +* Requeue to the end of rt_prio_array queue if we (and all of our +* ancestors) are not the only element on the rt_prio_array queue. */ for_each_sched_rt_entity (rt_se) { -if (rt_se->run_list.prev != rt_se->run_list.next) { +if (!list_is_singular (&rt_se->run_list)) {
Perhaps there should be a list_has_more_than_one() API, as list_is_singular requires two checks, and the "more_than_one" only requires a single check.
list_is_singular() is:
return !list_empty(list) && (list->next == list->prev);
which is more work than what you are replacing.
-- Steve
Quoted 3 lines
kernel/sched/rt.c +0
-0requeue_task_rt (rq, p,0 );resched_curr (rq);return ;
Quoted 10 lines
Perhaps there should be a
list_has_more_than_one()API, aslist_is_singularrequires two checks, and the "more_than_one" only requires a single check.
list_is_singular()is:return !list_empty(list) && (list->next == list->prev);which is more work than what you are replacing.
Hi, Steve:
Thanks for your explanation.
Maybe we should add another api called "list_more_than_one" just without list_empty() check.
I will send PATCH V2 later.
Thank.