aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-12-05 17:45:34 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-12-11 06:08:44 -0500
commit61cb5758d3c46bc1ba87694fefc0d9653613ce6b (patch)
tree122cbd1c3de0c1c3bf4591fb975e4de6d4de3ca0
parent800fb34a99ce7d22dca839c90f869c7a12b50f70 (diff)
cpuidle: Add cpuidle.governor= command line parameter
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>
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt3
-rw-r--r--Documentation/admin-guide/pm/cpuidle.rst7
-rw-r--r--drivers/cpuidle/cpuidle.c1
-rw-r--r--drivers/cpuidle/cpuidle.h1
-rw-r--r--drivers/cpuidle/governor.c9
5 files changed, 19 insertions, 2 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 19f4423e70d9..60fb9913af48 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -674,6 +674,9 @@
674 cpuidle.off=1 [CPU_IDLE] 674 cpuidle.off=1 [CPU_IDLE]
675 disable the cpuidle sub-system 675 disable the cpuidle sub-system
676 676
677 cpuidle.governor=
678 [CPU_IDLE] Name of the cpuidle governor to use.
679
677 cpufreq.off=1 [CPU_FREQ] 680 cpufreq.off=1 [CPU_FREQ]
678 disable the cpufreq sub-system 681 disable the cpufreq sub-system
679 682
diff --git a/Documentation/admin-guide/pm/cpuidle.rst b/Documentation/admin-guide/pm/cpuidle.rst
index 80b4f26547ac..9a34484fd6e4 100644
--- a/Documentation/admin-guide/pm/cpuidle.rst
+++ b/Documentation/admin-guide/pm/cpuidle.rst
@@ -566,6 +566,13 @@ processors implementing the architecture (i.e. CPU instruction set) in question,
566however, so it is rather crude and not very energy-efficient. For this reason, 566however, so it is rather crude and not very energy-efficient. For this reason,
567it is not recommended for production use. 567it is not recommended for production use.
568 568
569The ``cpuidle.governor=`` kernel command line switch allows the ``CPUIdle``
570governor to use to be specified. It has to be appended with a string matching
571the name of an available governor (e.g. ``cpuidle.governor=menu``) and that
572governor will be used instead of the default one. It is possible to force
573the ``menu`` governor to be used on the systems that use the ``ladder`` governor
574by default this way, for example.
575
569The other kernel command line parameters controlling CPU idle time management 576The other kernel command line parameters controlling CPU idle time management
570described below are only relevant for the *x86* architecture and some of 577described below are only relevant for the *x86* architecture and some of
571them affect Intel processors only. 578them affect Intel processors only.
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 4a97446f66d8..f7c58043e50f 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -702,4 +702,5 @@ static int __init cpuidle_init(void)
702} 702}
703 703
704module_param(off, int, 0444); 704module_param(off, int, 0444);
705module_param_string(governor, param_governor, CPUIDLE_NAME_LEN, 0444);
705core_initcall(cpuidle_init); 706core_initcall(cpuidle_init);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 2965ab32a583..d6613101af92 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -7,6 +7,7 @@
7#define __DRIVER_CPUIDLE_H 7#define __DRIVER_CPUIDLE_H
8 8
9/* For internal use only */ 9/* For internal use only */
10extern char param_governor[];
10extern struct cpuidle_governor *cpuidle_curr_governor; 11extern struct cpuidle_governor *cpuidle_curr_governor;
11extern struct list_head cpuidle_governors; 12extern struct list_head cpuidle_governors;
12extern struct list_head cpuidle_detected_devices; 13extern struct list_head cpuidle_detected_devices;
diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
index 9fed1b829292..bb93e5cf6a4a 100644
--- a/drivers/cpuidle/governor.c
+++ b/drivers/cpuidle/governor.c
@@ -11,10 +11,13 @@
11#include <linux/cpu.h> 11#include <linux/cpu.h>
12#include <linux/cpuidle.h> 12#include <linux/cpuidle.h>
13#include <linux/mutex.h> 13#include <linux/mutex.h>
14#include <linux/module.h>
14#include <linux/pm_qos.h> 15#include <linux/pm_qos.h>
15 16
16#include "cpuidle.h" 17#include "cpuidle.h"
17 18
19char param_governor[CPUIDLE_NAME_LEN];
20
18LIST_HEAD(cpuidle_governors); 21LIST_HEAD(cpuidle_governors);
19struct cpuidle_governor *cpuidle_curr_governor; 22struct cpuidle_governor *cpuidle_curr_governor;
20 23
@@ -86,9 +89,11 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
86 mutex_lock(&cpuidle_lock); 89 mutex_lock(&cpuidle_lock);
87 if (__cpuidle_find_governor(gov->name) == NULL) { 90 if (__cpuidle_find_governor(gov->name) == NULL) {
88 ret = 0; 91 ret = 0;
89 list_add_tail(&gov->governor_list, &cpuidle_governors);
90 if (!cpuidle_curr_governor || 92 if (!cpuidle_curr_governor ||
91 cpuidle_curr_governor->rating < gov->rating) 93 !strncasecmp(param_governor, gov->name, CPUIDLE_NAME_LEN) ||
94 (cpuidle_curr_governor->rating < gov->rating &&
95 strncasecmp(param_governor, cpuidle_curr_governor->name,
96 CPUIDLE_NAME_LEN)))
92 cpuidle_switch_governor(gov); 97 cpuidle_switch_governor(gov);
93 } 98 }
94 mutex_unlock(&cpuidle_lock); 99 mutex_unlock(&cpuidle_lock);