Revert "selftests/resctrl: Use resctrl/info for feature detection"
This reverts commit 19eaad1400
which is
ee0415681eb661efa1eb2db7acc263f2c7df1e23 upstream.
This commit is not a stable candidate and was backported without needed
dependencies that results in the resctrl tests unable to compile.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
d8c3859870
commit
0e70939037
@@ -616,56 +616,26 @@ char *fgrep(FILE *inf, const char *str)
|
||||
* validate_resctrl_feature_request - Check if requested feature is valid.
|
||||
* @resctrl_val: Requested feature
|
||||
*
|
||||
* Return: True if the feature is supported, else false
|
||||
* Return: 0 on success, non-zero on failure
|
||||
*/
|
||||
bool validate_resctrl_feature_request(const char *resctrl_val)
|
||||
bool validate_resctrl_feature_request(char *resctrl_val)
|
||||
{
|
||||
struct stat statbuf;
|
||||
FILE *inf = fopen("/proc/cpuinfo", "r");
|
||||
bool found = false;
|
||||
char *res;
|
||||
FILE *inf;
|
||||
|
||||
if (!resctrl_val)
|
||||
if (!inf)
|
||||
return false;
|
||||
|
||||
if (remount_resctrlfs(false))
|
||||
return false;
|
||||
res = fgrep(inf, "flags");
|
||||
|
||||
if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) {
|
||||
if (!stat(L3_PATH, &statbuf))
|
||||
return true;
|
||||
} else if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) {
|
||||
if (!stat(MB_PATH, &statbuf))
|
||||
return true;
|
||||
} else if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) ||
|
||||
!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) {
|
||||
if (!stat(L3_MON_PATH, &statbuf)) {
|
||||
inf = fopen(L3_MON_FEATURES_PATH, "r");
|
||||
if (!inf)
|
||||
return false;
|
||||
if (res) {
|
||||
char *s = strchr(res, ':');
|
||||
|
||||
if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) {
|
||||
res = fgrep(inf, "llc_occupancy");
|
||||
if (res) {
|
||||
found = true;
|
||||
free(res);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) {
|
||||
res = fgrep(inf, "mbm_total_bytes");
|
||||
if (res) {
|
||||
free(res);
|
||||
res = fgrep(inf, "mbm_local_bytes");
|
||||
if (res) {
|
||||
found = true;
|
||||
free(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(inf);
|
||||
}
|
||||
found = s && !strstr(s, resctrl_val);
|
||||
free(res);
|
||||
}
|
||||
fclose(inf);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
Reference in New Issue
Block a user