Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Maciej Wieczor-Retman and committed by
Shuah Khan
d6d35d0b a1cd99e7

+39 -4
+2 -2
tools/testing/selftests/resctrl/cmt_test.c
··· 169 169 return ret; 170 170 171 171 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"); 174 174 175 175 return ret; 176 176 }
+2
tools/testing/selftests/resctrl/mba_test.c
··· 201 201 return ret; 202 202 203 203 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"); 204 206 205 207 return ret; 206 208 }
+2 -2
tools/testing/selftests/resctrl/mbm_test.c
··· 160 160 return ret; 161 161 162 162 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"); 165 165 166 166 return ret; 167 167 }
+1
tools/testing/selftests/resctrl/resctrl.h
··· 203 203 int signal_handler_register(const struct resctrl_test *test); 204 204 void signal_handler_unregister(void); 205 205 unsigned int count_bits(unsigned long n); 206 + int snc_kernel_support(void); 206 207 207 208 void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config); 208 209 void perf_event_initialize_read_format(struct perf_event_read *pe_read);
+32
tools/testing/selftests/resctrl/resctrlfs.c
··· 957 957 958 958 return count; 959 959 } 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 + }