From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <vschneid@redhat.com>,
Mel Gorman <mgorman@suse.de>, Ben Segall <bsegall@google.com>,
Luca Abeni <luca.abeni@santannapisa.it>,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] sched/deadline: Use sched_dl_entity's dl_density in dl_task_fits_capacity()
Date: Wed, 29 Jun 2022 14:20:53 +0200 [thread overview]
Message-ID: <20220629122053.287165-4-dietmar.eggemann@arm.com> (raw)
In-Reply-To: <20220629122053.287165-1-dietmar.eggemann@arm.com>
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@arm.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;
}
extern void init_dl_bw(struct dl_bw *dl_b);
--
2.25.1
next prev parent reply other threads:[~2022-06-29 12:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 12:20 [PATCH 0/3] DL capacity-aware fixes Dietmar Eggemann
2022-06-29 12:20 ` [PATCH 1/3] sched: Introduce sched_asym_cpucap_active() Dietmar Eggemann
2022-06-29 12:20 ` [PATCH 2/3] sched/deadline: Make dl_cpuset_cpumask_can_shrink() capacity-aware Dietmar Eggemann
2022-06-29 12:20 ` Dietmar Eggemann [this message]
2022-07-06 10:47 ` [PATCH 3/3] sched/deadline: Use sched_dl_entity's dl_density in dl_task_fits_capacity() Vincent Guittot
2022-07-08 12:34 ` Dietmar Eggemann
2022-07-08 13:36 ` [PATCH 0/3] DL capacity-aware fixes Juri Lelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220629122053.287165-4-dietmar.eggemann@arm.com \
--to=dietmar.eggemann@arm.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.abeni@santannapisa.it \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.