lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0hKybawJTfmSNp=Hargq4QHhtJ-_mkzVLVJXxYwiMDnAQ@mail.gmail.com>
Date:   Thu, 4 Oct 2018 17:23:11 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Daniel Lezcano <daniel.lezcano@...aro.org>
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Linux PM <linux-pm@...r.kernel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Todd Kjos <tkjos@...gle.com>,
        Joel Fernandes <joelaf@...gle.com>,
        Colin Cross <ccross@...roid.com>,
        Ramesh Thomas <ramesh.thomas@...el.com>,
        Mel Gorman <mgorman@...e.de>, Ingo Molnar <mingo@...hat.com>,
        Rafael Wysocki <rafael.j.wysocki@...el.com>,
        Alex Shi <alex.shi@...aro.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Philippe Ombredanne <pombredanne@...b.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Kate Stewart <kstewart@...uxfoundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V2 2/2] cpuidle/drivers/menu: Remove get_loadavg in the
 performance multiplier

On Thu, Oct 4, 2018 at 2:04 PM Daniel Lezcano <daniel.lezcano@...aro.org> wrote:
>
> The function get_loadavg() returns almost always zero. To be more
> precise, statistically speaking for a total of 1023379 times passing
> in the function, the load is equal to zero 1020728 times, greater than
> 100, 610 times, the remaining is between 0 and 5.
>
> In 2011, the get_loadavg() was removed from the Android tree because
> of the above [1]. At this time, the load was:
>
> unsigned long this_cpu_load(void)
> {
>         struct rq *this = this_rq();
>         return this->cpu_load[0];
> }
>
> In 2014, the code was changed by commit 372ba8cb46b2 (cpuidle: menu: Lookup CPU
> runqueues less) and the load is:
>
> void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
> {
>         struct rq *rq = this_rq();
>         *nr_waiters = atomic_read(&rq->nr_iowait);
>         *load = rq->load.weight;
> }
>
> with the same result.
>
> Both measurements show using the load in this code path does no matter
> anymore. Removing it.
>
> [1] https://android.googlesource.com/kernel/common/+/4dedd9f124703207895777ac6e91dacde0f7cc17
>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Todd Kjos <tkjos@...gle.com>
> Cc: Joel Fernandes <joelaf@...gle.com>
> Cc: Colin Cross <ccross@...roid.com>
> Cc: Ramesh Thomas <ramesh.thomas@...el.com>
> Cc: Mel Gorman <mgorman@...e.de>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.org>

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

> ---
>  drivers/cpuidle/governors/menu.c | 26 +++++++-------------------
>  include/linux/sched/stat.h       |  1 -
>  kernel/sched/core.c              |  7 -------
>  3 files changed, 7 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
> index e26a409..066b01f 100644
> --- a/drivers/cpuidle/governors/menu.c
> +++ b/drivers/cpuidle/governors/menu.c
> @@ -135,11 +135,6 @@ struct menu_device {
>  #define LOAD_INT(x) ((x) >> FSHIFT)
>  #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
>
> -static inline int get_loadavg(unsigned long load)
> -{
> -       return LOAD_INT(load) * 10 + LOAD_FRAC(load) / 10;
> -}
> -
>  static inline int which_bucket(unsigned int duration, unsigned long nr_iowaiters)
>  {
>         int bucket = 0;
> @@ -173,18 +168,10 @@ static inline int which_bucket(unsigned int duration, unsigned long nr_iowaiters
>   * to be, the higher this multiplier, and thus the higher
>   * the barrier to go to an expensive C state.
>   */
> -static inline int performance_multiplier(unsigned long nr_iowaiters, unsigned long load)
> +static inline int performance_multiplier(unsigned long nr_iowaiters)
>  {
> -       int mult = 1;
> -
> -       /* for higher loadavg, we are more reluctant */
> -
> -       mult += 2 * get_loadavg(load);
> -
> -       /* for IO wait tasks (per cpu!) we add 5x each */
> -       mult += 10 * nr_iowaiters;
> -
> -       return mult;
> +       /* for IO wait tasks (per cpu!) we add 10x each */
> +       return 1 + 10 * nr_iowaiters;
>  }
>
>  static DEFINE_PER_CPU(struct menu_device, menu_devices);
> @@ -290,7 +277,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
>         int idx;
>         unsigned int interactivity_req;
>         unsigned int expected_interval;
> -       unsigned long nr_iowaiters, cpu_load;
> +       unsigned long nr_iowaiters;
>         ktime_t delta_next;
>
>         if (data->needs_update) {
> @@ -307,7 +294,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
>         /* determine the expected residency time, round up */
>         data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length(&delta_next));
>
> -       get_iowait_load(&nr_iowaiters, &cpu_load);
> +       nr_iowaiters = nr_iowait_cpu(dev->cpu);
>         data->bucket = which_bucket(data->next_timer_us, nr_iowaiters);
>
>         /*
> @@ -359,7 +346,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
>                  * Use the performance multiplier and the user-configurable
>                  * latency_req to determine the maximum exit latency.
>                  */
> -               interactivity_req = data->predicted_us / performance_multiplier(nr_iowaiters, cpu_load);
> +               interactivity_req = data->predicted_us /
> +                       performance_multiplier(nr_iowaiters);
>                 if (latency_req > interactivity_req)
>                         latency_req = interactivity_req;
>         }
> diff --git a/include/linux/sched/stat.h b/include/linux/sched/stat.h
> index 04f1321..f30954c 100644
> --- a/include/linux/sched/stat.h
> +++ b/include/linux/sched/stat.h
> @@ -20,7 +20,6 @@ extern unsigned long nr_running(void);
>  extern bool single_task_running(void);
>  extern unsigned long nr_iowait(void);
>  extern unsigned long nr_iowait_cpu(int cpu);
> -extern void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
>
>  static inline int sched_info_on(void)
>  {
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 43efb74..48a786a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2886,13 +2886,6 @@ unsigned long nr_iowait_cpu(int cpu)
>         return atomic_read(&cpu_rq(cpu)->nr_iowait);
>  }
>
> -void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
> -{
> -       struct rq *rq = this_rq();
> -       *nr_waiters = atomic_read(&rq->nr_iowait);
> -       *load = rq->load.weight;
> -}
> -
>  /*
>   * IO-wait accounting, and how its mostly bollocks (on SMP).
>   *
> --
> 2.7.4
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