Skip to content

Commit 61cb575

Browse files
committed
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>
1 parent 800fb34 commit 61cb575

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,9 @@
674674
cpuidle.off=1 [CPU_IDLE]
675675
disable the cpuidle sub-system
676676

677+
cpuidle.governor=
678+
[CPU_IDLE] Name of the cpuidle governor to use.
679+
677680
cpufreq.off=1 [CPU_FREQ]
678681
disable the cpufreq sub-system
679682

Documentation/admin-guide/pm/cpuidle.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,13 @@ processors implementing the architecture (i.e. CPU instruction set) in question,
566566
however, so it is rather crude and not very energy-efficient. For this reason,
567567
it is not recommended for production use.
568568

569+
The ``cpuidle.governor=`` kernel command line switch allows the ``CPUIdle``
570+
governor to use to be specified. It has to be appended with a string matching
571+
the name of an available governor (e.g. ``cpuidle.governor=menu``) and that
572+
governor will be used instead of the default one. It is possible to force
573+
the ``menu`` governor to be used on the systems that use the ``ladder`` governor
574+
by default this way, for example.
575+
569576
The other kernel command line parameters controlling CPU idle time management
570577
described below are only relevant for the *x86* architecture and some of
571578
them affect Intel processors only.

drivers/cpuidle/cpuidle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,5 @@ static int __init cpuidle_init(void)
702702
}
703703

704704
module_param(off, int, 0444);
705+
module_param_string(governor, param_governor, CPUIDLE_NAME_LEN, 0444);
705706
core_initcall(cpuidle_init);

drivers/cpuidle/cpuidle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define __DRIVER_CPUIDLE_H
88

99
/* For internal use only */
10+
extern char param_governor[];
1011
extern struct cpuidle_governor *cpuidle_curr_governor;
1112
extern struct list_head cpuidle_governors;
1213
extern struct list_head cpuidle_detected_devices;

drivers/cpuidle/governor.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
#include <linux/cpu.h>
1212
#include <linux/cpuidle.h>
1313
#include <linux/mutex.h>
14+
#include <linux/module.h>
1415
#include <linux/pm_qos.h>
1516

1617
#include "cpuidle.h"
1718

19+
char param_governor[CPUIDLE_NAME_LEN];
20+
1821
LIST_HEAD(cpuidle_governors);
1922
struct cpuidle_governor *cpuidle_curr_governor;
2023

@@ -86,9 +89,11 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
8689
mutex_lock(&cpuidle_lock);
8790
if (__cpuidle_find_governor(gov->name) == NULL) {
8891
ret = 0;
89-
list_add_tail(&gov->governor_list, &cpuidle_governors);
9092
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)))
9297
cpuidle_switch_governor(gov);
9398
}
9499
mutex_unlock(&cpuidle_lock);

0 commit comments

Comments
 (0)