All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.10] Revert "selftests/resctrl: Use resctrl/info for feature detection"
@ 2021-08-11 23:54 Reinette Chatre
  2021-08-13  8:41 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Reinette Chatre @ 2021-08-11 23:54 UTC (permalink / raw)
  To: stable
  Cc: fenghua.yu, skhan, sashal, gregkh, xiaochen.shen, tony.luck,
	Reinette Chatre

This reverts commit 19eaad1400eab34e97ec4467cd2ab694d1caf20c 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>
---

The same commit is present in v5.12.y where it also causes the
resctrl tests to fail to compile. I did not submit a revert against v5.12.y
because it is EOL.

 tools/testing/selftests/resctrl/resctrl.h   |  6 +--
 tools/testing/selftests/resctrl/resctrlfs.c | 52 +++++----------------
 2 files changed, 12 insertions(+), 46 deletions(-)

diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
index 9dcc96e1ad3d..36da6136af96 100644
--- a/tools/testing/selftests/resctrl/resctrl.h
+++ b/tools/testing/selftests/resctrl/resctrl.h
@@ -28,10 +28,6 @@
 #define RESCTRL_PATH		"/sys/fs/resctrl"
 #define PHYS_ID_PATH		"/sys/devices/system/cpu/cpu"
 #define CBM_MASK_PATH		"/sys/fs/resctrl/info"
-#define L3_PATH			"/sys/fs/resctrl/info/L3"
-#define MB_PATH			"/sys/fs/resctrl/info/MB"
-#define L3_MON_PATH		"/sys/fs/resctrl/info/L3_MON"
-#define L3_MON_FEATURES_PATH	"/sys/fs/resctrl/info/L3_MON/mon_features"
 
 #define PARENT_EXIT(err_msg)			\
 	do {					\
@@ -83,7 +79,7 @@ int remount_resctrlfs(bool mum_resctrlfs);
 int get_resource_id(int cpu_no, int *resource_id);
 int umount_resctrlfs(void);
 int validate_bw_report_request(char *bw_report);
-bool validate_resctrl_feature_request(const char *resctrl_val);
+bool validate_resctrl_feature_request(char *resctrl_val);
 char *fgrep(FILE *inf, const char *str);
 int taskset_benchmark(pid_t bm_pid, int cpu_no);
 void run_benchmark(int signum, siginfo_t *info, void *ucontext);
diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
index b57170f53861..4174e48e06d1 100644
--- a/tools/testing/selftests/resctrl/resctrlfs.c
+++ b/tools/testing/selftests/resctrl/resctrlfs.c
@@ -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 (!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);
-		}
+	if (res) {
+		char *s = strchr(res, ':');
+
+		found = s && !strstr(s, resctrl_val);
+		free(res);
 	}
+	fclose(inf);
 
 	return found;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5.10] Revert "selftests/resctrl: Use resctrl/info for feature detection"
  2021-08-11 23:54 [PATCH 5.10] Revert "selftests/resctrl: Use resctrl/info for feature detection" Reinette Chatre
@ 2021-08-13  8:41 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-08-13  8:41 UTC (permalink / raw)
  To: Reinette Chatre
  Cc: stable, fenghua.yu, skhan, sashal, xiaochen.shen, tony.luck

On Wed, Aug 11, 2021 at 04:54:21PM -0700, Reinette Chatre wrote:
> This reverts commit 19eaad1400eab34e97ec4467cd2ab694d1caf20c 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>
> ---
> 
> The same commit is present in v5.12.y where it also causes the
> resctrl tests to fail to compile. I did not submit a revert against v5.12.y
> because it is EOL.

Now queued up, thanks!

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-13  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 23:54 [PATCH 5.10] Revert "selftests/resctrl: Use resctrl/info for feature detection" Reinette Chatre
2021-08-13  8:41 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.