All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	Christian Loehle <christian.loehle@arm.com>,
	linux-kernel@vger.kernel.org,
	Felix Abecassis <fabecassis@nvidia.com>
Subject: Re: [PATCH] sched/topology: Avoid spurious asymmetry from CPU capacity noise
Date: Tue, 24 Mar 2026 10:39:41 +0100	[thread overview]
Message-ID: <acJb3fjs3r5nJpH2@gpd4> (raw)
In-Reply-To: <CAKfTPtBYdwNGw1QHPABVgz5KX+rzWv=f1V8Kgde7CU1yX10g8A@mail.gmail.com>

Hi Vincent,

On Tue, Mar 24, 2026 at 08:39:34AM +0100, Vincent Guittot wrote:
> On Tue, 24 Mar 2026 at 01:55, Andrea Righi <arighi@nvidia.com> wrote:
> >
> > On some platforms, the firmware may expose per-CPU performance
> > differences (e.g., via ACPI CPPC highest_perf) even when the system is
> > effectively symmetric. These small variations, typically due to silicon
> > binning, are reflected in arch_scale_cpu_capacity() and end up being
> > interpreted as real capacity asymmetry.
> >
> > As a result, the scheduler incorrectly enables SD_ASYM_CPUCAPACITY,
> > triggering asymmetry-specific behaviors, even though all CPUs have
> > comparable performance.
> >
> > Prevent this by treating CPU capacities within 20% of the maximum value
> 
> 20% is a bit high, my snapdragon rb5 has a mid CPU with a capacity of
> 871 but we still want to keep them different
> 
> Why would 5% not be enough?

Sure, 5% seems a more reasonable margin. I'll just reuse capacity_greater()
as suggested by Christian.

Thanks,
-Andrea

> 
> 
> 
> > as equivalent when building the asymmetry topology. This filters out
> > firmware noise, while preserving correct behavior on real heterogeneous
> > systems, where capacity differences are significantly larger.
> >
> > Reported-by: Felix Abecassis <fabecassis@nvidia.com>
> > Signed-off-by: Andrea Righi <arighi@nvidia.com>
> > ---
> >  kernel/sched/topology.c | 19 ++++++++++++++++---
> >  1 file changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> > index 061f8c85f5552..fe71ea9f3bda7 100644
> > --- a/kernel/sched/topology.c
> > +++ b/kernel/sched/topology.c
> > @@ -1432,9 +1432,8 @@ static void free_asym_cap_entry(struct rcu_head *head)
> >         kfree(entry);
> >  }
> >
> > -static inline void asym_cpu_capacity_update_data(int cpu)
> > +static inline void asym_cpu_capacity_update_data(int cpu, unsigned long capacity)
> >  {
> > -       unsigned long capacity = arch_scale_cpu_capacity(cpu);
> >         struct asym_cap_data *insert_entry = NULL;
> >         struct asym_cap_data *entry;
> >
> > @@ -1471,13 +1470,27 @@ static inline void asym_cpu_capacity_update_data(int cpu)
> >  static void asym_cpu_capacity_scan(void)
> >  {
> >         struct asym_cap_data *entry, *next;
> > +       unsigned long max_cap = 0;
> > +       unsigned long capacity;
> >         int cpu;
> >
> >         list_for_each_entry(entry, &asym_cap_list, link)
> >                 cpumask_clear(cpu_capacity_span(entry));
> >
> >         for_each_cpu_and(cpu, cpu_possible_mask, housekeeping_cpumask(HK_TYPE_DOMAIN))
> > -               asym_cpu_capacity_update_data(cpu);
> > +               max_cap = max(max_cap, arch_scale_cpu_capacity(cpu));
> > +
> > +       /*
> > +        * Treat small capacity differences (< 20% max capacity) as noise,
> > +        * to prevent enabling SD_ASYM_CPUCAPACITY when it's not really
> > +        * needed.
> > +        */
> > +       for_each_cpu_and(cpu, cpu_possible_mask, housekeeping_cpumask(HK_TYPE_DOMAIN)) {
> > +               capacity = arch_scale_cpu_capacity(cpu);
> > +               if (capacity * 5 >= max_cap * 4)
> > +                       capacity = max_cap;
> > +               asym_cpu_capacity_update_data(cpu, capacity);
> > +       }
> >
> >         list_for_each_entry_safe(entry, next, &asym_cap_list, link) {
> >                 if (cpumask_empty(cpu_capacity_span(entry))) {
> > --
> > 2.53.0
> >

  parent reply	other threads:[~2026-03-24  9:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24  0:55 [PATCH] sched/topology: Avoid spurious asymmetry from CPU capacity noise Andrea Righi
2026-03-24  7:39 ` Vincent Guittot
2026-03-24  7:55   ` Christian Loehle
2026-03-24  8:08     ` Christian Loehle
2026-03-24  9:46       ` Andrea Righi
2026-03-24 10:29         ` Dietmar Eggemann
2026-03-24 11:01           ` Andrea Righi
2026-03-25  9:23             ` Dietmar Eggemann
2026-03-25  9:32               ` Andrea Righi
2026-03-25 11:16                 ` Dietmar Eggemann
2026-03-25 12:25                   ` Andrea Righi
2026-03-25 15:26                     ` Dietmar Eggemann
2026-03-25 16:50                       ` Andrea Righi
2026-03-25 12:48                 ` Phil Auld
2026-03-24  9:39   ` Andrea Righi [this message]
2026-03-25  3:30     ` Koba Ko
2026-03-25 12:29       ` Andrea Righi

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=acJb3fjs3r5nJpH2@gpd4 \
    --to=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=christian.loehle@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=fabecassis@nvidia.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.