patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v1 1/4] test/power: fix check for cpu frequency
@ 2021-04-22 14:40 David Hunt
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 2/4] test/power: add turbo mode to freq check function David Hunt
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: David Hunt @ 2021-04-22 14:40 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

Different drivers present the current cpu core frequency in different
sysfs iles. Some present it in cpuinfo_cur_freq, some in scaling_cur_freq,
and some actually present it in both.

This patch attempts to open one, if that fails, tries the other.

Fixes: d550a8cc31f3 ("app/test: enhance power manager unit tests")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 app/test/test_power_cpufreq.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index f753d24ac5..52f58ef8b2 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -39,8 +39,10 @@ test_power_caps(void)
 #define TEST_FREQ_ROUNDING_DELTA 50000
 #define TEST_ROUND_FREQ_TO_N_100000 100000
 
-#define TEST_POWER_SYSFILE_CUR_FREQ \
+#define TEST_POWER_SYSFILE_CPUINFO_FREQ \
 	"/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_cur_freq"
+#define TEST_POWER_SYSFILE_SCALING_FREQ \
+	"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq"
 
 static uint32_t total_freq_num;
 static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
@@ -58,12 +60,19 @@ check_cur_freq(unsigned lcore_id, uint32_t idx)
 	int i;
 
 	if (snprintf(fullpath, sizeof(fullpath),
-		TEST_POWER_SYSFILE_CUR_FREQ, lcore_id) < 0) {
+		TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) {
 		return 0;
 	}
 	f = fopen(fullpath, "r");
 	if (f == NULL) {
-		return 0;
+		if (snprintf(fullpath, sizeof(fullpath),
+			TEST_POWER_SYSFILE_CPUINFO_FREQ, lcore_id) < 0) {
+			return 0;
+		}
+		f = fopen(fullpath, "r");
+		if (f == NULL) {
+			return 0;
+		}
 	}
 	for (i = 0; i < MAX_LOOP; i++) {
 		fflush(f);
-- 
2.17.1


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

* [dpdk-stable] [PATCH v1 2/4] test/power: add turbo mode to freq check function
  2021-04-22 14:40 [dpdk-stable] [PATCH v1 1/4] test/power: fix check for cpu frequency David Hunt
@ 2021-04-22 14:40 ` David Hunt
  2021-04-22 16:13   ` [dpdk-stable] [dpdk-dev] " Burakov, Anatoly
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 3/4] test/power: fix low freq test when turbo enabled David Hunt
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: David Hunt @ 2021-04-22 14:40 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

With the intel_pstate driver and turbo enabled, the top frequency in
the frequency array is the P1+1, i.e. 2300001, whereas the frequency
shown in scaling_cur_freq could be a lot higher.

This patch adds a flag to the check_cur_freq function so that we can
specify if a frequency is greater than expected (turbo mode), in which
case the check should be successful.

Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 app/test/test_power_cpufreq.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index 52f58ef8b2..33a68cf645 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -48,7 +48,7 @@ static uint32_t total_freq_num;
 static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
 
 static int
-check_cur_freq(unsigned lcore_id, uint32_t idx)
+check_cur_freq(unsigned int lcore_id, uint32_t idx, int turbo)
 {
 #define TEST_POWER_CONVERT_TO_DECIMAL 10
 #define MAX_LOOP 100
@@ -90,7 +90,10 @@ check_cur_freq(unsigned lcore_id, uint32_t idx)
 					/ TEST_ROUND_FREQ_TO_N_100000;
 		freq_conv = freq_conv * TEST_ROUND_FREQ_TO_N_100000;
 
-		ret = (freqs[idx] == freq_conv ? 0 : -1);
+		if (turbo)
+			ret = (freqs[idx] <= freq_conv ? 0 : -1);
+		else
+			ret = (freqs[idx] == freq_conv ? 0 : -1);
 
 		if (ret == 0)
 			break;
@@ -183,7 +186,7 @@ check_power_get_freq(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, count);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, count, 0);
 	if (ret < 0)
 		return -1;
 
