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]
Date:   Tue, 4 Jun 2019 08:59:28 -0700
From:   Peter Oskolkov <posk@...k.io>
To:     Viresh Kumar <viresh.kumar@...aro.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Vincent Guittot <vincent.guittot@...aro.org>
Subject: Re: [PATCH] sched/fair: Introduce fits_capacity()

On Tue, Jun 4, 2019 at 12:02 AM Viresh Kumar <viresh.kumar@...aro.org> wrote:
>
> The same formula to check utilization against capacity (after
> considering capacity_margin) is already used at 5 different locations.
>
> This patch creates a new macro, fits_capacity(), which can be used from
> all these locations without exposing the details of it and hence
> simplify code.
>
> All the 5 code locations are updated as well to use it..
>
> Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
> ---
>  kernel/sched/fair.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 7f8d477f90fe..db3a218b7928 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -102,6 +102,8 @@ int __weak arch_asym_cpu_priority(int cpu)
>   * (default: ~20%)
>   */
>  static unsigned int capacity_margin                    = 1280;
> +
> +#define fits_capacity(cap, max)        ((cap) * capacity_margin < (max) * 1024)

Any reason to have this as a macro and not as an inline function?

>  #endif
>
>  #ifdef CONFIG_CFS_BANDWIDTH
> @@ -3727,7 +3729,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep)
>
>  static inline int task_fits_capacity(struct task_struct *p, long capacity)
>  {
> -       return capacity * 1024 > task_util_est(p) * capacity_margin;
> +       return fits_capacity(task_util_est(p), capacity);
>  }
>
>  static inline void update_misfit_status(struct task_struct *p, struct rq *rq)
> @@ -5143,7 +5145,7 @@ static inline unsigned long cpu_util(int cpu);
>
>  static inline bool cpu_overutilized(int cpu)
>  {
> -       return (capacity_of(cpu) * 1024) < (cpu_util(cpu) * capacity_margin);
> +       return !fits_capacity(cpu_util(cpu), capacity_of(cpu));
>  }
>
>  static inline void update_overutilized_status(struct rq *rq)
> @@ -6304,7 +6306,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>                         /* Skip CPUs that will be overutilized. */
>                         util = cpu_util_next(cpu, p, cpu);
>                         cpu_cap = capacity_of(cpu);
> -                       if (cpu_cap * 1024 < util * capacity_margin)
> +                       if (!fits_capacity(util, cpu_cap))
>                                 continue;
>
>                         /* Always use prev_cpu as a candidate. */
> @@ -7853,8 +7855,7 @@ group_is_overloaded(struct lb_env *env, struct sg_lb_stats *sgs)
>  static inline bool
>  group_smaller_min_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
>  {
> -       return sg->sgc->min_capacity * capacity_margin <
> -                                               ref->sgc->min_capacity * 1024;
> +       return fits_capacity(sg->sgc->min_capacity, ref->sgc->min_capacity);
>  }
>
>  /*
> @@ -7864,8 +7865,7 @@ group_smaller_min_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
>  static inline bool
>  group_smaller_max_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
>  {
> -       return sg->sgc->max_capacity * capacity_margin <
> -                                               ref->sgc->max_capacity * 1024;
> +       return fits_capacity(sg->sgc->max_capacity, ref->sgc->max_capacity);
>  }
>
>  static inline enum
> --
> 2.21.0.rc0.269.g1a574e7a288b
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