Skip to contentSkip to conversation

sched/deadline: Replace rq_of_dl_rq(dl_rq_of_se(dl_se)) with ... ...task_rq(dl_task_of(dl_se))

PATCH In review Qi Zheng 2 participants 3 messages Oct 13, 2020 – Oct 14, 2020 Scheduler

lore
Share & tools
lore

Qi Zheng

author
#0 lore raw

PATCH 1/1 sched/deadline: Replace rq_of_dl_rq(dl_rq_of_se(dl_se)) with ... ...task_rq(dl_task_of(dl_se))

The rq is already obtained in the dl_rq_of_se() function:

	struct task_struct *p = dl_task_of(dl_se);
        struct rq *rq = task_rq(p);

So there is no need to do extra conversion.

---
 kernel/sched/deadline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/deadline.c +2 -2
index 6d93f4518734..f64e577f6aba 100644
@@ -1152,7 +1152,7 @@ void init_dl_task_timer(struct sched_dl_entity *dl_se)
 static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se)
 {
 	struct task_struct *p = dl_task_of(dl_se);
-	struct rq *rq = rq_of_dl_rq(dl_rq_of_se(dl_se));
+	struct rq *rq = task_rq(p);
 
 	if (dl_time_before(dl_se->deadline, rq_clock(rq)) &&
 	    dl_time_before(rq_clock(rq), dl_next_period(dl_se))) {
@@ -1498,7 +1498,7 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se,
 		replenish_dl_entity(dl_se, pi_se);
 	} else if ((flags & ENQUEUE_RESTORE) &&
 		  dl_time_before(dl_se->deadline,
-				 rq_clock(rq_of_dl_rq(dl_rq_of_se(dl_se))))) {
+				 rq_clock(task_rq(dl_task_of(dl_se))))) {
 		setup_new_dl_entity(dl_se);
 	}
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 24 lines · Qi Zheng

The rq is already obtained in the dl_rq_of_se() function:

	struct task_struct *p = dl_task_of(dl_se);
        struct rq *rq = task_rq(p);

So there is no need to do extra conversion.

---
 kernel/sched/deadline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/deadline.c +1 -1
index 6d93f4518734..f64e577f6aba 100644
@@ -1152,7 +1152,7 @@ void init_dl_task_timer(struct sched_dl_entity *dl_se)
 static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se)
 {
 	struct task_struct *p = dl_task_of(dl_se);
-	struct rq *rq = rq_of_dl_rq(dl_rq_of_se(dl_se));
+	struct rq *rq = task_rq(p);
 
 	if (dl_time_before(dl_se->deadline, rq_clock(rq)) &&
 	    dl_time_before(rq_clock(rq), dl_next_period(dl_se))) {

kernel/sched/deadline.c enqueue_dl_entity(struct sched_dl_entity *dl_se, · line 1503

Quoted 7 lines
kernel/sched/deadline.c +1 -1
@@ -1498,7 +1498,7 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se,
 		replenish_dl_entity(dl_se, pi_se);
 	} else if ((flags & ENQUEUE_RESTORE) &&
 		  dl_time_before(dl_se->deadline,
-				 rq_clock(rq_of_dl_rq(dl_rq_of_se(dl_se))))) {
+				 rq_clock(task_rq(dl_task_of(dl_se))))) {
 		setup_new_dl_entity(dl_se);
 	}

Consider where we're going:

https://lkml.kernel.org/r/[email protected]

then a dl_entity is no longer immediately a task and the above is no longer true.

author
#2 lore raw
Quoted 35 lines · Peter Zijlstra
Quoted 24 lines · Qi Zheng

The rq is already obtained in the dl_rq_of_se() function:
struct task_struct *p = dl_task_of(dl_se); struct rq *rq = task_rq(p);
So there is no need to do extra conversion.

---
kernel/sched/deadline.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/deadline.c +1 -1
index 6d93f4518734..f64e577f6aba 100644
@@ -1152,7 +1152,7 @@ void init_dl_task_timer(struct sched_dl_entity *dl_se)
 static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se)
 {
 struct task_struct *p = dl_task_of(dl_se);
- struct rq *rq = rq_of_dl_rq(dl_rq_of_se(dl_se));
+ struct rq *rq = task_rq(p);
 

if (dl_time_before(dl_se->deadline, rq_clock(rq)) && dl_time_before(rq_clock(rq), dl_next_period(dl_se))) {

kernel/sched/deadline.c enqueue_dl_entity(struct sched_dl_entity *dl_se, · line 1503

Quoted 7 lines
kernel/sched/deadline.c +1 -1
@@ -1498,7 +1498,7 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se,
 replenish_dl_entity(dl_se, pi_se);
 } else if ((flags & ENQUEUE_RESTORE) &&
 dl_time_before(dl_se->deadline,
- rq_clock(rq_of_dl_rq(dl_rq_of_se(dl_se))))) {
+ rq_clock(task_rq(dl_task_of(dl_se))))) {
 setup_new_dl_entity(dl_se);
 }

Consider where we're going:

Quoted 5 lines

https://lkml.kernel.org/r/[email protected]

then a dl_entity is no longer immediately a task and the above is no longer true.

Thanks for your reply, I saw in the patch below that the dl_rq_of_se() has been changed to the rq_of_dl_se(), so the above is no longer needed.

[RFC PATCH v2 4/6] sched/deadline: Introduce deadline servers

In addition, when will the SCHED_DEADLINE server infrastructure is expected to be integrated into the mainline? It looks great!

Quoted 40 lines · Peter Zijlstra <[email protected]> 于2020年10月13日周二 下午11:48写道:
Quoted 24 lines · Qi Zheng

The rq is already obtained in the dl_rq_of_se() function:

      struct task_struct *p = dl_task_of(dl_se);
        struct rq *rq = task_rq(p);

So there is no need to do extra conversion.

---
 kernel/sched/deadline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/deadline.c +1 -1
index 6d93f4518734..f64e577f6aba 100644
@@ -1152,7 +1152,7 @@ void init_dl_task_timer(struct sched_dl_entity *dl_se)
 static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se)
 {
      struct task_struct *p = dl_task_of(dl_se);
-     struct rq *rq = rq_of_dl_rq(dl_rq_of_se(dl_se));
+     struct rq *rq = task_rq(p);
 
      if (dl_time_before(dl_se->deadline, rq_clock(rq)) &&
          dl_time_before(rq_clock(rq), dl_next_period(dl_se))) {

kernel/sched/deadline.c enqueue_dl_entity(struct sched_dl_entity *dl_se, · line 1503

Quoted 7 lines
kernel/sched/deadline.c +1 -1
@@ -1498,7 +1498,7 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se,
              replenish_dl_entity(dl_se, pi_se);
      } else if ((flags & ENQUEUE_RESTORE) &&
                dl_time_before(dl_se->deadline,
-                              rq_clock(rq_of_dl_rq(dl_rq_of_se(dl_se))))) {
+                              rq_clock(task_rq(dl_task_of(dl_se))))) {
              setup_new_dl_entity(dl_se);
      }

Consider where we're going:

https://lkml.kernel.org/r/[email protected]

then a dl_entity is no longer immediately a task and the above is no longer true.