@@ -233,7 +236,7 @@ check_power_set_freq(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, 0);
 	if (ret < 0)
 		return -1;
 
@@ -269,7 +272,7 @@ check_power_freq_down(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, 0);
 	if (ret < 0)
 		return -1;
 
@@ -288,7 +291,7 @@ check_power_freq_down(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, 0);
 	if (ret < 0)
 		return -1;
 
@@ -324,7 +327,7 @@ check_power_freq_up(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2, 0);
 	if (ret < 0)
 		return -1;
 
@@ -343,7 +346,7 @@ check_power_freq_up(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, 1);
 	if (ret < 0)
 		return -1;
 
@@ -371,7 +374,7 @@ check_power_freq_max(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, 1);
 	if (ret < 0)
 		return -1;
 
@@ -399,7 +402,7 @@ check_power_freq_min(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, 0);
 	if (ret < 0)
 		return -1;
 
@@ -433,7 +436,7 @@ check_power_turbo(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, 1);
 	if (ret < 0)
 		return -1;
 
@@ -452,7 +455,7 @@ check_power_turbo(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, 0);
 	if (ret < 0)
 		return -1;
 
-- 
2.17.1


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

* [dpdk-stable] [PATCH v1 3/4] test/power: fix low freq test when turbo enabled
  2021-04-22 14:40 [dpdk-stable] [PATCH v1 1/4] test/power: fix check for cpu frequency David Hunt
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 2/4] test/power: add turbo mode to freq check function David Hunt
@ 2021-04-22 14:40 ` David Hunt
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 4/4] test/power: fix turbo test David Hunt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: David Hunt @ 2021-04-22 14:40 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

With the intel_pstate driver and turbo enabled, indexing is slightly
different to normal, so to get the test to work properly, enable
turbo at the start.

Fixes: ed7c51a6a680 ("app/test: vm power management")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 app/test/test_power_cpufreq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index 33a68cf645..e2be807318 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -249,6 +249,8 @@ check_power_freq_down(void)
 {
 	int ret;
 
+	rte_power_freq_enable_turbo(TEST_POWER_LCORE_ID);
+
 	/* test with an invalid lcore id */
 	ret = rte_power_freq_down(TEST_POWER_LCORE_INVALID);
 	if (ret >= 0) {
-- 
2.17.1


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

* [dpdk-stable] [PATCH v1 4/4] test/power: fix turbo test
  2021-04-22 14:40 [dpdk-stable] [PATCH v1 1/4] test/power: fix check for cpu frequency David Hunt
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 2/4] test/power: add turbo mode to freq check function David Hunt
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 3/4] test/power: fix low freq test when turbo enabled David Hunt
@ 2021-04-22 14:40 ` David Hunt
  2021-04-29 10:34 ` [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency Pattan, Reshma
  2021-05-12 16:32 ` [dpdk-stable] [PATCH v2 " David Hunt
  4 siblings, 0 replies; 16+ messages in thread
From: David Hunt @ 2021-04-22 14:40 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

when turbo is enabled or disabled, the frequency is set to a low non-turbo
frequency, so we need to set to the frequency expected by the test before
checking.

Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 app/test/test_power_cpufreq.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index e2be807318..ceffebc428 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -436,6 +436,12 @@ check_power_turbo(void)
 				TEST_POWER_LCORE_ID);
 		return -1;
 	}
+	ret = rte_power_freq_max(TEST_POWER_LCORE_ID);
+	if (ret < 0) {
+		printf("Fail to scale up the freq to max on lcore %u\n",
+						TEST_POWER_LCORE_ID);
+		return -1;
+	}
 
 	/* Check the current frequency */
 	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, 1);
@@ -455,6 +461,12 @@ check_power_turbo(void)
 				TEST_POWER_LCORE_ID);
 		return -1;
 	}
