Essential Android Android Kernel Optimization edit forum

How to add a CPU Governor

The CPU governor itself is just 1 C file, which is located in kernel_source/drivers/cpufreq/, for example: cpufreq_smartass2.c. You are responsible yourself for find the governor (look in an existing kernel repo for your device) But in order to successfully call and compile this file into your kernel you will have to make the following changes:

  1. Copy your governor file (cpufreq_govname.c) and browse to kernel_source/drivers/cpufreq, now paste it.
  2. and open Kconfig (this is the interface of the config menu layout) when adding a kernel, you want it to show up in your config. You can do that by adding the choice of governor.
tristate "'gov_name_lowercase' cpufreq governor"
depends on CPU_FREQ
governor' - a custom governor!

for example, for smartassV2.

 tristate "'smartassV2' cpufreq governor"
 depends on CPU_FREQ
 'smartassV2' - a "smart" optimized governor!

next to adding the choice, you also must declare the possibility that the governor gets chosen as default governor.

bool "gov_name_lowercase"
Use the CPUFreq governor 'govname' as default.

for example, for smartassV2.

 bool "smartass2"
 Use the CPUFreq governor 'smartassV2' as default.

– can’t find the right place to put it? Just search for “CPU_FREQ_GOV_CONSERVATIVE”, and place the code beneath, same thing counts for “CPU_FREQ_DEFAULT_GOV_CONSERVATIVE”

Now that Kconfig is finished you can save and close the file. 3. While still in the /drivers/cpufreq folder, open Makefile. In Makefile, add the line corresponding to your CPU Governor. for example:

obj-$(CONFIG_CPU_FREQ_GOV_SMARTASS2)    += cpufreq_smartass2.o

Be ware that you do not call the native C file, but the O file! which is the compiled C file. Save the file. 4. Move to: kernel_source/includes/linux. Now open cpufreq.h Scroll down until you see something like:

 extern struct cpufreq_governor cpufreq_gov_ondemand;
 #define CPUFREQ_DEFAULT_GOVERNOR    (&cpufreq_gov_ondemand)

(other cpu governors are also listed there)

Now add your entry with the selected CPU Governor, example:

 extern struct cpufreq_governor cpufreq_gov_smartass2;
 #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_smartass2)

Save the file and close it.

The initial CPU Governor setup is now complete. when you’ve done all steps successfully, you should be able to choose your governor from the menu (menuconfig, xconfig, gconfig, nconfig). Once checked in the menu it will be included to the kernel.

Commit that is nearly the same as above instructions: Add smartassV2 and lulzactive governor commit

Table Of Contents
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
216 Android Kernel Optimization
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close