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

Configure Feed

Select the types of activity you want to include in your feed.

selftests/resctrl: Use cache size to determine "fill_buf" buffer size

By default the MBM and MBA tests use the "fill_buf" benchmark to
read from a buffer with the goal to measure the memory bandwidth
generated by this buffer access.

Care should be taken when sizing the buffer used by the "fill_buf"
benchmark. If the buffer is small enough to fit in the cache then
it cannot be expected that the benchmark will generate much memory
bandwidth. For example, on a system with 320MB L3 cache the existing
hardcoded default of 250MB is insufficient.

Use the measured cache size to determine a buffer size that can be
expected to trigger memory access while keeping the existing default
as minimum, now renamed to MINIMUM_SPAN, that has been appropriate for
testing so far.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Reinette Chatre and committed by
Shuah Khan
f77b9672 3cb3f0b8

+28 -4
+13
tools/testing/selftests/resctrl/fill_buf.c
··· 129 129 130 130 return buf; 131 131 } 132 + 133 + ssize_t get_fill_buf_size(int cpu_no, const char *cache_type) 134 + { 135 + unsigned long cache_total_size = 0; 136 + int ret; 137 + 138 + ret = get_cache_size(cpu_no, cache_type, &cache_total_size); 139 + if (ret) 140 + return ret; 141 + 142 + return cache_total_size * 2 > MINIMUM_SPAN ? 143 + cache_total_size * 2 : MINIMUM_SPAN; 144 + }
+6 -1
tools/testing/selftests/resctrl/mba_test.c
··· 182 182 fill_buf.memflush = uparams->fill_buf->memflush; 183 183 param.fill_buf = &fill_buf; 184 184 } else if (!uparams->benchmark_cmd[0]) { 185 - fill_buf.buf_size = DEFAULT_SPAN; 185 + ssize_t buf_size; 186 + 187 + buf_size = get_fill_buf_size(uparams->cpu, "L3"); 188 + if (buf_size < 0) 189 + return buf_size; 190 + fill_buf.buf_size = buf_size; 186 191 fill_buf.memflush = true; 187 192 param.fill_buf = &fill_buf; 188 193 }
+6 -1
tools/testing/selftests/resctrl/mbm_test.c
··· 149 149 fill_buf.memflush = uparams->fill_buf->memflush; 150 150 param.fill_buf = &fill_buf; 151 151 } else if (!uparams->benchmark_cmd[0]) { 152 - fill_buf.buf_size = DEFAULT_SPAN; 152 + ssize_t buf_size; 153 + 154 + buf_size = get_fill_buf_size(uparams->cpu, "L3"); 155 + if (buf_size < 0) 156 + return buf_size; 157 + fill_buf.buf_size = buf_size; 153 158 fill_buf.memflush = true; 154 159 param.fill_buf = &fill_buf; 155 160 }
+2 -1
tools/testing/selftests/resctrl/resctrl.h
··· 41 41 42 42 #define BENCHMARK_ARGS 64 43 43 44 - #define DEFAULT_SPAN (250 * MB) 44 + #define MINIMUM_SPAN (250 * MB) 45 45 46 46 /* 47 47 * fill_buf_param: "fill_buf" benchmark parameters ··· 169 169 unsigned char *alloc_buffer(size_t buf_size, bool memflush); 170 170 void mem_flush(unsigned char *buf, size_t buf_size); 171 171 void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); 172 + ssize_t get_fill_buf_size(int cpu_no, const char *cache_type); 172 173 int initialize_read_mem_bw_imc(void); 173 174 int measure_read_mem_bw(const struct user_params *uparams, 174 175 struct resctrl_val_param *param, pid_t bm_pid);
+1 -1
tools/testing/selftests/resctrl/resctrl_tests.c
··· 189 189 ksft_exit_skip("Unable to parse benchmark buffer size.\n"); 190 190 } 191 191 } else { 192 - fill_param->buf_size = DEFAULT_SPAN; 192 + fill_param->buf_size = MINIMUM_SPAN; 193 193 } 194 194 195 195 if (uparams->benchmark_cmd[2] && *uparams->benchmark_cmd[2] != '\0') {