+	ret = rte_power_freq_max(TEST_POWER_LCORE_ID);
+	if (ret < 0) {
+		printf("Fail to scale up the freq to max on lcore %u\n",
+						TEST_POWER_LCORE_ID);
+		return -1;
+	}
 
 	/* Check the current frequency */
 	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, 0);
-- 
2.17.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v1 2/4] test/power: add turbo mode to freq check function
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 2/4] test/power: add turbo mode to freq check function David Hunt
@ 2021-04-22 16:13   ` Burakov, Anatoly
  2021-05-12 15:34     ` Thomas Monjalon
  0 siblings, 1 reply; 16+ messages in thread
From: Burakov, Anatoly @ 2021-04-22 16:13 UTC (permalink / raw)
  To: David Hunt, dev; +Cc: stable

On 22-Apr-21 3:40 PM, David Hunt wrote:
> With the intel_pstate driver and turbo enabled, the top frequency in
> the frequency array is the P1+1, i.e. 2300001, whereas the frequency
> shown in scaling_cur_freq could be a lot higher.
> 
> This patch adds a flag to the check_cur_freq function so that we can
> specify if a frequency is greater than expected (turbo mode), in which
> case the check should be successful.
> 
> Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Hunt <david.hunt@intel.com>
> ---
>   app/test/test_power_cpufreq.c | 27 +++++++++++++++------------
>   1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
> index 52f58ef8b2..33a68cf645 100644
> --- a/app/test/test_power_cpufreq.c
> +++ b/app/test/test_power_cpufreq.c
> @@ -48,7 +48,7 @@ static uint32_t total_freq_num;
>   static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
>   
>   static int
> -check_cur_freq(unsigned lcore_id, uint32_t idx)
> +check_cur_freq(unsigned int lcore_id, uint32_t idx, int turbo)

Nitpicking, but stdbool exists :) it would be nice to use bool type for 
bool variables, not int.

-- 
Thanks,
Anatoly

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency
  2021-04-22 14:40 [dpdk-stable] [PATCH v1 1/4] test/power: fix check for cpu frequency David Hunt
                   ` (2 preceding siblings ...)
  2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 4/4] test/power: fix turbo test David Hunt
@ 2021-04-29 10:34 ` Pattan, Reshma
  2021-05-11 13:27   ` Thomas Monjalon
  2021-05-11 14:41   ` David Hunt
  2021-05-12 16:32 ` [dpdk-stable] [PATCH v2 " David Hunt
  4 siblings, 2 replies; 16+ messages in thread
From: Pattan, Reshma @ 2021-04-29 10:34 UTC (permalink / raw)
  To: Hunt, David, dev; +Cc: Hunt, David, stable



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of David Hunt
> +TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) {

>  return 0;

[Reshma]:  Do we need to return -1 here and in other failure scenarios below.

>  }
>  f = fopen(fullpath, "r");
>  if (f == NULL) {
> -return 0;
> +if (snprintf(fullpath, sizeof(fullpath),
> +TEST_POWER_SYSFILE_CPUINFO_FREQ, lcore_id) < 0) {
> +return 0;
> +}
> +f = fopen(fullpath, "r");
> +if (f == NULL) {
> +return 0;
> +}
>  }
>  for (i = 0; i < MAX_LOOP; i++) {
>  fflush(f);
> --
> 2.17.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency
  2021-04-29 10:34 ` [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency Pattan, Reshma
@ 2021-05-11 13:27   ` Thomas Monjalon
  2021-05-11 14:41   ` David Hunt
  1 sibling, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2021-05-11 13:27 UTC (permalink / raw)
  To: Hunt, David, Pattan, Reshma
  Cc: dev, stable, david.marchand, anatoly.burakov, bruce.richardson

This patch series is stucked.
That's too often the case for the power lib/example/test patches.

29/04/2021 12:34, Pattan, Reshma:
> From: dev <dev-bounces@dpdk.org> On Behalf Of David Hunt
> > +TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) {
> 
> >  return 0;
> 
> [Reshma]:  Do we need to return -1 here and in other failure scenarios below.
> 
> >  }
> >  f = fopen(fullpath, "r");
> >  if (f == NULL) {
> > -return 0;
> > +if (snprintf(fullpath, sizeof(fullpath),
> > +TEST_POWER_SYSFILE_CPUINFO_FREQ, lcore_id) < 0) {
> > +return 0;
> > +}
> > +f = fopen(fullpath, "r");
> > +if (f == NULL) {
> > +return 0;
> > +}
> >  }




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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency
  2021-04-29 10:34 ` [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency Pattan, Reshma
  2021-05-11 13:27   ` Thomas Monjalon
