public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: 黄少波 <huangshaobo2075@phytium.com.cn>
To: linux-pm@vger.kernel.org
Cc: rafael@kernel.org, lenb@kernel.org, deepthi@linux.vnet.ibm.com,
	khilman@kernel.org
Subject: Re: Subject: [cpuidle] Limitation: cannot model asymmetric C-state latencies on big.LITTLE SoCs
Date: Tue, 17 Jun 2025 10:49:13 +0800 (GMT+08:00)	[thread overview]
Message-ID: <7205f65a.55ff.1977bca6dcd.Coremail.huangshaobo2075@phytium.com.cn> (raw)
In-Reply-To: <CAJZ5v0ix-QWgpq_FhnKhSWN5BtBmU_fSWSMJFkr8H1OUm6qJKw@mail.gmail.com>

> On Mon, Jun 16, 2025 at 9:14 AM 黄少波 <huangshaobo2075@phytium.com.cn> wrote:
> >
> > From: huangshaobo2075@phytium.com.cn
> > To: linux-pm@vger.kernel.org
> > Cc: rafael@kernel.org, lenb@kernel.org, deepthi@linux.vnet.ibm.com, khilman@kernel.org
> > Subject: [cpuidle] Limitation: cannot model asymmetric C-state latencies on big.LITTLE SoCs
> >
> > Hi,
> >
> > I'm working on an ARM64 platform with a big.LITTLE CPU topology. While parsing the ACPI tables,
> > I noticed that the C-state latency and residency values differ between the big and LITTLE cores,
> > as expected.
> >
> > However, I found that the current cpuidle framework only allows a single global `cpuidle_driver`,
> > and all CPUs share the same `cpuidle_driver->states[]` array.
> 
> Not really, see bl_idle_init() in particular.
> 
> However, on systems with ACPI on which _CST is used for idle state
> description, there's only one cpuidle driver and one table of idle
> states for all CPUs.
> 
> > As a result, only the first core to
> > initialize (usually a LITTLE core) sets up the C-states, and the same values are applied to all cores,
> > including the big ones. This leads to incorrect idle behavior on asymmetric platforms.
> >
> > I believe this behavior was introduced by commit 46bcfad7a819
> > ("cpuidle: Single/Global registration of idle states").
> >
> > I understand this design was introduced in 2011 to simplify cpuidle and reduce memory usage:
> > https://lkml.org/lkml/2011/4/25/83
> >
> > However, on today's heterogeneous SoCs, this global model no longer suffices. For proper modeling,
> > we need support for per-cluster or per-core cpuidle drivers, or at least some mechanism to allow
> > different idle state parameters per CPU.
> >
> > Has there been any discussion or work toward lifting this limitation?
> 
> No, there's not been any discussion on this so far, but why does the
> platform firmware on this system use _CST for idle state description?
> _LPI would be a better option AFAICS.

From: huangshaobo2075@phytium.com.cn
To: linux-pm@vger.kernel.org
Cc: rafael@kernel.org, lenb@kernel.org, deepthi@linux.vnet.ibm.com, khilman@kernel.org
Subject: [cpuidle][follow-up] _LPI path also assumes shared cpuidle_driver, breaks on big.LITTLE

Hi all,

Thanks Rafael for the quick feedback on my earlier question regarding asymmetric idle states on big.LITTLE SoCs.

As a follow-up, after reviewing the implementation further, I noticed that `acpi_processor_setup_lpi_states()` is only called from within
`acpi_processor_setup_cpuidle_states()`, which is itself only invoked once — during initialization of the first CPU.

Specifically:

- The kernel uses a shared global cpuidle_driver instance (`acpi_idle_driver`), which is only initialized once in `acpi_processor_power_init()`:

  static int acpi_processor_registered;
  ...
  if (!acpi_processor_registered) {
      acpi_processor_setup_cpuidle_states(pr);
      cpuidle_register_driver(&acpi_idle_driver);
  }

- Subsequent CPUs only register their cpuidle_device without updating the shared driver's states[] array.

- Even in `acpi_processor_power_state_has_changed()`, only `pr->id == 0` triggers `acpi_processor_setup_cpuidle_states()`, meaning the global
  state array is populated based only on CPU 0.

    int acpi_processor_power_state_has_changed(struct acpi_processor *pr) {
        ...
        if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) {
            ...
            acpi_processor_setup_cpuidle_states(pr);
            ...
        }
    }

The ACPI _LPI specification allows firmware to describe per-CPU or per-cluster idle state characteristics (latency, residency, etc.). However,
the current implementation effectively ignores this flexibility and applies the first CPU’s states globally.

This appears to be a design limitation that prevents accurate modeling of asymmetric CPU topologies like big.LITTLE. As a result, idle states may
not reflect the correct characteristics for all cores, leading to suboptimal behavior.

Could you please confirm whether this behavior is an intentional carry-over from the legacy _CST-based implementation, or simply an area that hasn't
been fully extended to support _LPI's per-CPU flexibility?

We are actively using the ACPI-based _LPI method on asymmetric ARM64 platforms, so this behavior is directly impacting us. I’d be happy to help investigate
a fix if the current design is not intentional.

Additionally, I’ve reviewed the `bl_idle_init()` implementation in the big.LITTLE device-tree-based driver and confirmed it does not support ACPI.
Since our platform relies on _LPI via ACPI, this limitation is particularly relevant in our use case.

Thanks for your time and insights!

Best regards,
Shaobo Huang


信息安全声明:本邮件包含信息归发件人所在组织所有,发件人所在组织对该邮件拥有所有权利。请接收者注意保密,未经发件人书面许可,不得向任何第三方组织和个人透露本邮件所含信息。
Information Security Notice: The information contained in this mail is solely property of the sender's organization.This mail communication is confidential.Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.

  reply	other threads:[~2025-06-17  2:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16  7:14 Subject: [cpuidle] Limitation: cannot model asymmetric C-state latencies on big.LITTLE SoCs 黄少波
2025-06-16 11:29 ` Rafael J. Wysocki
2025-06-17  2:49   ` 黄少波 [this message]
2025-06-20 10:46   ` Sudeep Holla
2025-06-17 15:59 ` Pierre Gondois
2025-06-18  3:34   ` 黄少波
2025-06-20 10:38 ` Sudeep Holla

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=7205f65a.55ff.1977bca6dcd.Coremail.huangshaobo2075@phytium.com.cn \
    --to=huangshaobo2075@phytium.com.cn \
    --cc=deepthi@linux.vnet.ibm.com \
    --cc=khilman@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.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