lkml.org 
[lkml]   [2021]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/3] sched/fair: Prepare variables for increased precision of EAS estimated energy
    Date
    The Energy Aware Scheduler (EAS) tries to find best CPU for a waking up
    task. It probes many possibilities and compares the estimated energy values
    for different scenarios. For calculating those energy values it relies on
    Energy Model (EM) data and em_cpu_energy(). The precision which is used in
    EM data is in milli-Watts (or abstract scale), which sometimes is not
    sufficient. In some cases it might happen that two CPUs from different
    Performance Domains (PDs) get the same calculated value for a given task
    placement, but in more precised scale, they might differ. This rounding
    error has to be addressed. This patch prepares EAS code for better
    precision in the coming EM improvements.

    Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
    ---
    kernel/sched/fair.c | 13 +++++++------
    1 file changed, 7 insertions(+), 6 deletions(-)

    diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
    index 7b8990fd4896..b517c9e79768 100644
    --- a/kernel/sched/fair.c
    +++ b/kernel/sched/fair.c
    @@ -6582,7 +6582,7 @@ static unsigned long cpu_util_next(int cpu, struct task_struct *p, int dst_cpu)
    * to compute what would be the energy if we decided to actually migrate that
    * task.
    */
    -static long
    +static u64
    compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
    {
    struct cpumask *pd_mask = perf_domain_span(pd);
    @@ -6689,12 +6689,13 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
    */
    static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
    {
    - unsigned long prev_delta = ULONG_MAX, best_delta = ULONG_MAX;
    struct root_domain *rd = cpu_rq(smp_processor_id())->rd;
    + u64 prev_delta = ULLONG_MAX, best_delta = ULLONG_MAX;
    int cpu, best_energy_cpu = prev_cpu, target = -1;
    - unsigned long cpu_cap, util, base_energy = 0;
    + unsigned long cpu_cap, util;
    struct sched_domain *sd;
    struct perf_domain *pd;
    + u64 base_energy = 0;

    rcu_read_lock();
    pd = rcu_dereference(rd->pd);
    @@ -6718,9 +6719,9 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
    goto unlock;

    for (; pd; pd = pd->next) {
    - unsigned long cur_delta, spare_cap, max_spare_cap = 0;
    + unsigned long spare_cap, max_spare_cap = 0;
    bool compute_prev_delta = false;
    - unsigned long base_energy_pd;
    + u64 base_energy_pd, cur_delta;
    int max_spare_cap_cpu = -1;

    for_each_cpu_and(cpu, perf_domain_span(pd), sched_domain_span(sd)) {
    @@ -6790,7 +6791,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
    * Pick the best CPU if prev_cpu cannot be used, or if it saves at
    * least 6% of the energy used by prev_cpu.
    */
    - if ((prev_delta == ULONG_MAX) ||
    + if ((prev_delta == ULLONG_MAX) ||
    (prev_delta - best_delta) > ((prev_delta + base_energy) >> 4))
    target = best_energy_cpu;

    --
    2.17.1
    \
     
     \ /
      Last update: 2021-06-25 17:27    [W:2.971 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site