@ 2021-05-11 14:41   ` David Hunt
  2021-05-11 14:46     ` Pattan, Reshma
  1 sibling, 1 reply; 16+ messages in thread
From: David Hunt @ 2021-05-11 14:41 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: stable


On 29/4/2021 11:34 AM, Pattan, Reshma wrote:
>
>> -----Original Message-----
>> From: dev <dev-bounces@dpdk.org> On Behalf Of David Hunt
>> +TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) {
>>   return 0;
> [Reshma]:  Do we need to return -1 here and in other failure scenarios below.


Hi Reshma,

We might do, but that's not something I had intended to address in this 
patch set.

We should look at this in a future patch, OK?

Rgds,

Dave.




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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency
  2021-05-11 14:41   ` David Hunt
@ 2021-05-11 14:46     ` Pattan, Reshma
  0 siblings, 0 replies; 16+ messages in thread
From: Pattan, Reshma @ 2021-05-11 14:46 UTC (permalink / raw)
  To: Hunt, David, dev; +Cc: stable



> -----Original Message-----
> From: Hunt, David <david.hunt@intel.com>
> > [Reshma]:  Do we need to return -1 here and in other failure scenarios below.
> 
> 
> Hi Reshma,
> 
> We might do, but that's not something I had intended to address in this patch
> set.
> 
> We should look at this in a future patch, OK?
> 
> Rgds,
> 
> Dave.
> 
> 

Fine with me. Thanks for checking.

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v1 2/4] test/power: add turbo mode to freq check function
  2021-04-22 16:13   ` [dpdk-stable] [dpdk-dev] " Burakov, Anatoly
@ 2021-05-12 15:34     ` Thomas Monjalon
  2021-05-12 16:38       ` David Hunt
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Monjalon @ 2021-05-12 15:34 UTC (permalink / raw)
  To: David Hunt; +Cc: dev, stable, Burakov, Anatoly, ferruh.yigit

22/04/2021 18:13, Burakov, Anatoly:
> On 22-Apr-21 3:40 PM, David Hunt wrote:
> > --- a/app/test/test_power_cpufreq.c
> > +++ b/app/test/test_power_cpufreq.c
> > @@ -48,7 +48,7 @@ static uint32_t total_freq_num;
> >   static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
> >   
> >   static int
> > -check_cur_freq(unsigned lcore_id, uint32_t idx)
> > +check_cur_freq(unsigned int lcore_id, uint32_t idx, int turbo)
> 
> Nitpicking, but stdbool exists :) it would be nice to use bool type for 
> bool variables, not int.

Dave, I think you missed this comment.





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

* [dpdk-stable] [PATCH v2 1/4] test/power: fix check for cpu frequency
  2021-04-22 14:40 [dpdk-stable] [PATCH v1 1/4] test/power: fix check for cpu frequency David Hunt
                   ` (3 preceding siblings ...)
  2021-04-29 10:34 ` [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency Pattan, Reshma
@ 2021-05-12 16:32 ` David Hunt
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 2/4] test/power: add turbo mode to freq check function David Hunt
                     ` (2 more replies)
  4 siblings, 3 replies; 16+ messages in thread
From: David Hunt @ 2021-05-12 16:32 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

Different drivers present the current cpu core frequency in different
sysfs iles. Some present it in cpuinfo_cur_freq, some in scaling_cur_freq,
and some actually present it in both.

This patch attempts to open one, if that fails, tries the other.

Fixes: d550a8cc31f3 ("app/test: enhance power manager unit tests")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>

---
changes in v2
   none
---
 app/test/test_power_cpufreq.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index f753d24ac5..52f58ef8b2 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -39,8 +39,10 @@ test_power_caps(void)
 #define TEST_FREQ_ROUNDING_DELTA 50000
 #define TEST_ROUND_FREQ_TO_N_100000 100000
 
-#define TEST_POWER_SYSFILE_CUR_FREQ \
+#define TEST_POWER_SYSFILE_CPUINFO_FREQ \
 	"/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_cur_freq"
+#define TEST_POWER_SYSFILE_SCALING_FREQ \
+	"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq"
 
 static uint32_t total_freq_num;
 static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
@@ -58,12 +60,19 @@ check_cur_freq(unsigned lcore_id, uint32_t idx)
 	int i;
 
 	if (snprintf(fullpath, sizeof(fullpath),
-		TEST_POWER_SYSFILE_CUR_FREQ, lcore_id) < 0) {
+		TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) {
 		return 0;
 	}
 	f = fopen(fullpath, "r");
 	if (f == NULL) {
-		return 0;
+		if (snprintf(fullpath, sizeof(fullpath),
+			TEST_POWER_SYSFILE_CPUINFO_FREQ, lcore_id) < 0) {
+			return 0;
+		}
+		f = fopen(fullpath, "r");
+		if (f == NULL) {
+			return 0;
+		}
 	}
 	for (i = 0; i < MAX_LOOP; i++) {
 		fflush(f);
-- 
2.17.1


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

* [dpdk-stable] [PATCH v2 2/4] test/power: add turbo mode to freq check function
  2021-05-12 16:32 ` [dpdk-stable] [PATCH v2 " David Hunt
@ 2021-05-12 16:32   ` David Hunt
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 3/4] test/power: fix low freq test when turbo enabled David Hunt
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 4/4] test/power: fix turbo test David Hunt
  2 siblings, 0 replies; 16+ messages in thread
From: David Hunt @ 2021-05-12 16:32 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

With the intel_pstate driver and turbo enabled, the top frequency in
the frequency array is the P1+1, i.e. 2300001, whereas the frequency
shown in scaling_cur_freq could be a lot higher.

This patch adds a flag to the check_cur_freq function so that we can
specify if a frequency is greater than expected (turbo mode), in which
case the check should be successful.

Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>

---
changes in v2
   changed check_cur_freq() to take a bool instead of an int, as suggested
   by Anatoly, and changed all the calls to use true/false.
---
 app/test/test_power_cpufreq.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index 52f58ef8b2..2b4728d2e1 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -48,7 +48,7 @@ static uint32_t total_freq_num;
 static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
 
 static int
-check_cur_freq(unsigned lcore_id, uint32_t idx)
+check_cur_freq(unsigned int lcore_id, uint32_t idx, bool turbo)
 {
 #define TEST_POWER_CONVERT_TO_DECIMAL 10
 #define MAX_LOOP 100
@@ -90,7 +90,10 @@ check_cur_freq(unsigned lcore_id, uint32_t idx)
 					/ TEST_ROUND_FREQ_TO_N_100000;
 		freq_conv = freq_conv * TEST_ROUND_FREQ_TO_N_100000;
 
-		ret = (freqs[idx] == freq_conv ? 0 : -1);
+		if (turbo)
+			ret = (freqs[idx] <= freq_conv ? 0 : -1);
+		else
+			ret = (freqs[idx] == freq_conv ? 0 : -1);
 
 		if (ret == 0)
 			break;
@@ -183,7 +186,7 @@ check_power_get_freq(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, count);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, count, false);
 	if (ret < 0)
 		return -1;
 
@@ -233,7 +236,7 @@ check_power_set_freq(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, false);
 	if (ret < 0)
 		return -1;
 
@@ -269,7 +272,7 @@ check_power_freq_down(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, false);
 	if (ret < 0)
 		return -1;
 
@@ -288,7 +291,7 @@ check_power_freq_down(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, false);
 	if (ret < 0)
 		return -1;
 
@@ -324,7 +327,7 @@ check_power_freq_up(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2, false);
 	if (ret < 0)
 		return -1;
 
@@ -343,7 +346,7 @@ check_power_freq_up(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true);
 	if (ret < 0)
 		return -1;
 
@@ -371,7 +374,7 @@ check_power_freq_max(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true);
 	if (ret < 0)
 		return -1;
 
@@ -399,7 +402,7 @@ check_power_freq_min(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1, false);
 	if (ret < 0)
 		return -1;
 
@@ -433,7 +436,7 @@ check_power_turbo(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true);
 	if (ret < 0)
 		return -1;
 
@@ -452,7 +455,7 @@ check_power_turbo(void)
 	}
 
 	/* Check the current frequency */
-	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1);
+	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, false);
 	if (ret < 0)
 		return -1;
 
-- 
2.17.1


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

* [dpdk-stable] [PATCH v2 3/4] test/power: fix low freq test when turbo enabled
  2021-05-12 16:32 ` [dpdk-stable] [PATCH v2 " David Hunt
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 2/4] test/power: add turbo mode to freq check function David Hunt
@ 2021-05-12 16:32   ` David Hunt
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 4/4] test/power: fix turbo test David Hunt
  2 siblings, 0 replies; 16+ messages in thread
From: David Hunt @ 2021-05-12 16:32 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

With the intel_pstate driver and turbo enabled, indexing is slightly
different to normal, so to get the test to work properly, enable
turbo at the start.

Fixes: ed7c51a6a680 ("app/test: vm power management")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>

---
changes in v2
   none
---
 app/test/test_power_cpufreq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index 2b4728d2e1..c24b706f4f 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -249,6 +249,8 @@ check_power_freq_down(void)
 {
 	int ret;
 
+	rte_power_freq_enable_turbo(TEST_POWER_LCORE_ID);
+
 	/* test with an invalid lcore id */
 	ret = rte_power_freq_down(TEST_POWER_LCORE_INVALID);
 	if (ret >= 0) {
-- 
2.17.1


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

* [dpdk-stable] [PATCH v2 4/4] test/power: fix turbo test
  2021-05-12 16:32 ` [dpdk-stable] [PATCH v2 " David Hunt
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 2/4] test/power: add turbo mode to freq check function David Hunt
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 3/4] test/power: fix low freq test when turbo enabled David Hunt
@ 2021-05-12 16:32   ` David Hunt
  2021-05-12 20:05     ` Thomas Monjalon
  2 siblings, 1 reply; 16+ messages in thread
