From: Severi Salminen <severi.salminen@iki.fi>
To: cpufreq@lists.linux.org.uk
Subject: [PATCH] Allow any governor to be used as default
Date: Tue, 29 May 2007 23:11:58 +0300 [thread overview]
Message-ID: <465C890E.5040300@iki.fi> (raw)
[-- Attachment #1: Type: text/plain, Size: 6313 bytes --]
This patch allows the user to select any cpufreq governor as the default
governor - not just 'performance' or 'userspave'. This patch is inspired
by and based on the patch provided in this bug:
http://bugme.osdl.org/show_bug.cgi?id=8384
The above patch, however, doesn't allow the selection of 'ondemand' or
'conservative'.
I added the necessary descriptions and options to Kconfig, made relevant
functions non-static and updated cpufreq.h.
In order to allow the selection of 'ondemand' or 'conservative' I had to
rename a function cpufreq_gov_dbs() in cpufreq_ondemand.c and
cpufreq_conservative.c to prevent name collision - the function has to
be non-static. The functions are now cpufreq_gov_ondemand() and
cpufreq_gov_conservative(). I think this is more in line with the naming
of other governors.
Those two files also have functions cpufreq_gov_dbs_init() and
cpufreq_gov_dbs_exit(). They could also be renamed for consistency but
it is not necessary as they are both static. I didn't touch them in this
patch.
This patch works on 2.6.21.2.
PS. This is my first patch so any feedback concerning anything is welcome.
Signed-off-by: Severi Salminen <severi.salminen@iki.fi>
---
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_conservative.c
linux-2.6.21.2/drivers/cpufreq/cpufreq_conservative.c
--- linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_conservative.c
2007-05-24 00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/cpufreq_conservative.c 2007-05-24
16:16:17.000000000 +0300
@@ -551,7 +551,7 @@
return 0;
}
-static struct cpufreq_governor cpufreq_gov_dbs = {
+struct cpufreq_governor cpufreq_gov_conservative = {
.name = "conservative",
.governor = cpufreq_governor_dbs,
.owner = THIS_MODULE,
@@ -559,7 +559,7 @@
static int __init cpufreq_gov_dbs_init(void)
{
- return cpufreq_register_governor(&cpufreq_gov_dbs);
+ return cpufreq_register_governor(&cpufreq_gov_conservative);
}
static void __exit cpufreq_gov_dbs_exit(void)
@@ -567,7 +567,7 @@
/* Make sure that the scheduled work is indeed not running */
flush_scheduled_work();
- cpufreq_unregister_governor(&cpufreq_gov_dbs);
+ cpufreq_unregister_governor(&cpufreq_gov_conservative);
}
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_ondemand.c
linux-2.6.21.2/drivers/cpufreq/cpufreq_ondemand.c
--- linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_ondemand.c 2007-05-24
00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/cpufreq_ondemand.c 2007-05-24
16:15:42.000000000 +0300
@@ -573,7 +573,7 @@
return 0;
}
-static struct cpufreq_governor cpufreq_gov_dbs = {
+struct cpufreq_governor cpufreq_gov_ondemand = {
.name = "ondemand",
.governor = cpufreq_governor_dbs,
.owner = THIS_MODULE,
@@ -586,12 +586,12 @@
printk(KERN_ERR "Creation of kondemand failed\n");
return -EFAULT;
}
- return cpufreq_register_governor(&cpufreq_gov_dbs);
+ return cpufreq_register_governor(&cpufreq_gov_ondemand);
}
static void __exit cpufreq_gov_dbs_exit(void)
{
- cpufreq_unregister_governor(&cpufreq_gov_dbs);
+ cpufreq_unregister_governor(&cpufreq_gov_ondemand);
destroy_workqueue(kondemand_wq);
}
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_powersave.c
linux-2.6.21.2/drivers/cpufreq/cpufreq_powersave.c
--- linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_powersave.c
2007-05-24 00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/cpufreq_powersave.c 2007-05-24
15:18:49.000000000 +0300
@@ -35,7 +35,7 @@
return 0;
}
-static struct cpufreq_governor cpufreq_gov_powersave = {
+struct cpufreq_governor cpufreq_gov_powersave = {
.name = "powersave",
.governor = cpufreq_governor_powersave,
.owner = THIS_MODULE,
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/Kconfig
linux-2.6.21.2/drivers/cpufreq/Kconfig
--- linux-2.6.21.2-vanilla/drivers/cpufreq/Kconfig 2007-05-24
00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/Kconfig 2007-05-24 16:20:06.000000000
+0300
@@ -66,6 +66,14 @@
the frequency statically to the highest frequency supported by
the CPU.
+config CPU_FREQ_DEFAULT_GOV_POWERSAVE
+ bool "powersave"
+ select CPU_FREQ_GOV_POWERSAVE
+ help
+ Use the CPUFreq governor 'powersave' as default. This sets
+ the frequency statically to the lowest frequency supported by
+ the CPU.
+
config CPU_FREQ_DEFAULT_GOV_USERSPACE
bool "userspace"
select CPU_FREQ_GOV_USERSPACE
@@ -75,6 +83,22 @@
program shall be able to set the CPU dynamically without having
to enable the userspace governor manually.
+config CPU_FREQ_DEFAULT_GOV_ONDEMAND
+ bool "ondemand"
+ select CPU_FREQ_GOV_ONDEMAND
+ help
+ Use the CPUFreq governor 'ondemand' as default. This governor
+ does a periodic polling and changes frequency based on the
+ CPU utilization.
+
+config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
+ bool "conservative"
+ select CPU_FREQ_GOV_CONSERVATIVE
+ help
+ Use the CPUFreq governor 'conservative' as default. This governor
+ does a periodic polling and changes frequency based on the
+ CPU utilization.
+
endchoice
config CPU_FREQ_GOV_PERFORMANCE
diff -ur linux-2.6.21.2-vanilla/include/linux/cpufreq.h
linux-2.6.21.2/include/linux/cpufreq.h
--- linux-2.6.21.2-vanilla/include/linux/cpufreq.h 2007-05-24
00:33:55.000000000 +0300
+++ linux-2.6.21.2/include/linux/cpufreq.h 2007-05-24 15:45:38.000000000
+0300
@@ -283,9 +283,18 @@
#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE
extern struct cpufreq_governor cpufreq_gov_performance;
#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_performance
+#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE)
+extern struct cpufreq_governor cpufreq_gov_powersave;
+#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_powersave
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE)
extern struct cpufreq_governor cpufreq_gov_userspace;
#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_userspace
+#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND)
+extern struct cpufreq_governor cpufreq_gov_ondemand;
+#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_ondemand
+#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE)
+extern struct cpufreq_governor cpufreq_gov_conservative;
+#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_conservative
#endif
[-- Attachment #2: cpufreq.patch --]
[-- Type: text/plain, Size: 5137 bytes --]
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_conservative.c linux-2.6.21.2/drivers/cpufreq/cpufreq_conservative.c
--- linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_conservative.c 2007-05-24 00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/cpufreq_conservative.c 2007-05-24 16:16:17.000000000 +0300
@@ -551,7 +551,7 @@
return 0;
}
-static struct cpufreq_governor cpufreq_gov_dbs = {
+struct cpufreq_governor cpufreq_gov_conservative = {
.name = "conservative",
.governor = cpufreq_governor_dbs,
.owner = THIS_MODULE,
@@ -559,7 +559,7 @@
static int __init cpufreq_gov_dbs_init(void)
{
- return cpufreq_register_governor(&cpufreq_gov_dbs);
+ return cpufreq_register_governor(&cpufreq_gov_conservative);
}
static void __exit cpufreq_gov_dbs_exit(void)
@@ -567,7 +567,7 @@
/* Make sure that the scheduled work is indeed not running */
flush_scheduled_work();
- cpufreq_unregister_governor(&cpufreq_gov_dbs);
+ cpufreq_unregister_governor(&cpufreq_gov_conservative);
}
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_ondemand.c linux-2.6.21.2/drivers/cpufreq/cpufreq_ondemand.c
--- linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_ondemand.c 2007-05-24 00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/cpufreq_ondemand.c 2007-05-24 16:15:42.000000000 +0300
@@ -573,7 +573,7 @@
return 0;
}
-static struct cpufreq_governor cpufreq_gov_dbs = {
+struct cpufreq_governor cpufreq_gov_ondemand = {
.name = "ondemand",
.governor = cpufreq_governor_dbs,
.owner = THIS_MODULE,
@@ -586,12 +586,12 @@
printk(KERN_ERR "Creation of kondemand failed\n");
return -EFAULT;
}
- return cpufreq_register_governor(&cpufreq_gov_dbs);
+ return cpufreq_register_governor(&cpufreq_gov_ondemand);
}
static void __exit cpufreq_gov_dbs_exit(void)
{
- cpufreq_unregister_governor(&cpufreq_gov_dbs);
+ cpufreq_unregister_governor(&cpufreq_gov_ondemand);
destroy_workqueue(kondemand_wq);
}
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_powersave.c linux-2.6.21.2/drivers/cpufreq/cpufreq_powersave.c
--- linux-2.6.21.2-vanilla/drivers/cpufreq/cpufreq_powersave.c 2007-05-24 00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/cpufreq_powersave.c 2007-05-24 15:18:49.000000000 +0300
@@ -35,7 +35,7 @@
return 0;
}
-static struct cpufreq_governor cpufreq_gov_powersave = {
+struct cpufreq_governor cpufreq_gov_powersave = {
.name = "powersave",
.governor = cpufreq_governor_powersave,
.owner = THIS_MODULE,
diff -ur linux-2.6.21.2-vanilla/drivers/cpufreq/Kconfig linux-2.6.21.2/drivers/cpufreq/Kconfig
--- linux-2.6.21.2-vanilla/drivers/cpufreq/Kconfig 2007-05-24 00:33:55.000000000 +0300
+++ linux-2.6.21.2/drivers/cpufreq/Kconfig 2007-05-24 16:20:06.000000000 +0300
@@ -66,6 +66,14 @@
the frequency statically to the highest frequency supported by
the CPU.
+config CPU_FREQ_DEFAULT_GOV_POWERSAVE
+ bool "powersave"
+ select CPU_FREQ_GOV_POWERSAVE
+ help
+ Use the CPUFreq governor 'powersave' as default. This sets
+ the frequency statically to the lowest frequency supported by
+ the CPU.
+
config CPU_FREQ_DEFAULT_GOV_USERSPACE
bool "userspace"
select CPU_FREQ_GOV_USERSPACE
@@ -75,6 +83,22 @@
program shall be able to set the CPU dynamically without having
to enable the userspace governor manually.
+config CPU_FREQ_DEFAULT_GOV_ONDEMAND
+ bool "ondemand"
+ select CPU_FREQ_GOV_ONDEMAND
+ help
+ Use the CPUFreq governor 'ondemand' as default. This governor
+ does a periodic polling and changes frequency based on the
+ CPU utilization.
+
+config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
+ bool "conservative"
+ select CPU_FREQ_GOV_CONSERVATIVE
+ help
+ Use the CPUFreq governor 'conservative' as default. This governor
+ does a periodic polling and changes frequency based on the
+ CPU utilization.
+
endchoice
config CPU_FREQ_GOV_PERFORMANCE
diff -ur linux-2.6.21.2-vanilla/include/linux/cpufreq.h linux-2.6.21.2/include/linux/cpufreq.h
--- linux-2.6.21.2-vanilla/include/linux/cpufreq.h 2007-05-24 00:33:55.000000000 +0300
+++ linux-2.6.21.2/include/linux/cpufreq.h 2007-05-24 15:45:38.000000000 +0300
@@ -283,9 +283,18 @@
#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE
extern struct cpufreq_governor cpufreq_gov_performance;
#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_performance
+#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE)
+extern struct cpufreq_governor cpufreq_gov_powersave;
+#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_powersave
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE)
extern struct cpufreq_governor cpufreq_gov_userspace;
#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_userspace
+#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND)
+extern struct cpufreq_governor cpufreq_gov_ondemand;
+#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_ondemand
+#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE)
+extern struct cpufreq_governor cpufreq_gov_conservative;
+#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_conservative
#endif
[-- Attachment #3: Type: text/plain, Size: 147 bytes --]
_______________________________________________
Cpufreq mailing list
Cpufreq@lists.linux.org.uk
http://lists.linux.org.uk/mailman/listinfo/cpufreq
reply other threads:[~2007-05-29 20:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=465C890E.5040300@iki.fi \
--to=severi.salminen@iki.fi \
--cc=cpufreq@lists.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.