diff options
author | Kristen Carlson Accardi <kristen@linux.intel.com> | 2014-12-10 15:39:38 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-12-10 18:24:42 -0500 |
commit | e0d4c8f80804000eadc106bc5167b96fc6231d98 (patch) | |
tree | 7ee4ae6b5a591ff27c69db620712825a2354063a /drivers/cpufreq | |
parent | aa4ea34da9e7a2bc0fb98f5add3e4e52872b7d45 (diff) |
intel_pstate: Add a few comments
Add a few comments in the code which calculates busyness to
clarify parts of the algorithm.
Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 0e841eecb743..742eefba12c2 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -199,7 +199,14 @@ static signed int pid_calc(struct _pid *pid, int32_t busy) | |||
199 | 199 | ||
200 | pid->integral += fp_error; | 200 | pid->integral += fp_error; |
201 | 201 | ||
202 | /* limit the integral term */ | 202 | /* |
203 | * We limit the integral here so that it will never | ||
204 | * get higher than 30. This prevents it from becoming | ||
205 | * too large an input over long periods of time and allows | ||
206 | * it to get factored out sooner. | ||
207 | * | ||
208 | * The value of 30 was chosen through experimentation. | ||
209 | */ | ||
203 | integral_limit = int_tofp(30); | 210 | integral_limit = int_tofp(30); |
204 | if (pid->integral > integral_limit) | 211 | if (pid->integral > integral_limit) |
205 | pid->integral = integral_limit; | 212 | pid->integral = integral_limit; |
@@ -616,6 +623,11 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | |||
616 | if (limits.no_turbo || limits.turbo_disabled) | 623 | if (limits.no_turbo || limits.turbo_disabled) |
617 | max_perf = cpu->pstate.max_pstate; | 624 | max_perf = cpu->pstate.max_pstate; |
618 | 625 | ||
626 | /* | ||
627 | * performance can be limited by user through sysfs, by cpufreq | ||
628 | * policy, or by cpu specific default values determined through | ||
629 | * experimentation. | ||
630 | */ | ||
619 | max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf)); | 631 | max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf)); |
620 | *max = clamp_t(int, max_perf_adj, | 632 | *max = clamp_t(int, max_perf_adj, |
621 | cpu->pstate.min_pstate, cpu->pstate.turbo_pstate); | 633 | cpu->pstate.min_pstate, cpu->pstate.turbo_pstate); |
@@ -717,11 +729,29 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu) | |||
717 | u32 duration_us; | 729 | u32 duration_us; |
718 | u32 sample_time; | 730 | u32 sample_time; |
719 | 731 | ||
732 | /* | ||
733 | * core_busy is the ratio of actual performance to max | ||
734 | * max_pstate is the max non turbo pstate available | ||
735 | * current_pstate was the pstate that was requested during | ||
736 | * the last sample period. | ||
737 | * | ||
738 | * We normalize core_busy, which was our actual percent | ||
739 | * performance to what we requested during the last sample | ||
740 | * period. The result will be a percentage of busy at a | ||
741 | * specified pstate. | ||
742 | */ | ||
720 | core_busy = cpu->sample.core_pct_busy; | 743 | core_busy = cpu->sample.core_pct_busy; |
721 | max_pstate = int_tofp(cpu->pstate.max_pstate); | 744 | max_pstate = int_tofp(cpu->pstate.max_pstate); |
722 | current_pstate = int_tofp(cpu->pstate.current_pstate); | 745 | current_pstate = int_tofp(cpu->pstate.current_pstate); |
723 | core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); | 746 | core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); |
724 | 747 | ||
748 | /* | ||
749 | * Since we have a deferred timer, it will not fire unless | ||
750 | * we are in C0. So, determine if the actual elapsed time | ||
751 | * is significantly greater (3x) than our sample interval. If it | ||
752 | * is, then we were idle for a long enough period of time | ||
753 | * to adjust our busyness. | ||
754 | */ | ||
725 | sample_time = pid_params.sample_rate_ms * USEC_PER_MSEC; | 755 | sample_time = pid_params.sample_rate_ms * USEC_PER_MSEC; |
726 | duration_us = (u32) ktime_us_delta(cpu->sample.time, | 756 | duration_us = (u32) ktime_us_delta(cpu->sample.time, |
727 | cpu->last_sample_time); | 757 | cpu->last_sample_time); |