From: David Hunt @ 2021-05-12 16:32 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

when turbo is enabled or disabled, the frequency is set to a low non-turbo
frequency, so we need to set to the frequency expected by the test before
checking.

Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature")
Cc: stable@dpdk.org

Signed-off-by: David Hunt <david.hunt@intel.com>

---
changes in v2
   none
---
 app/test/test_power_cpufreq.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index c24b706f4f..0c3adc5f33 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -436,6 +436,12 @@ check_power_turbo(void)
 				TEST_POWER_LCORE_ID);
 		return -1;
 	}
+	ret = rte_power_freq_max(TEST_POWER_LCORE_ID);
+	if (ret < 0) {
+		printf("Fail to scale up the freq to max on lcore %u\n",
+						TEST_POWER_LCORE_ID);
+		return -1;
+	}
 
 	/* Check the current frequency */
 	ret = check_cur_freq(TEST_POWER_LCORE_ID, 0, true);
@@ -455,6 +461,12 @@ check_power_turbo(void)
 				TEST_POWER_LCORE_ID);
 		return -1;
 	}
+	ret = rte_power_freq_max(TEST_POWER_LCORE_ID);
+	if (ret < 0) {
+		printf("Fail to scale up the freq to max on lcore %u\n",
+						TEST_POWER_LCORE_ID);
+		return -1;
+	}
 
 	/* Check the current frequency */
 	ret = check_cur_freq(TEST_POWER_LCORE_ID, 1, false);
