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: <CAJZ5v0gWSRE1WX0GTVqHhpDZW8ZaWpviuQ+zEyS4E6ne4rutLQ@mail.gmail.com>
Date: Mon, 22 Sep 2025 19:38:18 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Huisong Li <lihuisong@...wei.com>
Cc: rafael@...nel.org, lenb@...nel.org, linux-acpi@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linuxarm@...wei.com, 
	jonathan.cameron@...wei.com, zhanjie9@...ilicon.com, zhenglifeng1@...wei.com, 
	yubowen8@...wei.com
Subject: Re: [PATCH v4 1/1] ACPI: processor: Do not expose the global
 acpi_idle_driver variable

On Mon, Sep 22, 2025 at 9:04 AM Huisong Li <lihuisong@...wei.com> wrote:
>
> Currently, processor_driver just use the global acpi_idle_driver variable
> to check if the cpuidle driver is acpi_idle_driver. Actually, there is no
> need to expose this global variable defined in processor_idle.c to outside.
> So move the related check to acpi_processor_power_init() and limit the
> global variable to a static one.
>
> Signed-off-by: Huisong Li <lihuisong@...wei.com>
> ---
>  drivers/acpi/processor_driver.c |  3 +--
>  drivers/acpi/processor_idle.c   | 12 +++++++++++-
>  include/acpi/processor.h        |  1 -
>  3 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
> index de17c1412678..5d824435b26b 100644
> --- a/drivers/acpi/processor_driver.c
> +++ b/drivers/acpi/processor_driver.c
> @@ -166,8 +166,7 @@ static int __acpi_processor_start(struct acpi_device *device)
>         if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS))
>                 dev_dbg(&device->dev, "CPPC data invalid or not present\n");
>
> -       if (cpuidle_get_driver() == &acpi_idle_driver)
> -               acpi_processor_power_init(pr);
> +       acpi_processor_power_init(pr);
>
>         acpi_pss_perf_init(pr);
>
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index 698d14c19587..42948495f4f1 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -51,7 +51,7 @@ module_param(latency_factor, uint, 0644);
>
>  static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);
>
> -struct cpuidle_driver acpi_idle_driver = {
> +static struct cpuidle_driver acpi_idle_driver = {
>         .name =         "acpi_idle",
>         .owner =        THIS_MODULE,
>  };
> @@ -1402,8 +1402,18 @@ void acpi_processor_unregister_idle_driver(void)
>
>  void acpi_processor_power_init(struct acpi_processor *pr)
>  {
> +       struct cpuidle_driver *drv = cpuidle_get_driver();

This variable is not needed any more.

>         struct cpuidle_device *dev;
>
> +       /*
> +        * Normally, the ACPI idle driver has already been registered before
> +        * CPU online. But the 'drv' may be NULL if register idle driver failed.
> +        * So do not anything if the idle driver isn't acpi_idle_driver or the
> +        * 'drv' is NULL.

And this comment can be much shorter, maybe something like "The code
below only works if acpi_idle_driver is the current cpuidle driver."

> +        */
> +       if (drv != &acpi_idle_driver)
> +               return;
> +
>         if (disabled_by_idle_boot_param())
>                 return;
>
> diff --git a/include/acpi/processor.h b/include/acpi/processor.h
> index 24fdaa3c2899..7146a8e9e9c2 100644
> --- a/include/acpi/processor.h
> +++ b/include/acpi/processor.h
> @@ -417,7 +417,6 @@ static inline void acpi_processor_throttling_init(void) {}
>  #endif /* CONFIG_ACPI_CPU_FREQ_PSS */
>
>  /* in processor_idle.c */
> -extern struct cpuidle_driver acpi_idle_driver;
>  #ifdef CONFIG_ACPI_PROCESSOR_IDLE
>  void acpi_processor_power_init(struct acpi_processor *pr);
>  void acpi_processor_power_exit(struct acpi_processor *pr);
> --
> 2.33.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