All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
@ 2021-05-18 19:34 kyle.meyer
  2021-05-21 13:01 ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: kyle.meyer @ 2021-05-18 19:34 UTC (permalink / raw)
  To: rjw, viresh.kumar, linux-kernel; +Cc: Kyle Meyer

From: Kyle Meyer <kyle.meyer@hpe.com>

Revert part of commit 75c0758137c7a
("acpi-cpufreq: Fail initialization if driver cannot be registered").

acpi-cpufreq is mutually exclusive with intel_pstate, however,
acpi-cpufreq is loaded multiple times during startup while intel_pstate is
enabled. On systems using systemd the kernel triggers one uevent for each
device as a result of systemd-udev-trigger.service. The service exists to
retrigger all devices as uevents sent by the kernel before systemd-udevd
is running are missed. The delay caused by systemd-udevd repeatedly loading
the driver, getting a fail return, and unloading the driver twice per
logical CPU has a significant impact on the startup time, and can cause
some devices to be unavailable after reaching the root login prompt.

Load the driver once but skip initialization if a cpufreq driver exists by
changing the return value of cpufreq_get_current_driver() from -EEXIST to
0.

Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---
 drivers/cpufreq/acpi-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 7e7450453714..e79a945369d1 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -1003,7 +1003,7 @@ static int __init acpi_cpufreq_init(void)
 
 	/* don't keep reloading if cpufreq_driver exists */
 	if (cpufreq_get_current_driver())
-		return -EEXIST;
+		return 0;
 
 	pr_debug("%s\n", __func__);
 