-- 
2.17.1


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v1 2/4] test/power: add turbo mode to freq check function
  2021-05-12 15:34     ` Thomas Monjalon
@ 2021-05-12 16:38       ` David Hunt
  0 siblings, 0 replies; 16+ messages in thread
From: David Hunt @ 2021-05-12 16:38 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, stable, Burakov, Anatoly, ferruh.yigit


On 12/5/2021 4:34 PM, Thomas Monjalon wrote:
> 22/04/2021 18:13, Burakov, Anatoly:
>> On 22-Apr-21 3:40 PM, David Hunt wrote:
>>> --- a/app/test/test_power_cpufreq.c
>>> +++ b/app/test/test_power_cpufreq.c
>>> @@ -48,7 +48,7 @@ static uint32_t total_freq_num;
>>>    static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
>>>    
>>>    static int
>>> -check_cur_freq(unsigned lcore_id, uint32_t idx)
>>> +check_cur_freq(unsigned int lcore_id, uint32_t idx, int turbo)
>> Nitpicking, but stdbool exists :) it would be nice to use bool type for
>> bool variables, not int.
> Dave, I think you missed this comment.
>

Thanks for the reminder Thomas, I've just pushed a new version replacing 
the int with a bool.

Regards,
Dave.



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

* Re: [dpdk-stable] [PATCH v2 4/4] test/power: fix turbo test
  2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 4/4] test/power: fix turbo test David Hunt
