public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Governor poll frequency tuneables exported in config.
@ 2009-02-12 20:08 Mike Chan
  2009-02-16 13:33 ` Éric Piel
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Chan @ 2009-02-12 20:08 UTC (permalink / raw)
  To: davej; +Cc: linux-kernel, cpufreq

    cpufreq: Governor poll frequency tuneables exported in config.
    
    Signed-off-by: Mike Chan <mike@android.com>

diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 5f076ae..e9361a9 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -190,4 +190,17 @@ config CPU_FREQ_GOV_CONSERVATIVE
 
 	  If in doubt, say N.
 
+config CPU_FREQ_MIN_TICKS
+	int "Ticks between governor polling interval."
+	default 10
+	help
+	  Minimum number of ticks between polling interval for governors.
+
+config CPU_FREQ_SAMPLING_LATENCY_MULTIPLIER
+	int "Sampling rate multiplier for governors."
+	default 1000
+	help
+	  Sampling latency rate multiplied by the cpu switch latency.
+	  Affects governor polling.
+
 endif	# CPU_FREQ
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index ac0bbf2..7bc227e 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -51,11 +51,10 @@ static unsigned int def_sampling_rate;
 #define MIN_SAMPLING_RATE_RATIO			(2)
 /* for correct statistics, we need at least 10 ticks between each measure */
 #define MIN_STAT_SAMPLING_RATE			\
-			(MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
+	(MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(CONFIG_CPU_FREQ_MIN_TICKS))
 #define MIN_SAMPLING_RATE			\
 			(def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
 #define MAX_SAMPLING_RATE			(500 * def_sampling_rate)
-#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER	(1000)
 #define DEF_SAMPLING_DOWN_FACTOR		(1)
 #define MAX_SAMPLING_DOWN_FACTOR		(10)
 #define TRANSITION_LATENCY_LIMIT		(10 * 1000 * 1000)
@@ -523,7 +522,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
 				latency = 1;
 
 			def_sampling_rate = 10 * latency *
-					DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
+				CONFIG_CPU_FREQ_SAMPLING_LATENCY_MULTIPLIER;
 
 			if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
 				def_sampling_rate = MIN_STAT_SAMPLING_RATE;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 33855cb..c7df643 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -42,11 +42,10 @@ static unsigned int def_sampling_rate;
 #define MIN_SAMPLING_RATE_RATIO			(2)
 /* for correct statistics, we need at least 10 ticks between each measure */
 #define MIN_STAT_SAMPLING_RATE 			\
-			(MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
+	(MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(CONFIG_CPU_FREQ_MIN_TICKS))
 #define MIN_SAMPLING_RATE			\
 			(def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
 #define MAX_SAMPLING_RATE			(500 * def_sampling_rate)
-#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER	(1000)
 #define TRANSITION_LATENCY_LIMIT		(10 * 1000 * 1000)
 
 static void do_dbs_timer(struct work_struct *work);
@@ -542,7 +541,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
 				latency = 1;
 
 			def_sampling_rate = latency *
-					DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
+				CONFIG_CPU_FREQ_SAMPLING_LATENCY_MULTIPLIER;
 
 			if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
 				def_sampling_rate = MIN_STAT_SAMPLING_RATE;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: Governor poll frequency tuneables exported in config.
  2009-02-12 20:08 [PATCH] cpufreq: Governor poll frequency tuneables exported in config Mike Chan
@ 2009-02-16 13:33 ` Éric Piel
  2009-02-16 14:46   ` Thomas Renninger
  0 siblings, 1 reply; 4+ messages in thread
From: Éric Piel @ 2009-02-16 13:33 UTC (permalink / raw)
  To: Mike Chan; +Cc: davej, linux-kernel, cpufreq

Mike Chan schreef:
>     cpufreq: Governor poll frequency tuneables exported in config.
>     
Hello,

> +config CPU_FREQ_MIN_TICKS
> +	int "Ticks between governor polling interval."
> +	default 10
> +	help
> +	  Minimum number of ticks between polling interval for governors.
I don't think it makes much sense to let anyone tune this parameter.
This is a constant that says we need at least a 10% granularity to
compute any statistic correctly. There is nothing much to be discussed
or tuned.


> +config CPU_FREQ_SAMPLING_LATENCY_MULTIPLIER
> +	int "Sampling rate multiplier for governors."
> +	default 1000
> +	help
> +	  Sampling latency rate multiplied by the cpu switch latency.
> +	  Affects governor polling.
This one, why not (although I don't think it's worth neither), and it
would need a better documentation.

Eric


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: Governor poll frequency tuneables exported in config.
  2009-02-16 13:33 ` Éric Piel
@ 2009-02-16 14:46   ` Thomas Renninger
  2009-02-18  1:11     ` Mike Chan
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Renninger @ 2009-02-16 14:46 UTC (permalink / raw)
  To: Éric Piel; +Cc: Mike Chan, davej, linux-kernel, cpufreq

