diff mbox series

[V3,15/15] selftests/resctrl: Replace magic constants used as array size

Message ID 4d4887b0359bfd4094871f34aa8b06e2efee6043.1729218182.git.reinette.chatre@intel.com (mailing list archive)
State New
Headers show
Series selftests/resctrl: Support diverse platforms with MBM and MBA tests | expand

Commit Message

Reinette Chatre Oct. 18, 2024, 2:33 a.m. UTC
The Memory Bandwidth Allocation (MBA) test iterates through all possible
MBA allocations, from 10% (ALLOCATION_MIN) to 100% (ALLOCATION_MAX) with
increments of 10% (ALLOCATION_STEP) at each iteration. During each
iteration the test measures the actual memory bandwidth NUM_OF_RUNS times
to determine the impact of MBA on actual memory bandwidth.

After the MBA test completes all the memory bandwidth measurements are
parsed into an array. One array for resctrl Memory Bandwidth Monitoring
(MBM) measurements and one array for the Integrated Memory Controller
(iMC) measurements. Each array has a hardcoded size of 1024 that is
large enough to hold the current test data, but this hardcoded value makes
the implementation difficult to understand. It will not be clear that this
array needs to be reconsidered if any of the test parameters are changed.

Replace the magic constant as array size with the test parameters the
array size depends on.

Reported-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Closes: https://lore.kernel.org/all/45af2a8c-517d-8f0d-137d-ad0f3f6a3c68@linux.intel.com/
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
Changes since V2:
- New patch.
---
 tools/testing/selftests/resctrl/mba_test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ilpo Järvinen Oct. 18, 2024, 9:08 a.m. UTC | #1
On Thu, 17 Oct 2024, Reinette Chatre wrote:

> The Memory Bandwidth Allocation (MBA) test iterates through all possible
> MBA allocations, from 10% (ALLOCATION_MIN) to 100% (ALLOCATION_MAX) with
> increments of 10% (ALLOCATION_STEP) at each iteration. During each
> iteration the test measures the actual memory bandwidth NUM_OF_RUNS times
> to determine the impact of MBA on actual memory bandwidth.
> 
> After the MBA test completes all the memory bandwidth measurements are
> parsed into an array. One array for resctrl Memory Bandwidth Monitoring
> (MBM) measurements and one array for the Integrated Memory Controller
> (iMC) measurements. Each array has a hardcoded size of 1024 that is
> large enough to hold the current test data, but this hardcoded value makes
> the implementation difficult to understand. It will not be clear that this
> array needs to be reconsidered if any of the test parameters are changed.
> 
> Replace the magic constant as array size with the test parameters the
> array size depends on.
> 
> Reported-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Closes: https://lore.kernel.org/all/45af2a8c-517d-8f0d-137d-ad0f3f6a3c68@linux.intel.com/
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

--
 i.

> ---
> Changes since V2:
> - New patch.
> ---
>  tools/testing/selftests/resctrl/mba_test.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c
> index 4e6645b172e3..536d9089d2f6 100644
> --- a/tools/testing/selftests/resctrl/mba_test.c
> +++ b/tools/testing/selftests/resctrl/mba_test.c
> @@ -127,8 +127,9 @@ static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc)
>  
>  static int check_results(void)
>  {
> +	unsigned long bw_resc[NUM_OF_RUNS * ALLOCATION_MAX / ALLOCATION_STEP];
> +	unsigned long bw_imc[NUM_OF_RUNS * ALLOCATION_MAX / ALLOCATION_STEP];
>  	char *token_array[8], output[] = RESULT_FILE_NAME, temp[512];
> -	unsigned long bw_imc[1024], bw_resc[1024];
>  	int runs;
>  	FILE *fp;
>  
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c
index 4e6645b172e3..536d9089d2f6 100644
--- a/tools/testing/selftests/resctrl/mba_test.c
+++ b/tools/testing/selftests/resctrl/mba_test.c
@@ -127,8 +127,9 @@  static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc)
 
 static int check_results(void)
 {
+	unsigned long bw_resc[NUM_OF_RUNS * ALLOCATION_MAX / ALLOCATION_STEP];
+	unsigned long bw_imc[NUM_OF_RUNS * ALLOCATION_MAX / ALLOCATION_STEP];
 	char *token_array[8], output[] = RESULT_FILE_NAME, temp[512];
-	unsigned long bw_imc[1024], bw_resc[1024];
 	int runs;
 	FILE *fp;