Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: Initialise default governor before use

When the cpufreq driver starts up at boot time, it calls into the default
governor which might not be initialised yet. This hurts when the
governor's worker function relies on memory that is not yet set up by its
init function.

This migrates all governors from module_init() to fs_initcall() when being
the default, as was already done in cpufreq_performance when it was the
only possible choice. The performance governor is always initialized early
because it might be used as fallback even when not being the default.

Fixes at least one actual oops where ondemand is the default governor and
cpufreq_governor_dbs() uses the uninitialised kondemand_wq work-queue
during boot-time.

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Johannes Weiner and committed by
Linus Torvalds
6915719b d8c89eb3

+12 -1
+4
drivers/cpufreq/cpufreq_conservative.c
··· 603 603 "optimised for use in a battery environment"); 604 604 MODULE_LICENSE ("GPL"); 605 605 606 + #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE 607 + fs_initcall(cpufreq_gov_dbs_init); 608 + #else 606 609 module_init(cpufreq_gov_dbs_init); 610 + #endif 607 611 module_exit(cpufreq_gov_dbs_exit);
+4 -1
drivers/cpufreq/cpufreq_ondemand.c
··· 610 610 "Low Latency Frequency Transition capable processors"); 611 611 MODULE_LICENSE("GPL"); 612 612 613 + #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND 614 + fs_initcall(cpufreq_gov_dbs_init); 615 + #else 613 616 module_init(cpufreq_gov_dbs_init); 617 + #endif 614 618 module_exit(cpufreq_gov_dbs_exit); 615 -
+4
drivers/cpufreq/cpufreq_userspace.c
··· 231 231 MODULE_DESCRIPTION ("CPUfreq policy governor 'userspace'"); 232 232 MODULE_LICENSE ("GPL"); 233 233 234 + #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE 234 235 fs_initcall(cpufreq_gov_userspace_init); 236 + #else 237 + module_init(cpufreq_gov_userspace_init); 238 + #endif 235 239 module_exit(cpufreq_gov_userspace_exit);