selftests/resctrl: Add MBM test
MBM (Memory Bandwidth Monitoring) test is the first implemented selftest. It starts a stressful memory bandwidth benchmark and assigns the bandwidth pid in a resctrl monitoring group. Read and compare perf IMC counter and MBM total bytes for the benchmark. The numbers should be close enough to pass the test. Default benchmark is built-in fill_buf. But users can specify their own benchmark by option "-b". We can add memory bandwidth monitoring for multiple processes in the future. Co-developed-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com> Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com> Co-developed-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
@@ -388,6 +388,41 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool check_resctrlfs_support(void)
|
||||
{
|
||||
FILE *inf = fopen("/proc/filesystems", "r");
|
||||
DIR *dp;
|
||||
char *res;
|
||||
bool ret = false;
|
||||
|
||||
if (!inf)
|
||||
return false;
|
||||
|
||||
res = fgrep(inf, "nodev\tresctrl\n");
|
||||
|
||||
if (res) {
|
||||
ret = true;
|
||||
free(res);
|
||||
}
|
||||
|
||||
fclose(inf);
|
||||
|
||||
printf("%sok kernel supports resctrl filesystem\n", ret ? "" : "not ");
|
||||
tests_run++;
|
||||
|
||||
dp = opendir(RESCTRL_PATH);
|
||||
printf("%sok resctrl mountpoint \"%s\" exists\n",
|
||||
dp ? "" : "not ", RESCTRL_PATH);
|
||||
if (dp)
|
||||
closedir(dp);
|
||||
tests_run++;
|
||||
|
||||
printf("# resctrl filesystem %s mounted\n",
|
||||
find_resctrl_mount(NULL) ? "not" : "is");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *fgrep(FILE *inf, const char *str)
|
||||
{
|
||||
char line[256];
|
||||
@@ -433,6 +468,48 @@ bool validate_resctrl_feature_request(char *resctrl_val)
|
||||
return found;
|
||||
}
|
||||
|
||||
int filter_dmesg(void)
|
||||
{
|
||||
char line[1024];
|
||||
FILE *fp;
|
||||
int pipefds[2];
|
||||
pid_t pid;
|
||||
int ret;
|
||||
|
||||
ret = pipe(pipefds);
|
||||
if (ret) {
|
||||
perror("pipe");
|
||||
return ret;
|
||||
}
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
close(pipefds[0]);
|
||||
dup2(pipefds[1], STDOUT_FILENO);
|
||||
execlp("dmesg", "dmesg", NULL);
|
||||
perror("executing dmesg");
|
||||
exit(1);
|
||||
}
|
||||
close(pipefds[1]);
|
||||
fp = fdopen(pipefds[0], "r");
|
||||
if (!fp) {
|
||||
perror("fdopen(pipe)");
|
||||
kill(pid, SIGTERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (fgets(line, 1024, fp)) {
|
||||
if (strstr(line, "intel_rdt:"))
|
||||
printf("# dmesg: %s", line);
|
||||
if (strstr(line, "resctrl:"))
|
||||
printf("# dmesg: %s", line);
|
||||
}
|
||||
fclose(fp);
|
||||
waitpid(pid, NULL, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int validate_bw_report_request(char *bw_report)
|
||||
{
|
||||
if (strcmp(bw_report, "reads") == 0)
|
||||
|
||||
Reference in New Issue
Block a user