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: <CAKfTPtCnGRaAcqB6mkVZPP5CzptG-yLO4-mcoaOeHx8ZGPfTvA@mail.gmail.com>
Date: Thu, 21 Mar 2024 09:01:21 +0100
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Shrikanth Hegde <sshegde@...ux.ibm.com>
Cc: mingo@...nel.org, peterz@...radead.org, dietmar.eggemann@....com, 
	qyousef@...alina.io, linux-kernel@...r.kernel.org, vschneid@...hat.com, 
	qperret@...gle.com, yu.c.chen@...el.com, srikar@...ux.ibm.com, 
	pierre.gondois@....com
Subject: Re: [PATCH 2/2] sched/fair: Use helper functions to access rd->overload

On Wed, 13 Mar 2024 at 16:02, Shrikanth Hegde <sshegde@...ux.ibm.com> wrote:
>
> rd->overload is accessed at multiple places. Instead it could use helper
> get/set functions. This would make the code more readable and easy to
> maintain.
>
> No change in functionality intended.
>
> Suggested-by: Qais Yousef <qyousef@...alina.io>
> Signed-off-by: Shrikanth Hegde <sshegde@...ux.ibm.com>

Reviewed-by: Vincent Guittot <vincent.guittot@...aro.org>

> ---
>  kernel/sched/fair.c  |  7 ++++---
>  kernel/sched/sched.h | 14 ++++++++++++--
>  2 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index eeebadd7d9ae..cee99c93e6a4 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -10621,8 +10621,9 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
>
>         if (!env->sd->parent) {
>                 /* update overload indicator if we are at root domain */
> -               if (READ_ONCE(env->dst_rq->rd->overload) != (sg_status & SG_OVERLOAD))
> -                       WRITE_ONCE(env->dst_rq->rd->overload, sg_status & SG_OVERLOAD);
> +               if (is_rd_overloaded(env->dst_rq->rd) != (sg_status & SG_OVERLOAD))
> +                       set_rd_overload_status(env->dst_rq->rd,
> +                                              sg_status & SG_OVERLOAD);
>
>                 /* Update over-utilization (tipping point, U >= 0) indicator */
>                 set_rd_overutilized_status(env->dst_rq->rd,
> @@ -12344,7 +12345,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
>         rcu_read_lock();
>         sd = rcu_dereference_check_sched_domain(this_rq->sd);
>
> -       if (!READ_ONCE(this_rq->rd->overload) ||
> +       if (!is_rd_overloaded(this_rq->rd) ||
>             (sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) {
>
>                 if (sd)
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 41024c1c49b4..c91eb8811bef 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -918,6 +918,16 @@ extern void rq_attach_root(struct rq *rq, struct root_domain *rd);
>  extern void sched_get_rd(struct root_domain *rd);
>  extern void sched_put_rd(struct root_domain *rd);
>
> +static inline int is_rd_overloaded(struct root_domain *rd)
> +{
> +       return READ_ONCE(rd->overload);
> +}
> +
> +static inline void set_rd_overload_status(struct root_domain *rd, int status)
> +{
> +       WRITE_ONCE(rd->overload, status);
> +}
> +
>  #ifdef HAVE_RT_PUSH_IPI
>  extern void rto_push_irq_work_func(struct irq_work *work);
>  #endif
> @@ -2518,8 +2528,8 @@ static inline void add_nr_running(struct rq *rq, unsigned count)
>
>  #ifdef CONFIG_SMP
>         if (prev_nr < 2 && rq->nr_running >= 2) {
> -               if (!READ_ONCE(rq->rd->overload))
> -                       WRITE_ONCE(rq->rd->overload, 1);
> +               if (!is_rd_overloaded(rq->rd))
> +                       set_rd_overload_status(rq->rd, 1);
>         }
>  #endif
>
> --
> 2.39.3
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