(1/3) cpufreq_ondemand - 01_ignore-nice.diff
PATCH 1/1 (1/3) cpufreq_ondemand - 01_ignore-nice.diff
Adds support to cpufreq_ondemand to ignore 'nice' cpu time
Signature · 9 lines
________________________________________
/ Scintillation is not always \
\ identification for an auric substance. /
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||drivers/cpufreq/cpufreq_ondemand.c +62 -4
@@ -78,6 +78,7 @@unsigned int sampling_down_factor;unsigned int up_threshold;unsigned int down_threshold; +unsigned int ignore_nice; };static struct dbs_tuners dbs_tuners_ins = {
@@ -115,6 +116,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)
@@ -193,6 +195,46 @@return count; } +static ssize_t store_ignore_nice (struct cpufreq_policy *policy, +const char *buf,size_t count) +{ +unsigned int input; +int ret; + +unsigned int j; + + ret =sscanf (buf,"%u" , &input); +if ( ret !=1 ) +return -EINVAL ; + +if ( input >1 ) + input =1 ; + +down (&dbs_sem); +if ( input == dbs_tuners_ins.ignore_nice ) {/* nothing to do */ +up (&dbs_sem); +return count; + } + dbs_tuners_ins.ignore_nice = input; + +/* we need to re-evaluate prev_cpu_idle_up and prev_cpu_idle_down */ +for_each_cpu_mask (j, policy->cpus) { +struct cpu_dbs_info_s *j_dbs_info; + j_dbs_info = &per_cpu (cpu_dbs_info, j); + j_dbs_info->cur_policy = policy; + + j_dbs_info->prev_cpu_idle_up = +kstat_cpu (j).cpustat.idle + +kstat_cpu (j).cpustat.iowait + + ( !dbs_tuners_ins.ignore_nice + ?kstat_cpu (j).cpustat.nice :0 ); + j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; + } +up (&dbs_sem); + +return count; +} +#define define_one_rw (_name) \ static struct freq_attr _name = \ __ATTR(_name, 0644, show_##_name, store_##_name)
@@ -201,6 +243,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,
@@ -209,6 +252,7 @@ &sampling_down_factor.attr, &up_threshold.attr, &down_threshold.attr, + &ignore_nice.attr, NULL };
@@ -253,6 +297,9 @@/* 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;
@@ -269,6 +316,9 @@/* Check for frequency increase */ total_idle_ticks =kstat_cpu (j).cpustat.idle +kstat_cpu (j).cpustat.iowait; +/* consider 'nice' too? */ +if (dbs_tuners_ins.ignore_nice ==0 ) + total_idle_ticks +=kstat_cpu (j).cpustat.nice; tmp_idle_ticks = total_idle_ticks - j_dbs_info->prev_cpu_idle_up; j_dbs_info->prev_cpu_idle_up = total_idle_ticks;
@@ -297,6 +347,9 @@ total_idle_ticks =kstat_cpu (cpu).cpustat.idle +kstat_cpu (cpu).cpustat.iowait; +/* consider 'nice' too? */ +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_down; this_dbs_info->prev_cpu_idle_down = total_idle_ticks;
@@ -312,6 +365,9 @@/* Check for frequency increase */ total_idle_ticks =kstat_cpu (j).cpustat.idle +kstat_cpu (j).cpustat.iowait; +/* consider 'nice' too? */ +if (dbs_tuners_ins.ignore_nice ==0 ) + total_idle_ticks +=kstat_cpu (j).cpustat.nice; tmp_idle_ticks = total_idle_ticks - j_dbs_info->prev_cpu_idle_down; j_dbs_info->prev_cpu_idle_down = total_idle_ticks;
@@ -397,10 +453,11 @@ j_dbs_info->prev_cpu_idle_up =kstat_cpu (j).cpustat.idle + -kstat_cpu (j).cpustat.iowait; - j_dbs_info->prev_cpu_idle_down = -kstat_cpu (j).cpustat.idle + -kstat_cpu (j).cpustat.iowait; +kstat_cpu (j).cpustat.iowait + + ( !dbs_tuners_ins.ignore_nice + ?kstat_cpu (j).cpustat.nice :0 ); + j_dbs_info->prev_cpu_idle_down + = j_dbs_info->prev_cpu_idle_up; } this_dbs_info->enable =1 ;sysfs_create_group (&policy->kobj, &dbs_attr_group);
@@ -420,6 +477,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 (); }
_______________________________________________
Cpufreq mailing list
[email protected]
http://lists.linux.org.uk/mailman/listinfo/cpufreq
Quoted 4 lines · Alexander Clouter
Adds support to
cpufreq_ondemandto ignore 'nice' cpu timeSigned-off-by Alexander Clouter <[email protected]>
quoted-printable (more like unprintable) patches tend to get horribly mangled. This is what they ended up like..
@@ -193,6 +195,46 @@
return count;
}
=20
+static ssize_t store_ignore_nice(struct cpufreq_policy *policy,
+ const char *buf, size_t count)
+{
+ unsigned int input;
+ int ret;
+
+ unsigned int j;
+=09 + ret =3D sscanf (buf, "%u", &input); + if ( ret !=3D 1 ) + return -EINVAL;
+
+ if ( input > 1 )
+ input =3D 1;
+=09
(Note the =20/09 crap)
Please resend with a different mailer if necessary.
Dave
Quoted 30 lines · Dave Jones
Quoted 4 lines · Alexander Clouter
Adds support to
cpufreq_ondemandto ignore 'nice' cpu timeSigned-off-by Alexander Clouter <[email protected]>quoted-printable (more like unprintable) patches tend to get horribly mangled. This is what they ended up like..
drivers/cpufreq/cpufreq_ondemand.c +0
-0@@ -193,6 +195,46 @@return count; }=20
drivers/cpufreq/cpufreq_ondemand.c +15
-0+static ssize_t store_ignore_nice (struct cpufreq_policy *policy, +const char *buf,size_t count) +{ +unsigned int input; +int ret; + +unsigned int j; +=09 + ret =3D sscanf (buf, "%u", &input); + if ( ret !=3D 1 ) +return -EINVAL ; + +if ( input >1 ) + input =3D 1; +=09
Quoted 3 lines
(Note the =20/09 crap)
Please resend with a different mailer if necessary.
Ignore this, I ran them through mutt on a different box, and they showed up just fine. Wierd.
Dave