]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/resctrl: Discover SNC kernel support and adjust messages
authorMaciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Mon, 16 Dec 2024 15:18:54 +0000 (16:18 +0100)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 15 Jan 2025 00:06:32 +0000 (17:06 -0700)
Resctrl selftest prints a message on test failure that Sub-Numa
Clustering (SNC) could be enabled and points the user to check their BIOS
settings. No actual check is performed before printing that message so
it is not very accurate in pinpointing a problem.

When there is SNC support for kernel's resctrl subsystem and SNC is
enabled then sub node files are created for each node in the resctrlfs.
The sub node files exist in each regular node's L3 monitoring directory.
The reliable path to check for existence of sub node files is
/sys/fs/resctrl/mon_data/mon_L3_00/mon_sub_L3_00.

Add helper that checks for mon_sub_L3_00 existence.

Correct old messages to account for kernel support of SNC in
resctrl.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/resctrl/cmt_test.c
tools/testing/selftests/resctrl/mba_test.c
tools/testing/selftests/resctrl/mbm_test.c
tools/testing/selftests/resctrl/resctrl.h
tools/testing/selftests/resctrl/resctrlfs.c

index 3bbf3042fb06e2f24a6e922a8c61500c96490a23..d09e693dc739cb0dbf97acd39ffc9cf5c1545bc1 100644 (file)
@@ -169,8 +169,8 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param
                return ret;
 
        ret = check_results(&param, span, n);
-       if (ret && (get_vendor() == ARCH_INTEL))
-               ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
+       if (ret && (get_vendor() == ARCH_INTEL) && !snc_kernel_support())
+               ksft_print_msg("Kernel doesn't support Sub-NUMA Clustering but it is enabled on the system.\n");
 
        return ret;
 }
index 536d9089d2f6c87ebd139906c342ecb5afad2ebc..c7e9adc0368f3bc0aa45f9cc8d4a6f01d54439c6 100644 (file)
@@ -201,6 +201,8 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param
                return ret;
 
        ret = check_results();
+       if (ret && (get_vendor() == ARCH_INTEL) && !snc_kernel_support())
+               ksft_print_msg("Kernel doesn't support Sub-NUMA Clustering but it is enabled on the system.\n");
 
        return ret;
 }
index 315b2ef3b3bcb935a5fd5e8c81430d6f375f7367..84d8bc2505392e921020789840efeefd457be7d8 100644 (file)
@@ -160,8 +160,8 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
                return ret;
 
        ret = check_results(param.fill_buf ? param.fill_buf->buf_size : 0);
-       if (ret && (get_vendor() == ARCH_INTEL))
-               ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
+       if (ret && (get_vendor() == ARCH_INTEL) && !snc_kernel_support())
+               ksft_print_msg("Kernel doesn't support Sub-NUMA Clustering but it is enabled on the system.\n");
 
        return ret;
 }
index 35fa3afee9c3c3fc9b1289045f18fa6929c8cdce..cd3adfc14969fcd3a7d815afbe328578d7064704 100644 (file)
@@ -203,6 +203,7 @@ void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
 int signal_handler_register(const struct resctrl_test *test);
 void signal_handler_unregister(void);
 unsigned int count_bits(unsigned long n);
+int snc_kernel_support(void);
 
 void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config);
 void perf_event_initialize_read_format(struct perf_event_read *pe_read);
index dc7ce3cbdb271bf09be4d24415f5c6a1b4e13b7b..195f04c4d15868e8f15631afbd985d4c89e5a0bf 100644 (file)
@@ -957,3 +957,35 @@ unsigned int count_bits(unsigned long n)
 
        return count;
 }
+
+/**
+ * snc_kernel_support - Check for existence of mon_sub_L3_00 file that indicates
+ * SNC resctrl support on the kernel side.
+ *
+ * Return: 0 if not supported, 1 if SNC is disabled or SNC discovery is
+ * unreliable or SNC is both enabled and supported.
+ */
+int snc_kernel_support(void)
+{
+       char node_path[PATH_MAX];
+       struct stat statbuf;
+       int ret;
+
+       ret = snc_nodes_per_l3_cache();
+       /*
+        * If SNC is disabled then its kernel support isn't important. If SNC
+        * got disabled because the discovery process was unreliable the
+        * snc_unreliable variable was set. It can be used to verify the SNC
+        * discovery reliability elsewhere in the selftest.
+        */
+       if (ret == 1)
+               return ret;
+
+       snprintf(node_path, sizeof(node_path), "%s/%s", RESCTRL_PATH,
+                "mon_data/mon_L3_00/mon_sub_L3_00");
+
+       if (!stat(node_path, &statbuf))
+               return 1;
+
+       return 0;
+}