[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtAFC5Pk7nfJvSYTmaQNayDoGy40kTnT9j8-yZpDezKNYw@mail.gmail.com>
Date: Wed, 6 Jul 2022 12:47:44 +0200
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Dietmar Eggemann <dietmar.eggemann@....com>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Steven Rostedt <rostedt@...dmis.org>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Valentin Schneider <vschneid@...hat.com>,
Mel Gorman <mgorman@...e.de>, Ben Segall <bsegall@...gle.com>,
Luca Abeni <luca.abeni@...tannapisa.it>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] sched/deadline: Use sched_dl_entity's dl_density in dl_task_fits_capacity()
On Wed, 29 Jun 2022 at 14:21, Dietmar Eggemann <dietmar.eggemann@....com> wrote:
>
> Save a multiplication in dl_task_fits_capacity() by using already
> maintained per-sched_dl_entity (i.e. per-task) `dl_runtime/dl_deadline`
> (dl_density).
>
> cap_scale(dl_deadline, cap) >= dl_runtime
>
> dl_deadline * cap >> SCHED_CAPACITY_SHIFT >= dl_runtime
>
> cap >= dl_runtime << SCHED_CAPACITY_SHIFT / dl_deadline
>
> with BW_SHIFT = 2 x SCHED_CAPACITY_SHIFT
>
> cap >= (dl_runtime << BW_SHIFT / dl_deadline) >> SCHED_CAPACITY_SHIFT
>
> cap >= dl_density >> SCHED_CAPACITY_SHIFT
>
> __sched_setscheduler()->__checkparam_dl() ensures that the 2 corner
> cases (if conditions) `runtime == RUNTIME_INF (-1)` and `period == 0`
> of to_ratio(deadline, runtime) are not met when setting dl_density in
> __sched_setscheduler()-> __setscheduler_params()->__setparam_dl().
>
> Signed-off-by: Dietmar Eggemann <dietmar.eggemann@....com>
> ---
> kernel/sched/sched.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 79f65a6799c6..555f58d6c3a6 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -324,15 +324,15 @@ struct dl_bw {
> * Verify the fitness of task @p to run on @cpu taking into account the
> * CPU original capacity and the runtime/deadline ratio of the task.
> *
> - * The function will return true if the CPU original capacity of the
> - * @cpu scaled by SCHED_CAPACITY_SCALE >= runtime/deadline ratio of the
> - * task and false otherwise.
> + * The function will return true if the original capacity of @cpu is
> + * greater than or equal to task's deadline density right shifted by
> + * SCHED_CAPACITY_SHIFT and false otherwise.
> */
> static inline bool dl_task_fits_capacity(struct task_struct *p, int cpu)
> {
> unsigned long cap = arch_scale_cpu_capacity(cpu);
>
> - return cap_scale(p->dl.dl_deadline, cap) >= p->dl.dl_runtime;
> + return cap >= p->dl.dl_density >> SCHED_CAPACITY_SHIFT;
There is no direct relation between BW_SHIFT and SCHED_CAPACITY_SHIFT
and we can change one without modifying the other.
Should you use (BW_SHIFT-SCHED_CAPACITY_SHIFT) instead of SCHED_CAPACITY_SHIFT ?
> }
>
> extern void init_dl_bw(struct dl_bw *dl_b);
> --
> 2.25.1
>
Powered by blists - more mailing lists