Re: [PATCH -next] sched/deadline: Add compare_task_rq helper
From: Daniel Bristot de Oliveira
Date: Fri Aug 26 2022 - 03:10:21 EST
On 8/26/22 05:11, Shang XiaoJing wrote:
> Wrap repeated code in helper function compare_task_rq, which return true
> if there is no deadline task on the rq at all, or task's deadline
> earlier than the rq.
>
> Signed-off-by: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
> ---
> kernel/sched/deadline.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index d116d2b9d2f9..4a40a462717c 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1810,6 +1810,13 @@ static void yield_task_dl(struct rq *rq)
>
> #ifdef CONFIG_SMP
I see the value of this helper, but "compare_task_rq" is making things more confuse.
Choose a more descriptive name, like, dl_task_is_earliest_deadline() ?
> +static inline bool compare_task_rq(struct task_struct *p, struct rq *rq)
> +{
> + return (!rq->dl.dl_nr_running ||
> + dl_time_before(p->dl.deadline,
> + rq->dl.earliest_dl.curr));
> +}
> +
-- Daniel