cpuidle: governor: Add new governors to cpuidle_governors again

This change “cpuidle: governor: Add new governors to cpuidle_governors again” in Linux kernel is authored by Rafael J. Wysocki <rafael.j.wysocki [at] intel.com> on Tue Mar 12 19:13:13 2019 +0100.

cpuidle: governor: Add new governors to cpuidle_governors again

After commit 61cb5758d3c4 ("cpuidle: Add cpuidle.governor= command
line parameter") new cpuidle governors are not added to the list
of available governors, so governor selection via sysfs doesn't
work as expected (even though it is rarely used anyway).

Fix that by making cpuidle_register_governor() add new governors to
cpuidle_governors again.

Fixes: 61cb5758d3c4 ("cpuidle: Add cpuidle.governor= command line parameter")
Reported-by: Kees Cook <keescook@chromium.org>
Cc: 5.0+ <stable@vger.kernel.org> # 5.0+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit 22782b3.

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/cpuidle/governor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
index bb93e5c..9fddf82 100644
--- a/drivers/cpuidle/governor.c
+++ b/drivers/cpuidle/governor.c
@@ -89,6 +89,7 @@ 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 ||
 		    !strncasecmp(param_governor, gov->name, CPUIDLE_NAME_LEN) ||
 		    (cpuidle_curr_governor->rating < gov->rating &&

The commit for this change in Linux stable tree is 22782b3 (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *