mbox series

[0/4] selftests/resctrl: Enable MBM and MBA tests on AMD

Message ID cover.1708637563.git.babu.moger@amd.com
Headers show
Series selftests/resctrl: Enable MBM and MBA tests on AMD | expand

Message

Moger, Babu Feb. 22, 2024, 9:35 p.m. UTC
The MBM (Memory Bandwidth Monitoring) and MBA (Memory Bandwidth Allocation)
features are not enabled for AMD systems. The reason was lack of perf
counters to compare the resctrl test results.

Starting with the commit
25e56847821f ("perf/x86/amd/uncore: Add memory controller support"), AMD
now supports the UMC (Unified Memory Controller) perf events. These events
can be used to compare the test results.

This series adds the support to detect the UMC events and enable MBM/MBA
tests for AMD systems.


Babu Moger (4):
  selftests/resctrl: Rename variable imcs and num_of_imcs() to generic
    names
  selftests/resctrl: Pass sysfs controller name of the vendor
  selftests/resctrl: Add support for MBM and MBA tests on AMD
  selftests/resctrl: Skip the tests if iMC/UMC counters are unavailable

 tools/testing/selftests/resctrl/resctrl.h     |   1 +
 .../testing/selftests/resctrl/resctrl_tests.c |  16 ++-
 tools/testing/selftests/resctrl/resctrl_val.c | 105 ++++++++++++++----
 3 files changed, 96 insertions(+), 26 deletions(-)

Comments

Ilpo Järvinen Feb. 23, 2024, 10:38 a.m. UTC | #1
On Thu, 22 Feb 2024, Babu Moger wrote:

> In an effort to support MBM and MBA tests for AMD, renaming for variable
> and functions to generic names. For Intel, the memory controller is called
> Integrated Memory Controllers (IMC). For AMD, it is called Unified
> Memory Controller (UMC). No functional change.
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
>  tools/testing/selftests/resctrl/resctrl_val.c | 25 ++++++++++---------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
> index 88789678917b..52e23a8076d3 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -60,7 +60,7 @@ struct imc_counter_config {
>  };
>  
>  static char mbm_total_path[1024];
> -static int imcs;
> +static int number_of_mem_ctrls;
>  static struct imc_counter_config imc_counters_config[MAX_IMCS][2];
>  
>  void membw_initialize_perf_event_attr(int i, int j)
> @@ -211,15 +211,16 @@ static int read_from_imc_dir(char *imc_dir, int count)
>  }
>  
>  /*
> - * A system can have 'n' number of iMC (Integrated Memory Controller)
> - * counters, get that 'n'. For each iMC counter get it's type and config.
> + * A system can have 'n' number of iMC (Integrated Memory Controller for
> + * Intel) counters, get that 'n'. In case of AMD it is called UMC (Unified
> + * Memory Controller). For each iMC/UMC counter get it's type and config.
>   * Also, each counter has two configs, one for read and the other for write.
>   * A config again has two parts, event and umask.
>   * Enumerate all these details into an array of structures.
>   *
>   * Return: >= 0 on success. < 0 on failure.
>   */
> -static int num_of_imcs(void)
> +static int get_number_of_mem_ctrls(void)

It's a bit odd to shorten "memory" and "controller" but not "number". In 
fact, I'd prefer to use "controllers" in the longer form because ctrls 
is ambiguous ("control" vs "controller").

So perhaps num_of_mem_controllers(void) (or that with get_ prefix if you 
insist).

>  {
>  	char imc_dir[512], *temp;
>  	unsigned int count = 0;
> @@ -279,12 +280,12 @@ static int initialize_mem_bw_imc(void)
>  {
>  	int imc, j;
>  
> -	imcs = num_of_imcs();
> -	if (imcs <= 0)
> -		return imcs;
> +	number_of_mem_ctrls = get_number_of_mem_ctrls();
> +	if (number_of_mem_ctrls <= 0)
> +		return number_of_mem_ctrls;
>  
>  	/* Initialize perf_event_attr structures for all iMC's */
> -	for (imc = 0; imc < imcs; imc++) {
> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {

So you renamed imcs, but not imc. Perhaps the variable names could just be 
"mc" and "mcs"?

>  		for (j = 0; j < 2; j++)
>  			membw_initialize_perf_event_attr(imc, j);
>  	}
> @@ -309,7 +310,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>  
>  	/* Start all iMC counters to log values (both read and write) */
>  	reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1;
> -	for (imc = 0; imc < imcs; imc++) {
> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>  		for (j = 0; j < 2; j++) {
>  			ret = open_perf_event(imc, cpu_no, j);
>  			if (ret)
> @@ -322,7 +323,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>  	sleep(1);
>  
>  	/* Stop counters after a second to get results (both read and write) */
> -	for (imc = 0; imc < imcs; imc++) {
> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>  		for (j = 0; j < 2; j++)
>  			membw_ioctl_perf_event_ioc_disable(imc, j);
>  	}
> @@ -331,7 +332,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>  	 * Get results which are stored in struct type imc_counter_config
>  	 * Take over flow into consideration before calculating total b/w
>  	 */
> -	for (imc = 0; imc < imcs; imc++) {
> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>  		struct imc_counter_config *r =
>  			&imc_counters_config[imc][READ];
>  		struct imc_counter_config *w =
> @@ -368,7 +369,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>  		writes += w->return_value.value * of_mul_write * SCALE;
>  	}
>  
> -	for (imc = 0; imc < imcs; imc++) {
> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>  		close(imc_counters_config[imc][READ].fd);
>  		close(imc_counters_config[imc][WRITE].fd);

I've a yet submitted patch to convert these close() calls to use the 
loop approach which is consistent with the rest of the code, since you
will end up touching this when you do imc -> mc rename, it would be 
preferrable if you add one patch into your series which converts them to:

		for (j = 0; j < 2; j++)
			close(imc_counters_config[mc][j].fd);

(Given how long kselftest patches tend to linger unapplied, it would 
make things a lot easier since those changes will obviously conflict 
otherwise).
Ilpo Järvinen Feb. 23, 2024, 10:53 a.m. UTC | #2
On Thu, 22 Feb 2024, Babu Moger wrote:

> Add support to read UMC (Unified Memory Controller) perf events to compare
> the numbers with QoS monitor for AMD.
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
>  .../testing/selftests/resctrl/resctrl_tests.c |  6 +-
>  tools/testing/selftests/resctrl/resctrl_val.c | 62 +++++++++++++++++--
>  2 files changed, 58 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
> index 2bbe3045a018..231233b8d354 100644
> --- a/tools/testing/selftests/resctrl/resctrl_tests.c
> +++ b/tools/testing/selftests/resctrl/resctrl_tests.c
> @@ -104,8 +104,7 @@ static void run_mbm_test(const char * const *benchmark_cmd, int cpu_no)
>  	}
>  
>  	if (!validate_resctrl_feature_request("L3_MON", "mbm_total_bytes") ||
> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
> -	    (get_vendor() != ARCH_INTEL)) {
> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>  		ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n");
>  		goto cleanup;
>  	}
> @@ -131,8 +130,7 @@ static void run_mba_test(const char * const *benchmark_cmd, int cpu_no)
>  	}
>  
>  	if (!validate_resctrl_feature_request("MB", NULL) ||
> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
> -	    (get_vendor() != ARCH_INTEL)) {
> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>  		ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n");
>  		goto cleanup;
>  	}

These need to be rebased as this code moved into per test files with the 
generic test framework. The .vendor_specific field is the new way to make 
tests limited to particular vendors.

> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
> index 792116d3565f..c5a4607aa9d9 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -11,6 +11,7 @@
>  #include "resctrl.h"
>  
>  #define UNCORE_IMC		"uncore_imc"
> +#define AMD_UMC			"amd_umc"
>  #define READ_FILE_NAME		"events/cas_count_read"
>  #define WRITE_FILE_NAME		"events/cas_count_write"
>  #define DYN_PMU_PATH		"/sys/bus/event_source/devices"
> @@ -146,6 +147,47 @@ static int open_perf_event(int i, int cpu_no, int j)
>  	return 0;
>  }
>  
> +/* Get type and config (read and write) of an UMC counter */
> +static int read_from_umc_dir(char *umc_dir, int count)
> +{
> +	char umc_counter_type[1024];

PATH_MAX

> +	FILE *fp;
> +
> +	/* Get type of iMC counter */
> +	sprintf(umc_counter_type, "%s%s", umc_dir, "type");
> +	fp = fopen(umc_counter_type, "r");
> +	if (!fp) {
> +		perror("Failed to open imc counter type file");

Please don't add new perror() anymore, I just managed to clean up those
in favor of ksft_perror().

> +

Drop this newline (to slowly move towards more concise error handling 
blocks w/o all those extra newlines).

> +		return -1;


> +	}
> +	if (fscanf(fp, "%u", &imc_counters_config[count][READ].type) <= 0) {
> +		perror("Could not get imc type");

Ditto.

> +		fclose(fp);
> +		return -1;
> +	}
> +
> +	fclose(fp);
> +
> +	imc_counters_config[count][WRITE].type =
> +		imc_counters_config[count][READ].type;
> +
> +	/*
> +	 * Setup the event and umasks for UMC events
> +	 * Number of CAS commands sent for reads:
> +	 * EventCode = 0x0a, umask = 0x1
> +	 * Number of CAS commands sent for writes:
> +	 * EventCode = 0x0a, umask = 0x2
> +	 */
> +	imc_counters_config[count][READ].event = 0xa;
> +	imc_counters_config[count][READ].umask = 0x1;
> +
> +	imc_counters_config[count][WRITE].event = 0xa;
> +	imc_counters_config[count][WRITE].umask = 0x2;
> +
> +	return 0;
> +}
> +
>  /* Get type and config (read and write) of an iMC counter */
>  static int read_from_imc_dir(char *imc_dir, int count)
>  {
Moger, Babu Feb. 23, 2024, 6:11 p.m. UTC | #3
Hi Ilpo,

On 2/23/24 04:38, Ilpo Järvinen wrote:
> On Thu, 22 Feb 2024, Babu Moger wrote:
> 
>> In an effort to support MBM and MBA tests for AMD, renaming for variable
>> and functions to generic names. For Intel, the memory controller is called
>> Integrated Memory Controllers (IMC). For AMD, it is called Unified
>> Memory Controller (UMC). No functional change.
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> ---
>>  tools/testing/selftests/resctrl/resctrl_val.c | 25 ++++++++++---------
>>  1 file changed, 13 insertions(+), 12 deletions(-)
>>
>> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
>> index 88789678917b..52e23a8076d3 100644
>> --- a/tools/testing/selftests/resctrl/resctrl_val.c
>> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
>> @@ -60,7 +60,7 @@ struct imc_counter_config {
>>  };
>>  
>>  static char mbm_total_path[1024];
>> -static int imcs;
>> +static int number_of_mem_ctrls;
>>  static struct imc_counter_config imc_counters_config[MAX_IMCS][2];
>>  
>>  void membw_initialize_perf_event_attr(int i, int j)
>> @@ -211,15 +211,16 @@ static int read_from_imc_dir(char *imc_dir, int count)
>>  }
>>  
>>  /*
>> - * A system can have 'n' number of iMC (Integrated Memory Controller)
>> - * counters, get that 'n'. For each iMC counter get it's type and config.
>> + * A system can have 'n' number of iMC (Integrated Memory Controller for
>> + * Intel) counters, get that 'n'. In case of AMD it is called UMC (Unified
>> + * Memory Controller). For each iMC/UMC counter get it's type and config.
>>   * Also, each counter has two configs, one for read and the other for write.
>>   * A config again has two parts, event and umask.
>>   * Enumerate all these details into an array of structures.
>>   *
>>   * Return: >= 0 on success. < 0 on failure.
>>   */
>> -static int num_of_imcs(void)
>> +static int get_number_of_mem_ctrls(void)
> 
> It's a bit odd to shorten "memory" and "controller" but not "number". In 
> fact, I'd prefer to use "controllers" in the longer form because ctrls 
> is ambiguous ("control" vs "controller").
> 
> So perhaps num_of_mem_controllers(void) (or that with get_ prefix if you 
> insist).

Sure. num_of_mem_controllers looks good.

> 
>>  {
>>  	char imc_dir[512], *temp;
>>  	unsigned int count = 0;
>> @@ -279,12 +280,12 @@ static int initialize_mem_bw_imc(void)
>>  {
>>  	int imc, j;
>>  
>> -	imcs = num_of_imcs();
>> -	if (imcs <= 0)
>> -		return imcs;
>> +	number_of_mem_ctrls = get_number_of_mem_ctrls();
>> +	if (number_of_mem_ctrls <= 0)
>> +		return number_of_mem_ctrls;
>>  
>>  	/* Initialize perf_event_attr structures for all iMC's */
>> -	for (imc = 0; imc < imcs; imc++) {
>> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
> 
> So you renamed imcs, but not imc. Perhaps the variable names could just be 
> "mc" and "mcs"?

How about mem_ctrls ?
> 
>>  		for (j = 0; j < 2; j++)
>>  			membw_initialize_perf_event_attr(imc, j);
>>  	}
>> @@ -309,7 +310,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>>  
>>  	/* Start all iMC counters to log values (both read and write) */
>>  	reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1;
>> -	for (imc = 0; imc < imcs; imc++) {
>> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>>  		for (j = 0; j < 2; j++) {
>>  			ret = open_perf_event(imc, cpu_no, j);
>>  			if (ret)
>> @@ -322,7 +323,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>>  	sleep(1);
>>  
>>  	/* Stop counters after a second to get results (both read and write) */
>> -	for (imc = 0; imc < imcs; imc++) {
>> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>>  		for (j = 0; j < 2; j++)
>>  			membw_ioctl_perf_event_ioc_disable(imc, j);
>>  	}
>> @@ -331,7 +332,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>>  	 * Get results which are stored in struct type imc_counter_config
>>  	 * Take over flow into consideration before calculating total b/w
>>  	 */
>> -	for (imc = 0; imc < imcs; imc++) {
>> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>>  		struct imc_counter_config *r =
>>  			&imc_counters_config[imc][READ];
>>  		struct imc_counter_config *w =
>> @@ -368,7 +369,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>>  		writes += w->return_value.value * of_mul_write * SCALE;
>>  	}
>>  
>> -	for (imc = 0; imc < imcs; imc++) {
>> +	for (imc = 0; imc < number_of_mem_ctrls; imc++) {
>>  		close(imc_counters_config[imc][READ].fd);
>>  		close(imc_counters_config[imc][WRITE].fd);
> 
> I've a yet submitted patch to convert these close() calls to use the 
> loop approach which is consistent with the rest of the code, since you
> will end up touching this when you do imc -> mc rename, it would be 
> preferrable if you add one patch into your series which converts them to:
> 
> 		for (j = 0; j < 2; j++)
> 			close(imc_counters_config[mc][j].fd);

Sure. Will do.

> 
> (Given how long kselftest patches tend to linger unapplied, it would 
> make things a lot easier since those changes will obviously conflict 
> otherwise).
> 

Actually, I can wait for you to submit your patches.  Let me know.
Moger, Babu Feb. 23, 2024, 7:30 p.m. UTC | #4
Hi Ilpo,

On 2/23/24 04:53, Ilpo Järvinen wrote:
> On Thu, 22 Feb 2024, Babu Moger wrote:
> 
>> Add support to read UMC (Unified Memory Controller) perf events to compare
>> the numbers with QoS monitor for AMD.
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> ---
>>  .../testing/selftests/resctrl/resctrl_tests.c |  6 +-
>>  tools/testing/selftests/resctrl/resctrl_val.c | 62 +++++++++++++++++--
>>  2 files changed, 58 insertions(+), 10 deletions(-)
>>
>> diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
>> index 2bbe3045a018..231233b8d354 100644
>> --- a/tools/testing/selftests/resctrl/resctrl_tests.c
>> +++ b/tools/testing/selftests/resctrl/resctrl_tests.c
>> @@ -104,8 +104,7 @@ static void run_mbm_test(const char * const *benchmark_cmd, int cpu_no)
>>  	}
>>  
>>  	if (!validate_resctrl_feature_request("L3_MON", "mbm_total_bytes") ||
>> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
>> -	    (get_vendor() != ARCH_INTEL)) {
>> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>>  		ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n");
>>  		goto cleanup;
>>  	}
>> @@ -131,8 +130,7 @@ static void run_mba_test(const char * const *benchmark_cmd, int cpu_no)
>>  	}
>>  
>>  	if (!validate_resctrl_feature_request("MB", NULL) ||
>> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
>> -	    (get_vendor() != ARCH_INTEL)) {
>> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>>  		ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n");
>>  		goto cleanup;
>>  	}
> 
> These need to be rebased as this code moved into per test files with the 
> generic test framework. The .vendor_specific field is the new way to make 
> tests limited to particular vendors.

Hmm. I picked the latest code from tip/master. Where is the latest code
now? Is it yet to be submitted?

I can wait for your code to merge first.

> 
>> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
>> index 792116d3565f..c5a4607aa9d9 100644
>> --- a/tools/testing/selftests/resctrl/resctrl_val.c
>> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
>> @@ -11,6 +11,7 @@
>>  #include "resctrl.h"
>>  
>>  #define UNCORE_IMC		"uncore_imc"
>> +#define AMD_UMC			"amd_umc"
>>  #define READ_FILE_NAME		"events/cas_count_read"
>>  #define WRITE_FILE_NAME		"events/cas_count_write"
>>  #define DYN_PMU_PATH		"/sys/bus/event_source/devices"
>> @@ -146,6 +147,47 @@ static int open_perf_event(int i, int cpu_no, int j)
>>  	return 0;
>>  }
>>  
>> +/* Get type and config (read and write) of an UMC counter */
>> +static int read_from_umc_dir(char *umc_dir, int count)
>> +{
>> +	char umc_counter_type[1024];
> 
> PATH_MAX

ok.
> 
>> +	FILE *fp;
>> +
>> +	/* Get type of iMC counter */
>> +	sprintf(umc_counter_type, "%s%s", umc_dir, "type");
>> +	fp = fopen(umc_counter_type, "r");
>> +	if (!fp) {
>> +		perror("Failed to open imc counter type file");
> 
> Please don't add new perror() anymore, I just managed to clean up those
> in favor of ksft_perror().

Ok. Will look into it.
> 
>> +
> 
> Drop this newline (to slowly move towards more concise error handling 
> blocks w/o all those extra newlines).

ok.

> 
>> +		return -1;
> 
> 
>> +	}
>> +	if (fscanf(fp, "%u", &imc_counters_config[count][READ].type) <= 0) {
>> +		perror("Could not get imc type");
> 
> Ditto.

ok

> 
>> +		fclose(fp);
>> +		return -1;
>> +	}
>> +
>> +	fclose(fp);
>> +
>> +	imc_counters_config[count][WRITE].type =
>> +		imc_counters_config[count][READ].type;
>> +
>> +	/*
>> +	 * Setup the event and umasks for UMC events
>> +	 * Number of CAS commands sent for reads:
>> +	 * EventCode = 0x0a, umask = 0x1
>> +	 * Number of CAS commands sent for writes:
>> +	 * EventCode = 0x0a, umask = 0x2
>> +	 */
>> +	imc_counters_config[count][READ].event = 0xa;
>> +	imc_counters_config[count][READ].umask = 0x1;
>> +
>> +	imc_counters_config[count][WRITE].event = 0xa;
>> +	imc_counters_config[count][WRITE].umask = 0x2;
>> +
>> +	return 0;
>> +}
>> +
>>  /* Get type and config (read and write) of an iMC counter */
>>  static int read_from_imc_dir(char *imc_dir, int count)
>>  {
>
Moger, Babu Feb. 23, 2024, 7:47 p.m. UTC | #5
On 2/23/24 13:30, Moger, Babu wrote:
> Hi Ilpo,
> 
> On 2/23/24 04:53, Ilpo Järvinen wrote:
>> On Thu, 22 Feb 2024, Babu Moger wrote:
>>
>>> Add support to read UMC (Unified Memory Controller) perf events to compare
>>> the numbers with QoS monitor for AMD.
>>>
>>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>>> ---
>>>  .../testing/selftests/resctrl/resctrl_tests.c |  6 +-
>>>  tools/testing/selftests/resctrl/resctrl_val.c | 62 +++++++++++++++++--
>>>  2 files changed, 58 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
>>> index 2bbe3045a018..231233b8d354 100644
>>> --- a/tools/testing/selftests/resctrl/resctrl_tests.c
>>> +++ b/tools/testing/selftests/resctrl/resctrl_tests.c
>>> @@ -104,8 +104,7 @@ static void run_mbm_test(const char * const *benchmark_cmd, int cpu_no)
>>>  	}
>>>  
>>>  	if (!validate_resctrl_feature_request("L3_MON", "mbm_total_bytes") ||
>>> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
>>> -	    (get_vendor() != ARCH_INTEL)) {
>>> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>>>  		ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n");
>>>  		goto cleanup;
>>>  	}
>>> @@ -131,8 +130,7 @@ static void run_mba_test(const char * const *benchmark_cmd, int cpu_no)
>>>  	}
>>>  
>>>  	if (!validate_resctrl_feature_request("MB", NULL) ||
>>> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
>>> -	    (get_vendor() != ARCH_INTEL)) {
>>> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>>>  		ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n");
>>>  		goto cleanup;
>>>  	}
>>
>> These need to be rebased as this code moved into per test files with the 
>> generic test framework. The .vendor_specific field is the new way to make 
>> tests limited to particular vendors.
> 
> Hmm. I picked the latest code from tip/master. Where is the latest code
> now? Is it yet to be submitted?
> 
> I can wait for your code to merge first.

Oh. ok. Here it is
https://lore.kernel.org/lkml/cover.1708072203.git.maciej.wieczor-retman@intel.com/

I will rebase it on top of this next revision.

Thanks
Babu

> 
>>
>>> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
>>> index 792116d3565f..c5a4607aa9d9 100644
>>> --- a/tools/testing/selftests/resctrl/resctrl_val.c
>>> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
>>> @@ -11,6 +11,7 @@
>>>  #include "resctrl.h"
>>>  
>>>  #define UNCORE_IMC		"uncore_imc"
>>> +#define AMD_UMC			"amd_umc"
>>>  #define READ_FILE_NAME		"events/cas_count_read"
>>>  #define WRITE_FILE_NAME		"events/cas_count_write"
>>>  #define DYN_PMU_PATH		"/sys/bus/event_source/devices"
>>> @@ -146,6 +147,47 @@ static int open_perf_event(int i, int cpu_no, int j)
>>>  	return 0;
>>>  }
>>>  
>>> +/* Get type and config (read and write) of an UMC counter */
>>> +static int read_from_umc_dir(char *umc_dir, int count)
>>> +{
>>> +	char umc_counter_type[1024];
>>
>> PATH_MAX
> 
> ok.
>>
>>> +	FILE *fp;
>>> +
>>> +	/* Get type of iMC counter */
>>> +	sprintf(umc_counter_type, "%s%s", umc_dir, "type");
>>> +	fp = fopen(umc_counter_type, "r");
>>> +	if (!fp) {
>>> +		perror("Failed to open imc counter type file");
>>
>> Please don't add new perror() anymore, I just managed to clean up those
>> in favor of ksft_perror().
> 
> Ok. Will look into it.
>>
>>> +
>>
>> Drop this newline (to slowly move towards more concise error handling 
>> blocks w/o all those extra newlines).
> 
> ok.
> 
>>
>>> +		return -1;
>>
>>
>>> +	}
>>> +	if (fscanf(fp, "%u", &imc_counters_config[count][READ].type) <= 0) {
>>> +		perror("Could not get imc type");
>>
>> Ditto.
> 
> ok
> 
>>
>>> +		fclose(fp);
>>> +		return -1;
>>> +	}
>>> +
>>> +	fclose(fp);
>>> +
>>> +	imc_counters_config[count][WRITE].type =
>>> +		imc_counters_config[count][READ].type;
>>> +
>>> +	/*
>>> +	 * Setup the event and umasks for UMC events
>>> +	 * Number of CAS commands sent for reads:
>>> +	 * EventCode = 0x0a, umask = 0x1
>>> +	 * Number of CAS commands sent for writes:
>>> +	 * EventCode = 0x0a, umask = 0x2
>>> +	 */
>>> +	imc_counters_config[count][READ].event = 0xa;
>>> +	imc_counters_config[count][READ].umask = 0x1;
>>> +
>>> +	imc_counters_config[count][WRITE].event = 0xa;
>>> +	imc_counters_config[count][WRITE].umask = 0x2;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>>  /* Get type and config (read and write) of an iMC counter */
>>>  static int read_from_imc_dir(char *imc_dir, int count)
>>>  {
>>
>
Reinette Chatre Feb. 23, 2024, 10:39 p.m. UTC | #6
Hi Babu,

On 2/23/2024 11:47 AM, Moger, Babu wrote:
> On 2/23/24 13:30, Moger, Babu wrote:
>> On 2/23/24 04:53, Ilpo Järvinen wrote:
>>> On Thu, 22 Feb 2024, Babu Moger wrote:
>>>> @@ -131,8 +130,7 @@ static void run_mba_test(const char * const *benchmark_cmd, int cpu_no)
>>>>  	}
>>>>  
>>>>  	if (!validate_resctrl_feature_request("MB", NULL) ||
>>>> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
>>>> -	    (get_vendor() != ARCH_INTEL)) {
>>>> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>>>>  		ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n");
>>>>  		goto cleanup;
>>>>  	}
>>>
>>> These need to be rebased as this code moved into per test files with the 
>>> generic test framework. The .vendor_specific field is the new way to make 
>>> tests limited to particular vendors.
>>
>> Hmm. I picked the latest code from tip/master. Where is the latest code
>> now? Is it yet to be submitted?
>>
>> I can wait for your code to merge first.
> 
> Oh. ok. Here it is
> https://lore.kernel.org/lkml/cover.1708072203.git.maciej.wieczor-retman@intel.com/
> 
> I will rebase it on top of this next revision.

The resctrl selftest changes are routed through the kselftest repo. Shuah just picked
up this series you noticed but it is based on the framework changes from Ilpo that
is already merged. I recommend that you base your next series on the "next" branch
of the kselftest repo [1].

Reinette

[1] git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
Moger, Babu Feb. 26, 2024, 6:02 p.m. UTC | #7
Hi Reinette

On 2/23/24 16:39, Reinette Chatre wrote:
> Hi Babu,
> 
> On 2/23/2024 11:47 AM, Moger, Babu wrote:
>> On 2/23/24 13:30, Moger, Babu wrote:
>>> On 2/23/24 04:53, Ilpo Järvinen wrote:
>>>> On Thu, 22 Feb 2024, Babu Moger wrote:
>>>>> @@ -131,8 +130,7 @@ static void run_mba_test(const char * const *benchmark_cmd, int cpu_no)
>>>>>  	}
>>>>>  
>>>>>  	if (!validate_resctrl_feature_request("MB", NULL) ||
>>>>> -	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") ||
>>>>> -	    (get_vendor() != ARCH_INTEL)) {
>>>>> +	    !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes")) {
>>>>>  		ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n");
>>>>>  		goto cleanup;
>>>>>  	}
>>>>
>>>> These need to be rebased as this code moved into per test files with the 
>>>> generic test framework. The .vendor_specific field is the new way to make 
>>>> tests limited to particular vendors.
>>>
>>> Hmm. I picked the latest code from tip/master. Where is the latest code
>>> now? Is it yet to be submitted?
>>>
>>> I can wait for your code to merge first.
>>
>> Oh. ok. Here it is
>> https://lore.kernel.org/lkml/cover.1708072203.git.maciej.wieczor-retman@intel.com/
>>
>> I will rebase it on top of this next revision.
> 
> The resctrl selftest changes are routed through the kselftest repo. Shuah just picked
> up this series you noticed but it is based on the framework changes from Ilpo that
> is already merged. I recommend that you base your next series on the "next" branch
> of the kselftest repo [1].

Sure. Will do.
> 
> Reinette
> 
> [1] git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git