@ 2021-05-12 20:05     ` Thomas Monjalon
  0 siblings, 0 replies; 16+ messages in thread
From: Thomas Monjalon @ 2021-05-12 20:05 UTC (permalink / raw)
  To: David Hunt; +Cc: dev, stable

12/05/2021 18:32, David Hunt:
> when turbo is enabled or disabled, the frequency is set to a low non-turbo
> frequency, so we need to set to the frequency expected by the test before
> checking.
> 
> Fixes: aeaeaf5f2d62 ("test/power: add cases for turbo feature")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Hunt <david.hunt@intel.com>

Series applied, thanks.




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

end of thread, other threads:[~2021-05-12 20:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 14:40 [dpdk-stable] [PATCH v1 1/4] test/power: fix check for cpu frequency David Hunt
2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 2/4] test/power: add turbo mode to freq check function David Hunt
2021-04-22 16:13   ` [dpdk-stable] [dpdk-dev] " Burakov, Anatoly
2021-05-12 15:34     ` Thomas Monjalon
2021-05-12 16:38       ` David Hunt
2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 3/4] test/power: fix low freq test when turbo enabled David Hunt
2021-04-22 14:40 ` [dpdk-stable] [PATCH v1 4/4] test/power: fix turbo test David Hunt
2021-04-29 10:34 ` [dpdk-stable] [dpdk-dev] [PATCH v1 1/4] test/power: fix check for cpu frequency Pattan, Reshma
2021-05-11 13:27   ` Thomas Monjalon
2021-05-11 14:41   ` David Hunt
2021-05-11 14:46     ` Pattan, Reshma
2021-05-12 16:32 ` [dpdk-stable] [PATCH v2 " David Hunt
2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 2/4] test/power: add turbo mode to freq check function David Hunt
2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 3/4] test/power: fix low freq test when turbo enabled David Hunt
2021-05-12 16:32   ` [dpdk-stable] [PATCH v2 4/4] test/power: fix turbo test David Hunt
2021-05-12 20:05     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).