linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, rjw@rjwysocki.net
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	ilina@codeaurora.org
Subject: [PATCH 5/5] cpuidle: governor: Convert governors to modules
Date: Thu, 15 Oct 2020 16:44:31 +0200	[thread overview]
Message-ID: <20201015144431.9979-5-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20201015144431.9979-1-daniel.lezcano@linaro.org>

This patch converts the cpuidle governors into modules. Even if it is
not the utmost importance, that will be consistent with the devfreq,
the watchdog and the cpufreq governors.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/Kconfig              |  8 ++++----
 drivers/cpuidle/governors/haltpoll.c |  9 ++++++++-
 drivers/cpuidle/governors/ladder.c   | 12 ++++++++++--
 drivers/cpuidle/governors/menu.c     | 10 +++++++++-
 drivers/cpuidle/governors/teo.c      | 10 +++++++++-
 5 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index c0aeedd66f02..ff83042edd50 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -19,13 +19,13 @@ config CPU_IDLE_MULTIPLE_DRIVERS
 	bool
 
 config CPU_IDLE_GOV_LADDER
-	bool "Ladder governor (for periodic timer tick)"
+	tristate "Ladder governor (for periodic timer tick)"
 
 config CPU_IDLE_GOV_MENU
-	bool "Menu governor (for tickless system)"
+	tristate "Menu governor (for tickless system)"
 
 config CPU_IDLE_GOV_TEO
-	bool "Timer events oriented (TEO) governor (for tickless systems)"
+	tristate "Timer events oriented (TEO) governor (for tickless systems)"
 	help
 	  This governor implements a simplified idle state selection method
 	  focused on timer events and does not do any interactivity boosting.
@@ -34,7 +34,7 @@ config CPU_IDLE_GOV_TEO
 	  to use.  Say Y here if you are not happy with the alternatives.
 
 config CPU_IDLE_GOV_HALTPOLL
-	bool "Haltpoll governor (for virtualized systems)"
+	tristate "Haltpoll governor (for virtualized systems)"
 	depends on KVM_GUEST
 	help
 	  This governor implements haltpoll idle state selection, to be
diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c
index cb2a96eafc02..4756b758c324 100644
--- a/drivers/cpuidle/governors/haltpoll.c
+++ b/drivers/cpuidle/governors/haltpoll.c
@@ -146,4 +146,11 @@ static int __init init_haltpoll(void)
 	return 0;
 }
 
-postcore_initcall(init_haltpoll);
+static void __exit exit_haltpoll(void)
+{
+	cpuidle_unregister_governor(&haltpoll_governor);
+}
+
+module_init(init_haltpoll);
+module_exit(exit_haltpoll);
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index 8e9058c4ea63..78b622b75ce7 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -14,6 +14,7 @@
 
 #include <linux/kernel.h>
 #include <linux/cpuidle.h>
+#include <linux/module.h>
 #include <linux/jiffies.h>
 #include <linux/tick.h>
 
@@ -188,10 +189,17 @@ static int __init init_ladder(void)
 	 * governor is better so give it a higher rating than the menu
 	 * governor.
 	 */
-	if (!tick_nohz_enabled)
+	if (!tick_nohz_is_enabled())
 		ladder_governor.rating = 25;
 
 	return cpuidle_register_governor(&ladder_governor);
 }
 
-postcore_initcall(init_ladder);
+static void __exit exit_ladder(void)
+{
+	cpuidle_unregister_governor(&ladder_governor);
+}
+
+module_init(init_ladder);
+module_exit(exit_ladder);
+MODULE_LICENSE("GPL");
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index b0a7ad566081..fc92a5b18a7b 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -13,6 +13,7 @@
 #include <linux/time.h>
 #include <linux/ktime.h>
 #include <linux/hrtimer.h>
+#include <linux/module.h>
 #include <linux/tick.h>
 #include <linux/sched.h>
 #include <linux/sched/loadavg.h>
@@ -571,4 +572,11 @@ static int __init init_menu(void)
 	return cpuidle_register_governor(&menu_governor);
 }
 
-postcore_initcall(init_menu);
+static void __exit exit_menu(void)
+{
+	cpuidle_unregister_governor(&menu_governor);
+}
+
+module_init(init_menu);
+module_exit(exit_menu);
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index 6deaaf5f05b5..d11dab61113c 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -48,6 +48,7 @@
 #include <linux/cpuidle.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/sched/clock.h>
 #include <linux/tick.h>
 
@@ -491,4 +492,11 @@ static int __init teo_governor_init(void)
 	return cpuidle_register_governor(&teo_governor);
 }
 
-postcore_initcall(teo_governor_init);
+static void __exit teo_governor_exit(void)
+{
+	cpuidle_unregister_governor(&teo_governor);
+}
+
+module_init(teo_governor_init);
+module_exit(teo_governor_exit);
+MODULE_LICENSE("GPL v2");
-- 
2.17.1


  parent reply	other threads:[~2020-10-15 14:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 14:44 [PATCH 1/5] cpuidle: Remove pointless stub Daniel Lezcano
2020-10-15 14:44 ` [PATCH 2/5] cpuidle: governor: Encapsulate the cpuidle on/off switch Daniel Lezcano
2020-10-15 14:44 ` [PATCH 3/5] cpuidle: governor: Make possible to unregister a governor Daniel Lezcano
2020-10-15 14:44 ` [PATCH 4/5] cpuidle: governor: Export the needed symbols Daniel Lezcano
2020-11-05 14:04   ` Rafael J. Wysocki
2020-11-09 12:34     ` Peter Zijlstra
2020-10-15 14:44 ` Daniel Lezcano [this message]
2020-10-16 15:24 ` [PATCH 1/5] cpuidle: Remove pointless stub Rafael J. Wysocki
2020-10-16 20:31   ` Daniel Lezcano
2020-11-05 14:14     ` Rafael J. Wysocki
2020-11-05 15:31       ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201015144431.9979-5-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=ilina@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).