@@ -129,3 +129,16 @@ unsigned char *alloc_buffer(size_t buf_size, bool memflush)
return buf;
}
+
+ssize_t get_fill_buf_size(int cpu_no, const char *cache_type)
+{
+ unsigned long cache_total_size = 0;
+ int ret;
+
+ ret = get_cache_size(cpu_no, cache_type, &cache_total_size);
+ if (ret)
+ return ret;
+
+ return cache_total_size * 2 > MINIMUM_SPAN ?
+ cache_total_size * 2 : MINIMUM_SPAN;
+}
@@ -182,7 +182,12 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param
fill_buf.memflush = uparams->fill_buf->memflush;
param.fill_buf = &fill_buf;
} else if (!uparams->benchmark_cmd[0]) {
- fill_buf.buf_size = DEFAULT_SPAN;
+ ssize_t buf_size;
+
+ buf_size = get_fill_buf_size(uparams->cpu, "L3");
+ if (buf_size < 0)
+ return buf_size;
+ fill_buf.buf_size = buf_size;
fill_buf.memflush = true;
param.fill_buf = &fill_buf;
}
@@ -149,7 +149,12 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
fill_buf.memflush = uparams->fill_buf->memflush;
param.fill_buf = &fill_buf;
} else if (!uparams->benchmark_cmd[0]) {
- fill_buf.buf_size = DEFAULT_SPAN;
+ ssize_t buf_size;
+
+ buf_size = get_fill_buf_size(uparams->cpu, "L3");
+ if (buf_size < 0)
+ return buf_size;
+ fill_buf.buf_size = buf_size;
fill_buf.memflush = true;
param.fill_buf = &fill_buf;
}
@@ -41,7 +41,7 @@
#define BENCHMARK_ARGS 64
-#define DEFAULT_SPAN (250 * MB)
+#define MINIMUM_SPAN (250 * MB)
/*
* fill_buf_param: "fill_buf" benchmark parameters
@@ -169,6 +169,7 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
unsigned char *alloc_buffer(size_t buf_size, bool memflush);
void mem_flush(unsigned char *buf, size_t buf_size);
void fill_cache_read(unsigned char *buf, size_t buf_size, bool once);
+ssize_t get_fill_buf_size(int cpu_no, const char *cache_type);
int initialize_read_mem_bw_imc(void);
int measure_read_mem_bw(const struct user_params *uparams,
struct resctrl_val_param *param, pid_t bm_pid);
@@ -189,7 +189,7 @@ static struct fill_buf_param *alloc_fill_buf_param(struct user_params *uparams)
ksft_exit_skip("Unable to parse benchmark buffer size.\n");
}
} else {
- fill_param->buf_size = DEFAULT_SPAN;
+ fill_param->buf_size = MINIMUM_SPAN;
}
if (uparams->benchmark_cmd[2] && *uparams->benchmark_cmd[2] != '\0') {