diff mbox

[1/2] cpufreq: fix the CPUFreqCPUsSetToSW_ANY failed LP#1076694

Message ID 1353406224-31051-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show

Commit Message

Ivan Hu Nov. 20, 2012, 10:10 a.m. UTC
The bug LP#1076694 first failed "CPUFreqCPUsSetToSW_ANY: Test 1, Processors
are set to SW_ANY." This is due to when doing check_sw_any fuction,
we assume that high_perf > newhigh_perf, but if the newhigh_perf > high_perf
will accidentally make "high_perf - newhigh_perf > (high_perf - low_perf)/4"
to be true. So add high_perf > newhig_perf to avoid it.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/cpu/cpufreq/cpufreq.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Colin Ian King Nov. 20, 2012, 10:34 a.m. UTC | #1
On 20/11/12 10:10, Ivan Hu wrote:
> The bug LP#1076694 first failed "CPUFreqCPUsSetToSW_ANY: Test 1, Processors
> are set to SW_ANY." This is due to when doing check_sw_any fuction,
> we assume that high_perf > newhigh_perf, but if the newhigh_perf > high_perf
> will accidentally make "high_perf - newhigh_perf > (high_perf - low_perf)/4"
> to be true. So add high_perf > newhig_perf to avoid it.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   src/cpu/cpufreq/cpufreq.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 9efe4f0..98a5a9a 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -589,7 +589,8 @@ static void check_sw_any(fwts_framework *fw)
>   			if (i != j)
>   				lowest_speed(fw, j);
>   		newhigh_perf = get_performance(i);
> -		if (high_perf - newhigh_perf > (high_perf - low_perf)/4 &&
> +		if ((high_perf > newhigh_perf) &&
> +		    (high_perf - newhigh_perf > (high_perf - low_perf)/4) &&
>   		    (once == 0) && (high_perf - low_perf > 20)) {
>   			fwts_failed(fw, LOG_LEVEL_MEDIUM,
>   				"CPUFreqCPUsSetToSW_ANY",
>
Well spotted.

Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung Nov. 22, 2012, 2:28 a.m. UTC | #2
On 11/20/2012 06:10 PM, Ivan Hu wrote:
> The bug LP#1076694 first failed "CPUFreqCPUsSetToSW_ANY: Test 1, Processors
> are set to SW_ANY." This is due to when doing check_sw_any fuction,
> we assume that high_perf > newhigh_perf, but if the newhigh_perf > high_perf
> will accidentally make "high_perf - newhigh_perf > (high_perf - low_perf)/4"
> to be true. So add high_perf > newhig_perf to avoid it.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   src/cpu/cpufreq/cpufreq.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 9efe4f0..98a5a9a 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -589,7 +589,8 @@ static void check_sw_any(fwts_framework *fw)
>   			if (i != j)
>   				lowest_speed(fw, j);
>   		newhigh_perf = get_performance(i);
> -		if (high_perf - newhigh_perf > (high_perf - low_perf)/4 &&
> +		if ((high_perf > newhigh_perf) &&
> +		    (high_perf - newhigh_perf > (high_perf - low_perf)/4) &&
>   		    (once == 0) && (high_perf - low_perf > 20)) {
>   			fwts_failed(fw, LOG_LEVEL_MEDIUM,
>   				"CPUFreqCPUsSetToSW_ANY",
>
Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox

Patch

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 9efe4f0..98a5a9a 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -589,7 +589,8 @@  static void check_sw_any(fwts_framework *fw)
 			if (i != j)
 				lowest_speed(fw, j);
 		newhigh_perf = get_performance(i);
-		if (high_perf - newhigh_perf > (high_perf - low_perf)/4 &&
+		if ((high_perf > newhigh_perf) &&
+		    (high_perf - newhigh_perf > (high_perf - low_perf)/4) &&
 		    (once == 0) && (high_perf - low_perf > 20)) {
 			fwts_failed(fw, LOG_LEVEL_MEDIUM,
 				"CPUFreqCPUsSetToSW_ANY",