-- 
2.26.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
  2021-05-18 19:34 [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists kyle.meyer
@ 2021-05-21 13:01 ` Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2021-05-21 13:01 UTC (permalink / raw)
  To: viresh.kumar, linux-kernel, kyle.meyer; +Cc: Kyle Meyer

On Tuesday, May 18, 2021 9:34:55 PM CEST kyle.meyer@hpe.com wrote:
> From: Kyle Meyer <kyle.meyer@hpe.com>
> 
> Revert part of commit 75c0758137c7a
> ("acpi-cpufreq: Fail initialization if driver cannot be registered").
> 
> acpi-cpufreq is mutually exclusive with intel_pstate, however,
> acpi-cpufreq is loaded multiple times during startup while intel_pstate is
> enabled. On systems using systemd the kernel triggers one uevent for each
> device as a result of systemd-udev-trigger.service. The service exists to
> retrigger all devices as uevents sent by the kernel before systemd-udevd
> is running are missed. The delay caused by systemd-udevd repeatedly loading
> the driver, getting a fail return, and unloading the driver twice per
> logical CPU has a significant impact on the startup time, and can cause
> some devices to be unavailable after reaching the root login prompt.
> 
> Load the driver once but skip initialization if a cpufreq driver exists by
> changing the return value of cpufreq_get_current_driver() from -EEXIST to
> 0.
> 
> Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> ---
>  drivers/cpufreq/acpi-cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 7e7450453714..e79a945369d1 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -1003,7 +1003,7 @@ static int __init acpi_cpufreq_init(void)
>  
>  	/* don't keep reloading if cpufreq_driver exists */
>  	if (cpufreq_get_current_driver())
> -		return -EEXIST;
> +		return 0;
>  
>  	pr_debug("%s\n", __func__);
>  
> 

Please resend this with CCs to linux-pm@vger.kernel.org and linux-acpi@vegr.kernel.org.

Thanks!





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
  2021-06-07 11:02     ` Rafael J. Wysocki
@ 2021-06-07 11:14       ` Viresh Kumar
  0 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2021-06-07 11:14 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Takashi Iwai, Kyle Meyer, Rafael J. Wysocki,
	Linux Kernel Mailing List, Linux PM, linux-acpi

On 07-06-21, 13:02, Rafael J. Wysocki wrote:
> On Mon, Jun 7, 2021 at 9:26 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > I am not sure how this is supposed to work. If we return 0 from
> > acpi_cpufreq_init(),
> > then the driver will never be used, since it's acpi_cpufreq_init()
> > will never get
> > called again later.
> 
> Unless the module is unloaded and loaded again, that is.

Right.

> > cpufreq drivers don't follow the generic device/driver model where a driver gets
> > probed again if a device appears and so this is broken.
> 
> It is broken anyway as per the changelog of this patch.
> 
> On systems with several hundred logical CPUs this really can be troublesome.

Hmm, I agree.

> > Please revert this patch.
> 
> Well, you can argue that the problem at hand is outside the kernel and
> so it's not a kernel's business to address it.

Exactly, what we did here is add a band-aid to make a userspace tool
happy, the kernel was doing the right thing earlier.

> After all, systemd-udevd could learn to avoid attempting to load the
> module again if it fails with -EEXIST,

That is one way, right.

> but I'm not sure how different
> that really would be from what this patch does, in practice.

The very first difference is we won't be adding an incorrect hack in
the kernel to solve this userspace problem. Else in order to make
acpi-cpufreq driver work, after a user unloads intel-pstate, user
would be required to unload the acpi-cpufreq and load it again, which
will surely look confusing to the user. Why unload to load it again ?

Leaving a module inserted in an unusable state is not the right
solution to fix a problem IMHO.

-- 
viresh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
  2021-06-07  7:25   ` Viresh Kumar
@ 2021-06-07 11:02     ` Rafael J. Wysocki
  2021-06-07 11:14       ` Viresh Kumar
  0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2021-06-07 11:02 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, Takashi Iwai, Kyle Meyer, Rafael J. Wysocki,
	Linux Kernel Mailing List, Linux PM, linux-acpi

On Mon, Jun 7, 2021 at 9:26 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Hi Rafael,
>
> On Mon, May 24, 2021 at 7:47 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > On Sat, May 22, 2021 at 12:19 AM Kyle Meyer <kyle.meyer@hpe.com> wrote:
>
> > > diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> > > index 7e7450453714..e79a945369d1 100644
> > > --- a/drivers/cpufreq/acpi-cpufreq.c
> > > +++ b/drivers/cpufreq/acpi-cpufreq.c
> > > @@ -1003,7 +1003,7 @@ static int __init acpi_cpufreq_init(void)
> > >
> > >         /* don't keep reloading if cpufreq_driver exists */
> > >         if (cpufreq_get_current_driver())
> > > -               return -EEXIST;
> > > +               return 0;
> > >
> > >         pr_debug("%s\n", __func__);
> > >
> > > --
> >
> > Applied as 5.14 material with some edits in the subject and changelog, thanks!
>
> I am not sure how this is supposed to work. If we return 0 from
> acpi_cpufreq_init(),
> then the driver will never be used, since it's acpi_cpufreq_init()
> will never get
> called again later.

Unless the module is unloaded and loaded again, that is.

> cpufreq drivers don't follow the generic device/driver model where a driver gets
> probed again if a device appears and so this is broken.

It is broken anyway as per the changelog of this patch.

On systems with several hundred logical CPUs this really can be troublesome.

> Please revert this patch.

Well, you can argue that the problem at hand is outside the kernel and
so it's not a kernel's business to address it.

After all, systemd-udevd could learn to avoid attempting to load the
module again if it fails with -EEXIST, but I'm not sure how different
that really would be from what this patch does, in practice.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
  2021-05-24 14:16 ` Rafael J. Wysocki
@ 2021-06-07  7:25   ` Viresh Kumar
  2021-06-07 11:02     ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: Viresh Kumar @ 2021-06-07  7:25 UTC (permalink / raw)
  To: Rafael J. Wysocki, Takashi Iwai
  Cc: Kyle Meyer, Rafael J. Wysocki, Linux Kernel Mailing List,
	Linux PM, linux-acpi

Hi Rafael,

On Mon, May 24, 2021 at 7:47 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> On Sat, May 22, 2021 at 12:19 AM Kyle Meyer <kyle.meyer@hpe.com> wrote:

> > diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> > index 7e7450453714..e79a945369d1 100644
> > --- a/drivers/cpufreq/acpi-cpufreq.c
> > +++ b/drivers/cpufreq/acpi-cpufreq.c
> > @@ -1003,7 +1003,7 @@ static int __init acpi_cpufreq_init(void)
> >
> >         /* don't keep reloading if cpufreq_driver exists */
> >         if (cpufreq_get_current_driver())
> > -               return -EEXIST;
> > +               return 0;
> >
> >         pr_debug("%s\n", __func__);
> >
> > --
>
> Applied as 5.14 material with some edits in the subject and changelog, thanks!

I am not sure how this is supposed to work. If we return 0 from
acpi_cpufreq_init(),
then the driver will never be used, since it's acpi_cpufreq_init()
will never get
called again later.

cpufreq drivers don't follow the generic device/driver model where a driver gets
probed again if a device appears and so this is broken.

Please revert this patch.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
  2021-05-21 22:19 ` Kyle Meyer
  (?)
@ 2021-05-24 14:16 ` Rafael J. Wysocki
  2021-06-07  7:25   ` Viresh Kumar
  -1 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2021-05-24 14:16 UTC (permalink / raw)
  To: Kyle Meyer
  Cc: Rafael J. Wysocki, Viresh Kumar, Linux Kernel Mailing List,
	Linux PM, linux-acpi

On Sat, May 22, 2021 at 12:19 AM Kyle Meyer <kyle.meyer@hpe.com> wrote:
>
> Revert part of commit 75c0758137c7a
> ("acpi-cpufreq: Fail initialization if driver cannot be registered").
>
> acpi-cpufreq is mutually exclusive with intel_pstate, however,
> acpi-cpufreq is loaded multiple times during startup while intel_pstate is
> enabled. On systems using systemd the kernel triggers one uevent for each
> device as a result of systemd-udev-trigger.service. The service exists to
> retrigger all devices as uevents sent by the kernel before systemd-udevd
> is running are missed. The delay caused by systemd-udevd repeatedly loading
> the driver, getting a fail return, and unloading the driver twice per
> logical CPU has a significant impact on the startup time, and can cause
> some devices to be unavailable after reaching the root login prompt.
>
> Load the driver once but skip initialization if a cpufreq driver exists by
> changing the return value of cpufreq_get_current_driver() from -EEXIST to
> 0.
>
> Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> ---
>  drivers/cpufreq/acpi-cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 7e7450453714..e79a945369d1 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -1003,7 +1003,7 @@ static int __init acpi_cpufreq_init(void)
>
>         /* don't keep reloading if cpufreq_driver exists */
>         if (cpufreq_get_current_driver())
> -               return -EEXIST;
> +               return 0;
>
>         pr_debug("%s\n", __func__);
>
> --

Applied as 5.14 material with some edits in the subject and changelog, thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
@ 2021-05-21 22:19 ` Kyle Meyer
  0 siblings, 0 replies; 8+ messages in thread
From: Kyle Meyer @ 2021-05-21 22:19 UTC (permalink / raw)
  To: rjw, viresh.kumar, linux-kernel; +Cc: linux-pm, linux-acpi, Kyle Meyer

Revert part of commit 75c0758137c7a
("acpi-cpufreq: Fail initialization if driver cannot be registered").

acpi-cpufreq is mutually exclusive with intel_pstate, however,
acpi-cpufreq is loaded multiple times during startup while intel_pstate is
enabled. On systems using systemd the kernel triggers one uevent for each
device as a result of systemd-udev-trigger.service. The service exists to
retrigger all devices as uevents sent by the kernel before systemd-udevd
is running are missed. The delay caused by systemd-udevd repeatedly loading
the driver, getting a fail return, and unloading the driver twice per
logical CPU has a significant impact on the startup time, and can cause
some devices to be unavailable after reaching the root login prompt.

Load the driver once but skip initialization if a cpufreq driver exists by
changing the return value of cpufreq_get_current_driver() from -EEXIST to
0.

Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---
 drivers/cpufreq/acpi-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 7e7450453714..e79a945369d1 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -1003,7 +1003,7 @@ static int __init acpi_cpufreq_init(void)
 
 	/* don't keep reloading if cpufreq_driver exists */
 	if (cpufreq_get_current_driver())
-		return -EEXIST;
+		return 0;
 
 	pr_debug("%s\n", __func__);
 
-- 
2.26.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists
@ 2021-05-21 22:19 ` Kyle Meyer
  0 siblings, 0 replies; 8+ messages in thread
From: Kyle Meyer @ 2021-05-21 22:19 UTC (permalink / raw)
  To: rjw, viresh.kumar, linux-kernel; +Cc: linux-pm, linux-acpi, Kyle Meyer

Revert part of commit 75c0758137c7a
("acpi-cpufreq: Fail initialization if driver cannot be registered").

acpi-cpufreq is mutually exclusive with intel_pstate, however,
acpi-cpufreq is loaded multiple times during startup while intel_pstate is
enabled. On systems using systemd the kernel triggers one uevent for each
device as a result of systemd-udev-trigger.service. The service exists to
retrigger all devices as uevents sent by the kernel before systemd-udevd
is running are missed. The delay caused by systemd-udevd repeatedly loading
the driver, getting a fail return, and unloading the driver twice per
logical CPU has a significant impact on the startup time, and can cause
some devices to be unavailable after reaching the root login prompt.

Load the driver once but skip initialization if a cpufreq driver exists by
changing the return value of cpufreq_get_current_driver() from -EEXIST to
0.

Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---
 drivers/cpufreq/acpi-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 7e7450453714..e79a945369d1 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -1003,7 +1003,7 @@ static int __init acpi_cpufreq_init(void)
 
 	/* don't keep reloading if cpufreq_driver exists */
 	if (cpufreq_get_current_driver())
-		return -EEXIST;
+		return 0;
 
 	pr_debug("%s\n", __func__);
 
-- 
2.26.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-07 11:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 19:34 [PATCH] acpi-cpufreq: Skip initialization if a cpufreq driver exists kyle.meyer
2021-05-21 13:01 ` Rafael J. Wysocki
2021-05-21 22:19 Kyle Meyer
2021-05-21 22:19 ` Kyle Meyer
2021-05-24 14:16 ` Rafael J. Wysocki
2021-06-07  7:25   ` Viresh Kumar
2021-06-07 11:02     ` Rafael J. Wysocki
2021-06-07 11:14       ` Viresh Kumar

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.