Skip to content

Commit f3d3a8f

Browse files
rchatreshuahkh
authored andcommitted
selftests/resctrl: Prepare for parsing multiple events per iMC
The events needed to read memory bandwidth are discovered by iterating over every memory controller (iMC) within /sys/bus/event_source/devices. Each iMC's PMU is assumed to have one event to measure read memory bandwidth that is represented by the sysfs cas_count_read file. The event's configuration is read from "cas_count_read" and stored as an element of imc_counters_config[] by read_from_imc_dir() that receives the index of the array where to store the configuration as argument. It is possible that an iMC's PMU may have more than one event that should be used to measure memory bandwidth. Change semantics to not provide the index of the array to read_from_imc_dir() but instead a pointer to the index. This enables read_from_imc_dir() to store configurations for more than one event by incrementing the index to imc_counters_config[] itself. Ensure that the same type is consistently used for the index as it is passed around during counter configuration. Link: https://lore.kernel.org/r/549e026d20af0381349e645c912e6470fce8bd7e.1775266384.git.reinette.chatre@intel.com Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Chen Yu <yu.c.chen@intel.com> Reviewed-by: Zide Chen <zide.chen@intel.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent c066a68 commit f3d3a8f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tools/testing/selftests/resctrl/resctrl_val.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void read_mem_bw_ioctl_perf_event_ioc_disable(int i)
7373
* @cas_count_cfg: Config
7474
* @count: iMC number
7575
*/
76-
static void get_read_event_and_umask(char *cas_count_cfg, int count)
76+
static void get_read_event_and_umask(char *cas_count_cfg, unsigned int count)
7777
{
7878
char *token[MAX_TOKENS];
7979
int i = 0;
@@ -110,7 +110,7 @@ static int open_perf_read_event(int i, int cpu_no)
110110
}
111111

112112
/* Get type and config of an iMC counter's read event. */
113-
static int read_from_imc_dir(char *imc_dir, int count)
113+
static int read_from_imc_dir(char *imc_dir, unsigned int *count)
114114
{
115115
char cas_count_cfg[1024], imc_counter_cfg[1024], imc_counter_type[1024];
116116
FILE *fp;
@@ -123,7 +123,7 @@ static int read_from_imc_dir(char *imc_dir, int count)
123123

124124
return -1;
125125
}
126-
if (fscanf(fp, "%u", &imc_counters_config[count].type) <= 0) {
126+
if (fscanf(fp, "%u", &imc_counters_config[*count].type) <= 0) {
127127
ksft_perror("Could not get iMC type");
128128
fclose(fp);
129129

@@ -147,7 +147,8 @@ static int read_from_imc_dir(char *imc_dir, int count)
147147
}
148148
fclose(fp);
149149

150-
get_read_event_and_umask(cas_count_cfg, count);
150+
get_read_event_and_umask(cas_count_cfg, *count);
151+
*count += 1;
151152

152153
return 0;
153154
}
@@ -196,13 +197,12 @@ static int num_of_imcs(void)
196197
if (temp[0] >= '0' && temp[0] <= '9') {
197198
sprintf(imc_dir, "%s/%s/", DYN_PMU_PATH,
198199
ep->d_name);
199-
ret = read_from_imc_dir(imc_dir, count);
200+
ret = read_from_imc_dir(imc_dir, &count);
200201
if (ret) {
201202
closedir(dp);
202203

203204
return ret;
204205
}
205-
count++;
206206
}
207207
}
208208
closedir(dp);

0 commit comments

Comments
 (0)