On Monday 16 February 2009 14:33:54 Éric Piel wrote:
> Mike Chan schreef:
> >     cpufreq: Governor poll frequency tuneables exported in config.
> >     
> Hello,
> 
> > +config CPU_FREQ_MIN_TICKS
> > +	int "Ticks between governor polling interval."
> > +	default 10
> > +	help
> > +	  Minimum number of ticks between polling interval for governors.
> I don't think it makes much sense to let anyone tune this parameter.
> This is a constant that says we need at least a 10% granularity to
> compute any statistic correctly. There is nothing much to be discussed
> or tuned.
> 
> 
> > +config CPU_FREQ_SAMPLING_LATENCY_MULTIPLIER
> > +	int "Sampling rate multiplier for governors."
> > +	default 1000
> > +	help
> > +	  Sampling latency rate multiplied by the cpu switch latency.
> > +	  Affects governor polling.
> This one, why not (although I don't think it's worth neither), and it
> would need a better documentation.
It is already configurable in userspace, no need to introduce a 
new config variable:

Documentation/cpu-freq/governors.txt

==================
sampling_rate: measured in uS (10^-6 seconds), 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. It's default value is (cmp. with users-guide.txt):
transition_latency * 1000
The lowest value you can set is:
transition_latency * 100 or it may get restricted to a value where it
makes not sense for the kernel anymore to poll that often which depends
on your HZ config variable (HZ=1000: max=20000us, HZ=250: max=5000).
Be aware that transition latency is in ns and sampling_rate is in us, so 
you
get the same sysfs value by default.
Sampling rate should always get adjusted considering the transition latency
To set the sampling rate 750 times as high as the transition latency
in the bash (as said, 1000 is default), do:
echo `$(($(cat cpuinfo_transition_latency) * 750 / 1000)) \
    >ondemand/sampling_rate
===================

But this is only in the very latest cpufreq next tree and should pop up
in 2.6.30.

Hmm, the statement:
"Typically this is set to values of around '10000' or more"
Is wrong (E.g. if you have HZ=250 you cannot go below 80000), but I plan to 
touch this again soon. Then this statement hopefully is correct again.

    Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpufreq: Governor poll frequency tuneables exported in  config.
  2009-02-16 14:46   ` Thomas Renninger
@ 2009-02-18  1:11     ` Mike Chan
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Chan @ 2009-02-18  1:11 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Éric Piel, davej, linux-kernel, cpufreq

On Mon, Feb 16, 2009 at 6:46 AM, Thomas Renninger <trenn@suse.de> wrote:
> On Monday 16 February 2009 14:33:54 Éric Piel wrote:
>> Mike Chan schreef:
>> >     cpufreq: Governor poll frequency tuneables exported in config.
>> >
>> Hello,
>>
>> > +config CPU_FREQ_MIN_TICKS
>> > +   int "Ticks between governor polling interval."
>> > +   default 10
>> > +   help
>> > +     Minimum number of ticks between polling interval for governors.
>> I don't think it makes much sense to let anyone tune this parameter.
>> This is a constant that says we need at least a 10% granularity to
>> compute any statistic correctly. There is nothing much to be discussed
>> or tuned.
>>
>>
>> > +config CPU_FREQ_SAMPLING_LATENCY_MULTIPLIER
>> > +   int "Sampling rate multiplier for governors."
>> > +   default 1000
>> > +   help
>> > +     Sampling latency rate multiplied by the cpu switch latency.
>> > +     Affects governor polling.
>> This one, why not (although I don't think it's worth neither), and it
>> would need a better documentation.
> It is already configurable in userspace, no need to introduce a
> new config variable:
>
> Documentation/cpu-freq/governors.txt
>
> ==================
> sampling_rate: measured in uS (10^-6 seconds), 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. It's default value is (cmp. with users-guide.txt):
> transition_latency * 1000
> The lowest value you can set is:
> transition_latency * 100 or it may get restricted to a value where it
> makes not sense for the kernel anymore to poll that often which depends
> on your HZ config variable (HZ=1000: max=20000us, HZ=250: max=5000).
> Be aware that transition latency is in ns and sampling_rate is in us, so
> you
> get the same sysfs value by default.
> Sampling rate should always get adjusted considering the transition latency
> To set the sampling rate 750 times as high as the transition latency
> in the bash (as said, 1000 is default), do:
> echo `$(($(cat cpuinfo_transition_latency) * 750 / 1000)) \
>    >ondemand/sampling_rate
> ===================
>
> But this is only in the very latest cpufreq next tree and should pop up
> in 2.6.30.
>
> Hmm, the statement:
> "Typically this is set to values of around '10000' or more"
> Is wrong (E.g. if you have HZ=250 you cannot go below 80000), but I plan to
> touch this again soon. Then this statement hopefully is correct again.
>
>    Thomas
>

The problem currently in 29 is that I need a faster response time from
the governors.
Take for example cpuinfo_transition_latency = 20us.
This gives a default sample_rate = 200ms, sample_rate_min = 100ms.

There is no way to get faster response times unless you tune those
values, or lie to the governor about the cpu switch speeds.

Some will argue 100ms is sufficient, but if you are trying to render @
60fps and are cpu bound this will cause a few dropped frames.

You mention "transition_latency * 100" but this is hard-coded in the
.c file, I don't see a way around this in 29, I'm assuming this will
be adjustable in 30?
I don't care so much about this patch's implementation, just that the
sampling_rate limitations are not an issue in the latest cpufreq tree
/ 30.

-- 
MIke Chan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-18  1:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-12 20:08 [PATCH] cpufreq: Governor poll frequency tuneables exported in config Mike Chan
2009-02-16 13:33 ` Éric Piel
2009-02-16 14:46   ` Thomas Renninger
2009-02-18  1:11     ` Mike Chan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox