mbox series

[V4,0/3] cpufreq: Allow default governor on cmdline and fix locking issues

Message ID cover.1593418662.git.viresh.kumar@linaro.org
Headers show
Series cpufreq: Allow default governor on cmdline and fix locking issues | expand

Message

Viresh Kumar June 29, 2020, 8:24 a.m. UTC
Hi,

I have picked Quentin's series over my patch, modified both and tested.

V3->V4:
- Do __module_get() for cpufreq_default_governor() case as well and get
  rid of an extra variable.
- Use a single character array, default_governor, instead of two of them.

V2->V3:
- default_governor is a string now and we don't set it on governor
  registration or unregistration anymore.
- Fixed locking issues in cpufreq_init_policy().

--
Viresh

Original cover letter fro Quentin:

This series enables users of prebuilt kernels (e.g. distro kernels) to
specify their CPUfreq governor of choice using the kernel command line,
instead of having to wait for the system to fully boot to userspace to
switch using the sysfs interface. This is helpful for 2 reasons:
  1. users get to choose the governor that runs during the actual boot;
  2. it simplifies the userspace boot procedure a bit (one less thing to
     worry about).

To enable this, the first patch moves all governor init calls to
core_initcall, to make sure they are registered by the time the drivers
probe. This should be relatively low impact as registering a governor
is a simple procedure (it gets added to a llist), and all governors
already load at core_initcall anyway when they're set as the default
in Kconfig. This also allows to clean-up the governors' init/exit code,
and reduces boilerplate.

The second patch introduces the new command line parameter, inspired by
its cpuidle counterpart. More details can be found in the respective
patch headers.

Changes in v2:
 - added Viresh's ack to patch 01
 - moved the assignment of 'default_governor' in patch 02 to the governor
   registration path instead of the driver registration (Viresh)

Quentin Perret (2):
  cpufreq: Register governors at core_initcall
  cpufreq: Specify default governor on command line

Viresh Kumar (1):
  cpufreq: Fix locking issues with governors

 .../admin-guide/kernel-parameters.txt         |  5 ++
 Documentation/admin-guide/pm/cpufreq.rst      |  6 +-
 .../platforms/cell/cpufreq_spudemand.c        | 26 +-----
 drivers/cpufreq/cpufreq.c                     | 87 ++++++++++++-------
 drivers/cpufreq/cpufreq_conservative.c        | 22 ++---
 drivers/cpufreq/cpufreq_ondemand.c            | 24 ++---
 drivers/cpufreq/cpufreq_performance.c         | 14 +--
 drivers/cpufreq/cpufreq_powersave.c           | 18 +---
 drivers/cpufreq/cpufreq_userspace.c           | 18 +---
 include/linux/cpufreq.h                       | 14 +++
 kernel/sched/cpufreq_schedutil.c              |  6 +-
 11 files changed, 100 insertions(+), 140 deletions(-)

-- 
2.25.0.rc1.19.g042ed3e048af

Comments

Quentin Perret June 29, 2020, 9:37 a.m. UTC | #1
On Monday 29 Jun 2020 at 13:54:58 (+0530), Viresh Kumar wrote:
> The locking around governors handling isn't adequate currently. The list

> of governors should never be traversed without locking in place. Also we

> must make sure the governor isn't removed while it is still referenced

> by code.

> 

> Reported-by: Quentin Perret <qperret@google.com>


Reviewed-by: Quentin Perret <qperret@google.com>


Thanks!
Quentin
Rafael J. Wysocki June 30, 2020, 6:38 p.m. UTC | #2
On Mon, Jun 29, 2020 at 10:58 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>

> Hi,

>

> I have picked Quentin's series over my patch, modified both and tested.

>

> V3->V4:

> - Do __module_get() for cpufreq_default_governor() case as well and get

>   rid of an extra variable.

> - Use a single character array, default_governor, instead of two of them.

>

> V2->V3:

> - default_governor is a string now and we don't set it on governor

>   registration or unregistration anymore.

> - Fixed locking issues in cpufreq_init_policy().

>

> --

> Viresh

>

> Original cover letter fro Quentin:

>

> This series enables users of prebuilt kernels (e.g. distro kernels) to

> specify their CPUfreq governor of choice using the kernel command line,

> instead of having to wait for the system to fully boot to userspace to

> switch using the sysfs interface. This is helpful for 2 reasons:

>   1. users get to choose the governor that runs during the actual boot;

>   2. it simplifies the userspace boot procedure a bit (one less thing to

>      worry about).

>

> To enable this, the first patch moves all governor init calls to

> core_initcall, to make sure they are registered by the time the drivers

> probe. This should be relatively low impact as registering a governor

> is a simple procedure (it gets added to a llist), and all governors

> already load at core_initcall anyway when they're set as the default

> in Kconfig. This also allows to clean-up the governors' init/exit code,

> and reduces boilerplate.

>

> The second patch introduces the new command line parameter, inspired by

> its cpuidle counterpart. More details can be found in the respective

> patch headers.

>

> Changes in v2:

>  - added Viresh's ack to patch 01

>  - moved the assignment of 'default_governor' in patch 02 to the governor

>    registration path instead of the driver registration (Viresh)

>

> Quentin Perret (2):

>   cpufreq: Register governors at core_initcall

>   cpufreq: Specify default governor on command line

>

> Viresh Kumar (1):

>   cpufreq: Fix locking issues with governors

>

>  .../admin-guide/kernel-parameters.txt         |  5 ++

>  Documentation/admin-guide/pm/cpufreq.rst      |  6 +-

>  .../platforms/cell/cpufreq_spudemand.c        | 26 +-----

>  drivers/cpufreq/cpufreq.c                     | 87 ++++++++++++-------

>  drivers/cpufreq/cpufreq_conservative.c        | 22 ++---

>  drivers/cpufreq/cpufreq_ondemand.c            | 24 ++---

>  drivers/cpufreq/cpufreq_performance.c         | 14 +--

>  drivers/cpufreq/cpufreq_powersave.c           | 18 +---

>  drivers/cpufreq/cpufreq_userspace.c           | 18 +---

>  include/linux/cpufreq.h                       | 14 +++

>  kernel/sched/cpufreq_schedutil.c              |  6 +-

>  11 files changed, 100 insertions(+), 140 deletions(-)

>

> --


All three patches applied as 5.9 material, thanks!