cpufreq_ondemand tweaks (round two)
PATCH 1/1 cpufreq_ondemand tweaks (round two)
Hi All,
After listening to all your points a couple of weeks back I found the time to break up my patches to 'ondemand' into three smaller patches and my clean my tweaks up a little. I also went ahead with the suggestion to create a completely new governor ('conservative', better name suggestions welcome) which has the major alteration so that the change in frequency is made gradually in both directions; this, I feel, being much more suitable for battery powered environments.
I also included the relevant cleanup code by Adrian Bunk ([2.6 patch] small cpufreq cleanup 2004-10-30 7:22:46) into the conservative governor.
As a side note, Venkatesh might want to consider dropping the default sampling rate an order of magnitude as on my laptop its constantly flicking between min and max and is a bit too trigger happy whilst the cpu use at around 5%; for me at least. Bruno Ducrot pointed out that the amd64's "do have unacceptable latency between min and max freq transition, due to the step-by-step requirements (200MHz IIRC)". For me its just a a cosmetic annoyance in /proc/cpuinfo :)
Let me know what you think.
Regards
Alex
------------------------------------------
01_ignore-nice.diff
-------------------
Adds support so that you can choose to consider (default) or ignore 'nice'ed processes.
02_check-rate-and-break-out.diff
--------------------------------
If it is decided that cpu needs to be sped up a notch but yet the cpu frequency is already at max (or reduce speed but already at its lowest frequency) then we break out without wasting cpu cycles and (possible?) latency issues attempting to make changes that have no effect.
03_sys_freq_step.diff
---------------------
the step down frequency is now tweakable through /sys. It takes an unsigned int between zero and (((max - min) * 100) / max), the percentage equal to the difference between min and max. The advantage of this is that all the divisions are moved out of the main loop when it comes to working out whas frequency in khz the cpu should be lowered by.
------------------------------
Signature · 14 lines
________________________________________
/ Nullum magnum ingenium sine mixtura \
| dementiae fuit. |
| |
| [There is no great genius without some |
| touch of madness.] |
| |
\ -- Seneca /
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||drivers/cpufreq/cpufreq_ondemand.c +29 -2
@@ -81,6 +81,7 @@unsigned int sampling_down_factor;unsigned int up_threshold;unsigned int down_threshold; +unsigned int ignore_nice; };struct dbs_tuners dbs_tuners_ins = {
@@ -120,6 +121,7 @@show_one (sampling_down_factor, sampling_down_factor);show_one (up_threshold, up_threshold);show_one (down_threshold, down_threshold); +show_one (ignore_nice, ignore_nice);static ssize_t store_sampling_down_factor (struct cpufreq_policy *unused,const char *buf,size_t count)
@@ -189,6 +191,22 @@return count; } +static ssize_t store_ignore_nice (struct cpufreq_policy *unused, +const char *buf,size_t count) +{ +unsigned int input; +int ret; + ret =sscanf (buf,"%u" , &input); +down (&dbs_sem); +if ( ret ==1 ) { +if ( input >1 ) + input =1 ; + dbs_tuners_ins.ignore_nice = input; + } +up (&dbs_sem); +return count; +} +#define define_one_rw (_name) \ static struct freq_attr _name = { \ .attr = { .name = __stringify(_name), .mode = 0644 }, \
@@ -200,6 +218,7 @@define_one_rw (sampling_down_factor);define_one_rw (up_threshold);define_one_rw (down_threshold); +define_one_rw (ignore_nice);static struct attribute * dbs_attributes[] = { &sampling_rate_max.attr,
@@ -208,6 +227,7 @@ &sampling_down_factor.attr, &up_threshold.attr, &down_threshold.attr, + &ignore_nice.attr, NULL };
@@ -247,6 +267,10 @@/* Check for frequency increase */ total_idle_ticks =kstat_cpu (cpu).cpustat.idle +kstat_cpu (cpu).cpustat.iowait; +/* consider 'nice' tasks as 'idle' time too if required */ +if (dbs_tuners_ins.ignore_nice ==0 ) + total_idle_ticks +=kstat_cpu (cpu).cpustat.nice; + idle_ticks = total_idle_ticks - this_dbs_info->prev_cpu_idle_up; this_dbs_info->prev_cpu_idle_up = total_idle_ticks;
@@ -346,10 +370,12 @@ this_dbs_info->prev_cpu_idle_up =kstat_cpu (cpu).cpustat.idle + -kstat_cpu (cpu).cpustat.iowait; +kstat_cpu (cpu).cpustat.iowait + +kstat_cpu (cpu).cpustat.nice; this_dbs_info->prev_cpu_idle_down =kstat_cpu (cpu).cpustat.idle + -kstat_cpu (cpu).cpustat.iowait; +kstat_cpu (cpu).cpustat.iowait + +kstat_cpu (cpu).cpustat.nice; this_dbs_info->enable =1 ;sysfs_create_group (&policy->kobj, &dbs_attr_group); dbs_enable++;
@@ -368,6 +394,7 @@ def_sampling_rate = (latency /1000 ) *DEF_SAMPLING_RATE_LATENCY_MULTIPLIER ; dbs_tuners_ins.sampling_rate = def_sampling_rate; + dbs_tuners_ins.ignore_nice =0 ;dbs_timer_init (); }
drivers/cpufreq/cpufreq_ondemand.c +6 -0
@@ -281,6 +281,9 @@sampling_rate_in_HZ (dbs_tuners_ins.sampling_rate);if (idle_ticks < up_idle_ticks) { +if (this_dbs_info->cur_policy->cur + == this_dbs_info->cur_policy->max) +return ;__cpufreq_driver_target (this_dbs_info->cur_policy, this_dbs_info->cur_policy->max,CPUFREQ_RELATION_H );
@@ -307,6 +310,9 @@sampling_rate_in_HZ (freq_down_sampling_rate);if (idle_ticks > down_idle_ticks ) { +if (this_dbs_info->cur_policy->cur + == this_dbs_info->cur_policy->min) +return ; freq_down_step = (5 * this_dbs_info->cur_policy->max) /100 ;/* max freq cannot be less than 100. But who knows.... */
drivers/cpufreq/cpufreq_ondemand.c +42 -9
107 lines not on this page · raw message
drivers/cpufreq/cpufreq_conservative.c +525 -0
525 lines not on this page · raw message
drivers/cpufreq/Kconfig +18 -0
@@ -84,6 +84,24 @@ If in doubt, say N. +config CPU_FREQ_GOV_CONSERVATIVE + tristate "'conservative' cpufreq policy governor" + depends on CPU_FREQ + help + 'conservative' - this driver is quite identical to the 'ondemand' + governor both in its source code and purpose, the difference is that + it has been designed to be much more suitable in a battery powered + environment. The frequency is gracefully increased and decreased + rather than jumping to 100% when speed is required and dropping back + aggressively. It also polls 100 times fewer times than 'ondemand'. + + For details, take a look at linux/Documentation/cpu-freq. + + If you have a desktop machine then you should consider really the + 'ondemand' governor instead, however if you are using a laptop, PDA or + even an AMD64 based desktop (due to latency issues) you probably will + want to use this governor. If in doubt, say N. + config CPU_FREQ_24_API bool "/proc/sys/cpu/ interface (2.4. / OLD)" depends on CPU_FREQ && SYSCTL && CPU_FREQ_GOV_USERSPACE
drivers/cpufreq/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_POWERSAVE) += cpufreq_powersave.o obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE) += cpufreq_userspace.o obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o +obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o # CPUfreq cross-arch helpers obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o
_______________________________________________
Cpufreq mailing list
[email protected]
http://www.linux.org.uk/mailman/listinfo/cpufreq