linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: peterz@infradead.org, mingo@kernel.org,
	linux-kernel@vger.kernel.org, rjw@rjwysocki.net
Subject: Re: [PATCH] sched/fair: remove #ifdefs from scale_rt_capacity
Date: Fri, 20 Jul 2018 10:25:43 +0530	[thread overview]
Message-ID: <20180720045543.jx76p67sntophjne@vireshk-i7> (raw)
In-Reply-To: <1532001606-6689-1-git-send-email-vincent.guittot@linaro.org>

On 19-07-18, 14:00, Vincent Guittot wrote:
> Reuse cpu_util_irq() that has been defined for schedutil and set irq util
> to 0 when !CONFIG_IRQ_TIME_ACCOUNTING
> 
> But the compiler is not able to optimize the sequence (at least with
> aarch64 GCC 7.2.1)
> 	free *= (max - irq);
> 	free /= max;
> when irq is fixed to 0
> 
> Add a new inline function scale_irq_capacity() that will scale utilization
> when irq is accounted. Reuse this funciton in schedutil which applies
> similar formula.
> 
> Suggested-by: Ingo Molnar <mingo@redhat.com>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>  kernel/sched/cpufreq_schedutil.c |  3 +--
>  kernel/sched/fair.c              | 13 +++----------
>  kernel/sched/sched.h             | 20 ++++++++++++++++++--
>  3 files changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 97dcd44..3fffad3 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -247,8 +247,7 @@ static unsigned long sugov_get_util(struct sugov_cpu *sg_cpu)
>  	 *   U' = irq + ------- * U
>  	 *                max
>  	 */
> -	util *= (max - irq);
> -	util /= max;
> +	util = scale_irq_capacity(util, irq, max);
>  	util += irq;
>  
>  	/*
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d5f7d52..14c3fdd 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7551,16 +7551,12 @@ static unsigned long scale_rt_capacity(int cpu)
>  	struct rq *rq = cpu_rq(cpu);
>  	unsigned long max = arch_scale_cpu_capacity(NULL, cpu);
>  	unsigned long used, free;
> -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
>  	unsigned long irq;
> -#endif
>  
> -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> -	irq = READ_ONCE(rq->avg_irq.util_avg);
> +	irq = cpu_util_irq(rq);
>  
>  	if (unlikely(irq >= max))
>  		return 1;
> -#endif
>  
>  	used = READ_ONCE(rq->avg_rt.util_avg);
>  	used += READ_ONCE(rq->avg_dl.util_avg);
> @@ -7569,11 +7565,8 @@ static unsigned long scale_rt_capacity(int cpu)
>  		return 1;
>  
>  	free = max - used;
> -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> -	free *= (max - irq);
> -	free /= max;
> -#endif
> -	return free;
> +
> +	return scale_irq_capacity(free, irq, max);
>  }
>  
>  static void update_cpu_capacity(struct sched_domain *sd, int cpu)
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index ebb4b3c..b80c3fd 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -2210,17 +2210,33 @@ static inline unsigned long cpu_util_rt(struct rq *rq)
>  {
>  	return READ_ONCE(rq->avg_rt.util_avg);
>  }
> +#endif
>  
> -#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
> +#if defined(SMP) \
> + && (defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING))
>  static inline unsigned long cpu_util_irq(struct rq *rq)
>  {
>  	return rq->avg_irq.util_avg;
>  }
> +
> +static inline
> +unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max)
> +{
> +	util *= (max - irq);

() can be dropped here. 

Other than that: 

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

  reply	other threads:[~2018-07-20  4:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 12:00 [PATCH] sched/fair: remove #ifdefs from scale_rt_capacity Vincent Guittot
2018-07-20  4:55 ` Viresh Kumar [this message]
2018-07-20 12:31 ` Peter Zijlstra
2018-07-30 16:04   ` Vincent Guittot
2018-07-25 14:22 ` [tip:sched/core] sched/fair: Remove #ifdefs from scale_rt_capacity() tip-bot for Vincent Guittot
2018-09-15 11:46   ` Ingo Molnar
2018-09-15 12:17     ` Vincent Guittot
2018-09-15 12:29       ` Ingo Molnar
2018-09-15 14:35         ` Vincent Guittot
2018-09-18  6:38           ` Ingo Molnar

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=20180720045543.jx76p67sntophjne@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=vincent.guittot@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).