Application:Govnah

This page is currently available in these languages:
 * [[Image:Australia.png]] [[Image:USA.png]] Application:Govnah
 * [[Image:Germany.png]] Application:Govnah-DE
 * [[Image:France.png]] Application:Govnah-FR



Summary
Advanced webOS kernels provide mechanisms to control various operating parameters on the device such as clock speed. These kernels expose one or more "governors" which can control those parameters. An example of such a kernel is the UberKernel. This application is available through Preware.

Purpose
Govnah's UI provides access to:
 * A real-time graph of CPU speed, CPU temperature, memory usage and system load
 * A mechanism for setting the parameters of the governors exposed by the various Linux kernels.
 * Ability to reduce/raise the amount of power parts of the device uses to reduce battery consumption.
 * Temperature range which lowers/resets CPU frequency to cool down the device under heavy load.
 * Ability to slow down the CPU when battery is low.
 * The amount of swap that can be compressed (compcache).
 * The enabled Linux IO schedulers.
 * The enabled Linux TCP Congestion algorithms.



Installation
The following guide assumes a Palm Pre/Pre+/Pre2/Veer/TouchPad is currently running Palm's stock kernel with no over-clocking patches.


 * 1) On Preware's home screen, type "Govnah" and hit enter.
 * 2) Select "Govnah" and "Install".
 * 3) If you have not yet installed a replacement "Kernel", on Preware's home screen, type "uber" and hit enter.
 * 4) Select "UberKernel" and "Install".
 * 5) Restart your phone as prompted.

Note: See the the UberKernel page for further information on its abilities and use.



Where To Start


Profiles


Advanced Settings


CPU Frequency


Compressed Swap (compcache)


Saving your Profile


Profile Management


"Unknown" Profile

 * With webOS 2.1, HP as implemented a 10M compcache natively. This causes a problem with Govnah's abilty to assign your compcache value before the webOS's upstart scripts does which will cacue Govnah to display "Unknown" as a profile name.  To remedy:
 * 1) Save your profile with the stock 10M compcache.
 * 2) You need to edit /etc/event.d/compcache to reflect your setting.
 * The number is your target size in K. For a 14M compcache: 14 * 1024 = 14336.
 * Reboot your phone.



Real World Examples
The Uber-Kernel exposes a governor called on-demand. The on-demand governor increases and decreases clock speed based on the percentage of CPU usage.

The on-demand governor exposes the following parameters which can be set by Govnah:
 * scaling_max_freq - Set the maximum frequency your CPU is allowed to scale to.
 * scaling_min_freq - Same as scaling_max_freq but setting a minimum value.
 * sampling_rate - How often you want the kernel to look at the CPU usage (in microseconds) Typically this is set to values of 10000 or more.
 * up_threshold - This defines what the average CPU usage percentage increase between samplings for the kernel to decide to increase the CPU frequency.
 * ignore_nice_load - If '0' (its default), all processes are counted towards the 'cpu utilization' value. When set to '1', the processes that are run with a 'nice' value will not count (and thus be ignored) in the overall usage calculation.
 * powersave_bias - This modifies the behavior of the ondemand governor to save more power by reducing the target frequency by a specified percentage. The bias is in tenths of a percent (0 to 1000). A setting of 100 will result in a 10% smaller increase in CPU speed for a given usage than a setting of 0 would result in.

Each "Governor" in the kernel tells Govnah what parameters it has that may be set and may also say what the limits of those parameters are.



Generic Items (all)

 * scaling_max_freq : Set the maximum frequency your CPU(s) are allowed to scale to. Look at the output from scaling_available_frequencies
 * scaling_min_freq : Same as scaling_max_freq but setting a value that will not allow the CPU(s) to go below.

