Skip to content

Commit d6d35d0

Browse files
maciejwieczorretmanshuahkh
authored andcommitted
selftests/resctrl: Discover SNC kernel support and adjust messages
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>
1 parent a1cd99e commit d6d35d0

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

tools/testing/selftests/resctrl/cmt_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param
169169
return ret;
170170

171171
ret = check_results(&param, span, n);
172-
if (ret && (get_vendor() == ARCH_INTEL))
173-
ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
172+
if (ret && (get_vendor() == ARCH_INTEL) && !snc_kernel_support())
173+
ksft_print_msg("Kernel doesn't support Sub-NUMA Clustering but it is enabled on the system.\n");
174174

175175
return ret;
176176
}

tools/testing/selftests/resctrl/mba_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param
201201
return ret;
202202

203203
ret = check_results();
204+
if (ret && (get_vendor() == ARCH_INTEL) && !snc_kernel_support())
205+
ksft_print_msg("Kernel doesn't support Sub-NUMA Clustering but it is enabled on the system.\n");
204206

205207
return ret;
206208
}

tools/testing/selftests/resctrl/mbm_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
160160
return ret;
161161

162162
ret = check_results(param.fill_buf ? param.fill_buf->buf_size : 0);
163-
if (ret && (get_vendor() == ARCH_INTEL))
164-
ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
163+
if (ret && (get_vendor() == ARCH_INTEL) && !snc_kernel_support())
164+
ksft_print_msg("Kernel doesn't support Sub-NUMA Clustering but it is enabled on the system.\n");
165165

166166
return ret;
167167
}

tools/testing/selftests/resctrl/resctrl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
203203
int signal_handler_register(const struct resctrl_test *test);
204204
void signal_handler_unregister(void);
205205
unsigned int count_bits(unsigned long n);
206+
int snc_kernel_support(void);
206207

207208
void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config);
208209
void perf_event_initialize_read_format(struct perf_event_read *pe_read);

tools/testing/selftests/resctrl/resctrlfs.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,3 +957,35 @@ unsigned int count_bits(unsigned long n)
957957

958958
return count;
959959
}
960+
961+
/**
962+
* snc_kernel_support - Check for existence of mon_sub_L3_00 file that indicates
963+
* SNC resctrl support on the kernel side.
964+
*
965+
* Return: 0 if not supported, 1 if SNC is disabled or SNC discovery is
966+
* unreliable or SNC is both enabled and supported.
967+
*/
968+
int snc_kernel_support(void)
969+
{
970+
char node_path[PATH_MAX];
971+
struct stat statbuf;
972+
int ret;
973+
974+
ret = snc_nodes_per_l3_cache();
975+
/*
976+
* If SNC is disabled then its kernel support isn't important. If SNC
977+
* got disabled because the discovery process was unreliable the
978+
* snc_unreliable variable was set. It can be used to verify the SNC
979+
* discovery reliability elsewhere in the selftest.
980+
*/
981+
if (ret == 1)
982+
return ret;
983+
984+
snprintf(node_path, sizeof(node_path), "%s/%s", RESCTRL_PATH,
985+
"mon_data/mon_L3_00/mon_sub_L3_00");
986+
987+
if (!stat(node_path, &statbuf))
988+
return 1;
989+
990+
return 0;
991+
}

0 commit comments

Comments
 (0)