mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Qais Yousef <qyousef@layalina.io>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lukasz Luba <lukasz.luba@arm.com>, Wei Wang <wvw@google.com>,
	Xuewen Yan <xuewen.yan94@gmail.com>, Hank <han.lin@mediatek.com>,
	Jonathan JMChen <Jonathan.JMChen@mediatek.com>
Subject: Re: [PATCH 2/3] sched/fair: Fixes for capacity inversion detection
Date: Thu, 1 Dec 2022 23:39:46 +0100	[thread overview]
Message-ID: <f06321f0-def6-6f9d-b72f-f700e7e9a60a@arm.com> (raw)
In-Reply-To: <20221127141742.1644023-3-qyousef@layalina.io>

On 27/11/2022 15:17, Qais Yousef wrote:
> Traversing the Perf Domains requires rcu_read_lock() to be held and is
> conditional on sched_energy_enabled(). rcu_read_lock() is held while in
> load_balance(), add an assert to ensure this is always the case.
> 
> Also skip capacity inversion detection for our own pd; which was an
> error.
> 
> Fixes: 44c7b80bffc3 ("sched/fair: Detect capacity inversion")
> Reported-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
> Signed-off-by: Qais Yousef (Google) <qyousef@layalina.io>
> ---
>  kernel/sched/fair.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 89dadaafc1ec..7c0dd57e562a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8856,16 +8856,22 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu)
>  	 *   * Thermal pressure will impact all cpus in this perf domain
>  	 *     equally.
>  	 */
> -	if (static_branch_unlikely(&sched_asym_cpucapacity)) {
> +	if (sched_energy_enabled()) {
>  		unsigned long inv_cap = capacity_orig - thermal_load_avg(rq);
>  		struct perf_domain *pd = rcu_dereference(rq->rd->pd);
>  
>  		rq->cpu_capacity_inverted = 0;
>  
> +		SCHED_WARN_ON(!rcu_read_lock_held());

This will trigger in CPU hotplug via build_sched_domains() ->
update_group_capacity() -> update_cpu_capacity() on an EAS system.

> +
>  		for (; pd; pd = pd->next) {
>  			struct cpumask *pd_span = perf_domain_span(pd);
>  			unsigned long pd_cap_orig, pd_cap;
>  
> +			/* We can't be inverted against our own pd */
> +			if (cpumask_test_cpu(cpu_of(rq), pd_span))
> +				continue;
> +

This should fix the issue with `cpu` function parameter in its own PD.

>  			cpu = cpumask_any(pd_span);
>  			pd_cap_orig = arch_scale_cpu_capacity(cpu);
>  

I still don't get the benefit of the CPU capacity inversion patches in
tip/sched/core which should be fixed by this patch:

aa69c36f31aa - sched/fair: Consider capacity inversion in
               util_fits_cpu()
44c7b80bffc3 - sched/fair: Detect capacity inversion

I have to ask again. Why should we use thermal_load_avg() instead of
arch_scale_thermal_pressure() for a CPUx in `CPU capacity inversion
state` (i.e. w/ higher `CPU capacity orig` but lower `CPU capacity` than
CPUy?

  reply	other threads:[~2022-12-01 22:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27 14:17 [PATCH 0/3] Fixes for uclamp and " Qais Yousef
2022-11-27 14:17 ` [PATCH 1/3] sched/uclamp: Fix a uninitialized variable warnings Qais Yousef
2022-12-01 22:38   ` Dietmar Eggemann
2022-12-03 14:32     ` Qais Yousef
2022-12-08 14:51     ` [PATCH v2] " Qais Yousef
2022-11-27 14:17 ` [PATCH 2/3] sched/fair: Fixes for capacity inversion detection Qais Yousef
2022-12-01 22:39   ` Dietmar Eggemann [this message]
2022-12-03 14:32     ` Qais Yousef
2022-12-08 14:54     ` [PATCH v2] " Qais Yousef
2022-12-08 14:58       ` Qais Yousef
2022-11-27 14:17 ` [RFC PATCH 3/3] sched/fair: Traverse cpufreq policies to detect capacity inversion Qais Yousef
2022-11-30 18:27   ` Rafael J. Wysocki
2022-12-03 14:32     ` Qais Yousef
2022-12-05 12:39       ` Rafael J. Wysocki
2022-12-05 14:09         ` Qais Yousef
2022-12-02 14:57   ` Vincent Guittot
2022-12-03 14:33     ` Qais Yousef
2022-12-04 11:35       ` Vincent Guittot
2022-12-05 11:01         ` Qais Yousef
2022-12-06 18:12           ` Vincent Guittot
2022-12-08 14:05             ` Qais Yousef
2022-12-09 16:47               ` Vincent Guittot
2022-12-12 18:43                 ` Qais Yousef
2022-12-13 17:38                   ` Dietmar Eggemann
2022-12-15 17:46                     ` Vincent Guittot
2022-12-20 11:50                     ` Qais Yousef
2022-12-13 17:42                   ` Lukasz Luba
2022-12-20 11:51                     ` Qais Yousef
2022-12-20 12:52                       ` Lukasz Luba
2022-12-15 17:39                   ` Vincent Guittot
2022-12-20 12:32                     ` Qais Yousef
2022-12-20 13:50                       ` Vincent Guittot
2022-12-23 11:58                         ` Qais Yousef
2022-12-27 13:33                           ` Vincent Guittot
2022-12-28 17:18                             ` Vincent Guittot
2023-01-09 16:40                             ` Qais Yousef
2023-01-10 16:38                               ` Vincent Guittot
2023-01-10 16:44                                 ` Qais Yousef

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=f06321f0-def6-6f9d-b72f-f700e7e9a60a@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=Jonathan.JMChen@mediatek.com \
    --cc=han.lin@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qyousef@layalina.io \
    --cc=rafael@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wvw@google.com \
    --cc=xuewen.yan94@gmail.com \
    /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

all inboxes | Powered by JetHome®