ondemand

 * sampling_rate : This is measured in microseconds (one millionth of a second). This is how often you want the kernel to look at the CPU usage and to make decisions on what to do about the frequency. Typically this is set to values of around '10000' or more. If you wanted to set the sampling rate to 1 second you would set it to 1000000 like in the following example.
 * sampling_rate_(min|max) : This is minimum and maximum sampling rates available that you may set 'sampling_rate' to. I believe in microseconds also.
 * sampling_down_factor : this parameter controls the rate that the CPU makes a decision on when to decrease the frequency. When set to its default value of '5' it means that at 1/5 the sampling_rate the kernel makes a decision to lower the frequency. Five "lower rate" decisions have to be made in a row before the CPU frequency is actually lower. If set to '1' then the frequency decreases as quickly as it increases, if set to '2' it decreases at half the rate of the increase.
 * up_threshold : This defines what the average CPU usage between the samplings of 'sampling_rate' needs to be for the kernel to make a decision on whether or not it should increase the frequency. For example when it is set to its default value of '80' it means that between the checking intervals the CPU needs to be on average more than 80% in use to then decide that the CPU frequency needs to be increased.
 * ignore_nice_load : This parameter takes a value of '0' or '1'. When set to '0' (its default), all processes are counted towards the 'cpu utilization' value. When set to '1', the processes that are run with a 'nice' value will not count (and thus be ignored) in the overall usage calculation.
 * powersave_bias : This modifies the behavior of the ondemand governor to save more power by reducing the target frequency by a specified percentage. By default, (powersave_bias = 0), the ondemand governor selects the minimum processor frequency that can still complete a workload with minimal idle time. Doing so should result in the highest performance to power efficiency ratio. In some cases, you might prefer a greater emphasis on power efficiency than performance. In this case, set the powersave_bias parameter to a value between 1 and 1000 to reduce the target frequency by one-thousandth of that value. For example, set powersave_bias to 100 for a one-tenth reduction in target frequency. In this case, if the governor chooses a target frequency of 2 GHz (with powersave_bias  = 100), the governor instead will request 1.8GHz – a one-tenth reduction. If 1.8 GHz is an exact match with an available hardware frequency (listed in the scaling_available_freq parameter), the processor is set to this frequency. If 1.8 GHz is not available, the processor fluctuates between the closest available upper and lower frequencies for an average frequency of 1.8 GHz. (from IBM web page). The original author of the ondemand powersave_bias code explains it as "For example, If ondemand requests 2.0GHz based on utilization, and powersave_bias=100, this code will knock 10% off the target and seek a target of 1.8GHz instead of 2.0GHz until the next sampling. If 1.8 is an exact match with an hardware frequency we use it, otherwise we average our time between the frequency next higher than 1.8 and next lower than 1.8" (from http://osdir.com/ml/kernel.cpufreq/2006-07/msg00114.html ) - the key word appears to be "average". The author also warns "In practice, users will not be able to detect a difference between 0.1% increments, but 1.0% increments turned out to be too large. Also, the max value of 1000 (100%) would simply peg the system in its deepest power saving P-state, unless the processor really has a hardware P-state at 0Hz".

conservative

 * freq_step : This describes what percentage steps the CPU freq should be increased and decreased smoothly by. By default the CPU frequency will increase in 5% chunks of your maximum CPU frequency. You can change this value to anywhere between 0 and 100 where '0' will effectively lock your CPU at a speed regardless of its load whilst '100' will, in theory, make it behave identically to the "ondemand" governor.
 * down_threshold : This is same as the 'up_threshold' found for the "ondemand" governor but for the opposite direction. For example when set to its default value of '20' it means that if the CPU usage needs to be below 20% between samples to have the frequency decreased.
 * sampling_rate : same as ondemand.
 * sampling_rate_(min|max) : same as ondemand.
 * up_threshold : same as ondemand.
 * ignore_nice_load : same as ondemand.

userspace

 * scaling_setspeed : one of the values from scaling_available_frequencies
 * NB : when userspace is selected LunaSysMgr will change the frequency as it feels.

powersave

 * Nothing special

performance

 * Nothing special

screenstate

 * Nothing special

Relaunching for Cross-App Integration
There are 2 different launch params. One to get a list of profiles returned to your app, and one to apply a profile to the phone. This was implemented in v0.3.1.

Profile List
The code below is how you would launch Govnah and tell it to return a list of profiles to your app: this.controller.serviceRequest (	'palm://com.palm.applicationManager',	{		method: 'launch',		parameters:		{			id: 'org.webosinternals.govnah',			params:			{				type: 'get-profiles',				returnid: 'app.to.relaunch'			}		}	} ); You need to replace the returnid parameters value 'app.to.relaunch' with your apps id.

The object below will be sent to your app-assistants handleLaunch function. (But with real data obviously.) {	type: 'govnah-profiles', profiles: [		{			id: 1, name: 'Palm Default' },		{			id: 8, name: 'Awesome Profile!' },		{...}	] }

Profile Apply
The code below is how you use the list of profiles you received in the prior relaunch to have Govnah apply a profile. this.controller.serviceRequest (	'palm://com.palm.applicationManager',	{		method: 'launch',		parameters:		{			id: 'org.webosinternals.govnah',			params:			{				type: 'set-profile',				profileid: 1			}		}	} ); Replace 'profileid' parameters value with the profile id you wish Govnah to apply. Note that 'profilename' is also an accepted parameter. This launch will not relaunch your app, it will simply apply if the profileid/name you requested actually exists. (And will just ignore your request if it doesn't.)

Official Forum

 * Official PreCentral Forum Thread

Bug Reporting

 * Official Bug Reporting Site
 * Registration on the site is required to submit bug reports.

Feature Requests

 * Official Feature Requests Site
 * Registration on the site is required to submit feature requests.

=Links=
 * http://www.pantz.org/software/cpufreq/usingcpufreqonlinux.html
 * http://publib.boulder.ibm.com/infocenter/lnxinfo/v3r0m0/index.jsp?topic=/liaai/cpufreq/TheOndemandGovernor.htm
 * http://fasterdata.es.net/TCP-tuning/linux.html
 * http://www.pdfgeni.com/book/Performance-analysis-of-loss-based-high-speed-TCP-congestion-control-algorithms-pdf.html - collection of documents on implementation of different IPv4 congestion control methods.
 * http://www.mjmwired.net/kernel/Documentation/cpu-freq/governors.txt - Kernel documentation for the standard Linux CPU frequency governors