]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cpuidle: Add cpuidle.governor= command line parameter
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 5 Dec 2018 22:45:34 +0000 (23:45 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 11 Dec 2018 11:08:44 +0000 (12:08 +0100)
Add cpuidle.governor= command line parameter to allow the default
cpuidle governor to be replaced.

That is useful, for example, if someone running a tickful kernel
wants to use the menu governor on it.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/admin-guide/kernel-parameters.txt
Documentation/admin-guide/pm/cpuidle.rst
drivers/cpuidle/cpuidle.c
drivers/cpuidle/cpuidle.h
drivers/cpuidle/governor.c

index 19f4423e70d913ea2bf0801e4e14b57dc74e320f..60fb9913af48aff4ae37bb31beca3ec1eeef4a74 100644 (file)
        cpuidle.off=1   [CPU_IDLE]
                        disable the cpuidle sub-system
 
+       cpuidle.governor=
+                       [CPU_IDLE] Name of the cpuidle governor to use.
+
        cpufreq.off=1   [CPU_FREQ]
                        disable the cpufreq sub-system
 
index 80b4f26547ac6b09a7bfa565e6277a719d9ec1bc..9a34484fd6e45304a3d71a65c1894bc8383c9eb7 100644 (file)
@@ -566,6 +566,13 @@ processors implementing the architecture (i.e. CPU instruction set) in question,
 however, so it is rather crude and not very energy-efficient.  For this reason,
 it is not recommended for production use.
 
+The ``cpuidle.governor=`` kernel command line switch allows the ``CPUIdle``
+governor to use to be specified.  It has to be appended with a string matching
+the name of an available governor (e.g. ``cpuidle.governor=menu``) and that
+governor will be used instead of the default one.  It is possible to force
+the ``menu`` governor to be used on the systems that use the ``ladder`` governor
+by default this way, for example.
+
 The other kernel command line parameters controlling CPU idle time management
 described below are only relevant for the *x86* architecture and some of
 them affect Intel processors only.
index 4a97446f66d836bbf4129454420108313872b26e..f7c58043e50f3b1205ee35c7b104a3ea748f2c6d 100644 (file)
@@ -702,4 +702,5 @@ static int __init cpuidle_init(void)
 }
 
 module_param(off, int, 0444);
+module_param_string(governor, param_governor, CPUIDLE_NAME_LEN, 0444);
 core_initcall(cpuidle_init);
index 2965ab32a583f769ea919c30427eb7255b04909a..d6613101af9246ee112df42c36a5abd2d63ceb56 100644 (file)
@@ -7,6 +7,7 @@
 #define __DRIVER_CPUIDLE_H
 
 /* For internal use only */
+extern char param_governor[];
 extern struct cpuidle_governor *cpuidle_curr_governor;
 extern struct list_head cpuidle_governors;
 extern struct list_head cpuidle_detected_devices;
index 9fed1b82929278d08d3aa8ef26c77ebd705fbd1f..bb93e5cf6a4ae5ca386ef8bb67fbe22d6d8c651d 100644 (file)
 #include <linux/cpu.h>
 #include <linux/cpuidle.h>
 #include <linux/mutex.h>
+#include <linux/module.h>
 #include <linux/pm_qos.h>
 
 #include "cpuidle.h"
 
+char param_governor[CPUIDLE_NAME_LEN];
+
 LIST_HEAD(cpuidle_governors);
 struct cpuidle_governor *cpuidle_curr_governor;
 
@@ -86,9 +89,11 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
        mutex_lock(&cpuidle_lock);
        if (__cpuidle_find_governor(gov->name) == NULL) {
                ret = 0;
-               list_add_tail(&gov->governor_list, &cpuidle_governors);
                if (!cpuidle_curr_governor ||
-                   cpuidle_curr_governor->rating < gov->rating)
+                   !strncasecmp(param_governor, gov->name, CPUIDLE_NAME_LEN) ||
+                   (cpuidle_curr_governor->rating < gov->rating &&
+                    strncasecmp(param_governor, cpuidle_curr_governor->name,
+                                CPUIDLE_NAME_LEN)))
                        cpuidle_switch_governor(gov);
        }
        mutex_unlock(&cpuidle_lock);