[PATCH 2/3] sched/deadline: avoid redundant check for boosted task

Wander Lairson Costa posted 3 patches 1 year, 6 months ago
There is a newer version of this series
[PATCH 2/3] sched/deadline: avoid redundant check for boosted task
Posted by Wander Lairson Costa 1 year, 6 months ago
enqueue_dl_entity only calls setup_new_dl_entity if the task is not
boosted, so the WARN_ON check is unnecessary.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
---
 kernel/sched/deadline.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 312e8fa7ce94..908d5ce79425 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -785,12 +785,11 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se,
  * one, and to (try to!) reconcile itself with its own scheduling
  * parameters.
  */
-static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
+static inline void __setup_new_dl_entity(struct sched_dl_entity *dl_se)
 {
 	struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
 	struct rq *rq = rq_of_dl_rq(dl_rq);
 
-	WARN_ON(is_dl_boosted(dl_se));
 	WARN_ON(dl_time_before(rq_clock(rq), dl_se->deadline));
 
 	/*
@@ -809,6 +808,12 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
 	replenish_dl_new_period(dl_se, rq);
 }
 
+static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
+{
+	WARN_ON(is_dl_boosted(dl_se));
+	__setup_new_dl_entity(dl_se);
+}
+
 /*
  * Pure Earliest Deadline First (EDF) scheduling does not deal with the
  * possibility of a entity lasting more than what it declared, and thus
@@ -1755,7 +1760,7 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags)
 	} else if ((flags & ENQUEUE_RESTORE) &&
 		   !is_dl_boosted(dl_se) &&
 		   dl_time_before(dl_se->deadline, rq_clock(rq_of_dl_se(dl_se)))) {
-		setup_new_dl_entity(dl_se);
+		__setup_new_dl_entity(dl_se);
 	}
 
 	__enqueue_dl_entity(dl_se);
-- 
2.45.2
Re: [PATCH 2/3] sched/deadline: avoid redundant check for boosted task
Posted by Juri Lelli 1 year, 6 months ago
Hi Wander,

On 22/07/24 10:29, Wander Lairson Costa wrote:
> enqueue_dl_entity only calls setup_new_dl_entity if the task is not
> boosted, so the WARN_ON check is unnecessary.
> 
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>
> ---
>  kernel/sched/deadline.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 312e8fa7ce94..908d5ce79425 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -785,12 +785,11 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se,
>   * one, and to (try to!) reconcile itself with its own scheduling
>   * parameters.
>   */
> -static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> +static inline void __setup_new_dl_entity(struct sched_dl_entity *dl_se)
>  {
>  	struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
>  	struct rq *rq = rq_of_dl_rq(dl_rq);
>  
> -	WARN_ON(is_dl_boosted(dl_se));
>  	WARN_ON(dl_time_before(rq_clock(rq), dl_se->deadline));
>  
>  	/*
> @@ -809,6 +808,12 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
>  	replenish_dl_new_period(dl_se, rq);
>  }
>  
> +static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> +{
> +	WARN_ON(is_dl_boosted(dl_se));
> +	__setup_new_dl_entity(dl_se);
> +}
> +

So, the other call path is from dl_server_start() and for this we know
the entity is not boosted either. We could probably just remove the
WARN_ON w/o the additional wrapper function. That said, considering it's
not fast path, I wonder if we actually want to leave the WARN_ON where
it is, so that we can catch potential future erroneous usages?

Thanks,
Juri
Re: [PATCH 2/3] sched/deadline: avoid redundant check for boosted task
Posted by Wander Lairson Costa 1 year, 6 months ago
On Tue, Jul 23, 2024 at 5:55 AM Juri Lelli <juri.lelli@redhat.com> wrote:
>
> Hi Wander,
>
> On 22/07/24 10:29, Wander Lairson Costa wrote:
> > enqueue_dl_entity only calls setup_new_dl_entity if the task is not
> > boosted, so the WARN_ON check is unnecessary.
> >
> > Signed-off-by: Wander Lairson Costa <wander@redhat.com>
> > ---
> >  kernel/sched/deadline.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> > index 312e8fa7ce94..908d5ce79425 100644
> > --- a/kernel/sched/deadline.c
> > +++ b/kernel/sched/deadline.c
> > @@ -785,12 +785,11 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se,
> >   * one, and to (try to!) reconcile itself with its own scheduling
> >   * parameters.
> >   */
> > -static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> > +static inline void __setup_new_dl_entity(struct sched_dl_entity *dl_se)
> >  {
> >       struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
> >       struct rq *rq = rq_of_dl_rq(dl_rq);
> >
> > -     WARN_ON(is_dl_boosted(dl_se));
> >       WARN_ON(dl_time_before(rq_clock(rq), dl_se->deadline));
> >
> >       /*
> > @@ -809,6 +808,12 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> >       replenish_dl_new_period(dl_se, rq);
> >  }
> >
> > +static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> > +{
> > +     WARN_ON(is_dl_boosted(dl_se));
> > +     __setup_new_dl_entity(dl_se);
> > +}
> > +
>
> So, the other call path is from dl_server_start() and for this we know
> the entity is not boosted either. We could probably just remove the
> WARN_ON w/o the additional wrapper function. That said, considering it's
> not fast path, I wonder if we actually want to leave the WARN_ON where
> it is, so that we can catch potential future erroneous usages?
>

Yeah, if you feel the patch is not worth it, I am more in favor of
dropping the patch than removing the WARN_ON.

> Thanks,
> Juri
>
Re: [PATCH 2/3] sched/deadline: avoid redundant check for boosted task
Posted by Juri Lelli 1 year, 6 months ago
On 23/07/24 09:27, Wander Lairson Costa wrote:
> On Tue, Jul 23, 2024 at 5:55 AM Juri Lelli <juri.lelli@redhat.com> wrote:
> >
> > Hi Wander,
> >
> > On 22/07/24 10:29, Wander Lairson Costa wrote:
> > > enqueue_dl_entity only calls setup_new_dl_entity if the task is not
> > > boosted, so the WARN_ON check is unnecessary.
> > >
> > > Signed-off-by: Wander Lairson Costa <wander@redhat.com>
> > > ---
> > >  kernel/sched/deadline.c | 11 ++++++++---
> > >  1 file changed, 8 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> > > index 312e8fa7ce94..908d5ce79425 100644
> > > --- a/kernel/sched/deadline.c
> > > +++ b/kernel/sched/deadline.c
> > > @@ -785,12 +785,11 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se,
> > >   * one, and to (try to!) reconcile itself with its own scheduling
> > >   * parameters.
> > >   */
> > > -static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> > > +static inline void __setup_new_dl_entity(struct sched_dl_entity *dl_se)
> > >  {
> > >       struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
> > >       struct rq *rq = rq_of_dl_rq(dl_rq);
> > >
> > > -     WARN_ON(is_dl_boosted(dl_se));
> > >       WARN_ON(dl_time_before(rq_clock(rq), dl_se->deadline));
> > >
> > >       /*
> > > @@ -809,6 +808,12 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> > >       replenish_dl_new_period(dl_se, rq);
> > >  }
> > >
> > > +static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se)
> > > +{
> > > +     WARN_ON(is_dl_boosted(dl_se));
> > > +     __setup_new_dl_entity(dl_se);
> > > +}
> > > +
> >
> > So, the other call path is from dl_server_start() and for this we know
> > the entity is not boosted either. We could probably just remove the
> > WARN_ON w/o the additional wrapper function. That said, considering it's
> > not fast path, I wonder if we actually want to leave the WARN_ON where
> > it is, so that we can catch potential future erroneous usages?
> >
> 
> Yeah, if you feel the patch is not worth it, I am more in favor of
> dropping the patch than removing the WARN_ON.

Think we can drop it yes.

Thanks,
Juri