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

login
register
mail settings
Submitter Ivan Hu
Date Nov. 20, 2012, 10:10 a.m.
Message ID <1353406224-31051-1-git-send-email-ivan.hu@canonical.com>
Download mbox | patch
Permalink /patch/200281/
State Accepted
Headers show

Comments

Ivan Hu - Nov. 20, 2012, 10:10 a.m.
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(-)
Colin King - Nov. 20, 2012, 10:34 a.m.
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.
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>

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",