summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/resctrl/cache.c
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2023-12-15 17:05:04 +0200
committerShuah Khan <skhan@linuxfoundation.org>2024-02-13 13:56:44 -0700
commit433f437b3ae2ed4e318ecd5233c82f6936e78e82 (patch)
treecd5883e1b09379ae34ae8180f39a2bfe8dc29d84 /tools/testing/selftests/resctrl/cache.c
parent3cdad0a5a6cf581519748612cb449b43379510a4 (diff)
selftests/resctrl: Move cat_val() to cat_test.c and rename to cat_test()
The main CAT test function is called cat_val() and resides in cache.c which is illogical. Rename the function to cat_test() and move it into cat_test.c. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/resctrl/cache.c')
-rw-r--r--tools/testing/selftests/resctrl/cache.c90
1 files changed, 5 insertions, 85 deletions
diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c
index 335415eaa406..319d0cdd7225 100644
--- a/tools/testing/selftests/resctrl/cache.c
+++ b/tools/testing/selftests/resctrl/cache.c
@@ -3,16 +3,9 @@
#include <stdint.h>
#include "resctrl.h"
-struct perf_event_read {
- __u64 nr; /* The number of events */
- struct {
- __u64 value; /* The value of the event */
- } values[2];
-};
-
char llc_occup_path[1024];
-static void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config)
+void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config)
{
memset(pea, 0, sizeof(*pea));
pea->type = PERF_TYPE_HARDWARE;
@@ -35,13 +28,13 @@ static void perf_event_reset_enable(int pe_fd)
ioctl(pe_fd, PERF_EVENT_IOC_ENABLE, 0);
}
-static void perf_event_initialize_read_format(struct perf_event_read *pe_read)
+void perf_event_initialize_read_format(struct perf_event_read *pe_read)
{
memset(pe_read, 0, sizeof(*pe_read));
pe_read->nr = 1;
}
-static int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no)
+int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no)
{
int pe_fd;
@@ -130,8 +123,8 @@ static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value
*
* Return: =0 on success. <0 on failure.
*/
-static int perf_event_measure(int pe_fd, struct perf_event_read *pe_read,
- const char *filename, int bm_pid)
+int perf_event_measure(int pe_fd, struct perf_event_read *pe_read,
+ const char *filename, int bm_pid)
{
int ret;
@@ -170,79 +163,6 @@ int measure_llc_resctrl(const char *filename, int bm_pid)
}
/*
- * cache_val: execute benchmark and measure LLC occupancy resctrl
- * and perf cache miss for the benchmark
- * @param: parameters passed to cache_val()
- * @span: buffer size for the benchmark
- *
- * Return: 0 when the test was run, < 0 on error.
- */
-int cat_val(struct resctrl_val_param *param, size_t span)
-{
- int memflush = 1, operation = 0, ret = 0;
- char *resctrl_val = param->resctrl_val;
- struct perf_event_read pe_read;
- struct perf_event_attr pea;
- pid_t bm_pid;
- int pe_fd;
-
- if (strcmp(param->filename, "") == 0)
- sprintf(param->filename, "stdio");
-
- bm_pid = getpid();
-
- /* Taskset benchmark to specified cpu */
- ret = taskset_benchmark(bm_pid, param->cpu_no);
- if (ret)
- return ret;
-
- /* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/
- ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp,
- resctrl_val);
- if (ret)
- return ret;
-
- perf_event_attr_initialize(&pea, PERF_COUNT_HW_CACHE_MISSES);
- perf_event_initialize_read_format(&pe_read);
-
- /* Test runs until the callback setup() tells the test to stop. */
- while (1) {
- ret = param->setup(param);
- if (ret == END_OF_TESTS) {
- ret = 0;
- break;
- }
- if (ret < 0)
- break;
-
- pe_fd = perf_open(&pea, bm_pid, param->cpu_no);
- if (pe_fd < 0) {
- ret = -1;
- break;
- }
-
- if (run_fill_buf(span, memflush, operation, true)) {
- fprintf(stderr, "Error-running fill buffer\n");
- ret = -1;
- goto pe_close;
- }
-
- sleep(1);
- ret = perf_event_measure(pe_fd, &pe_read, param->filename, bm_pid);
- if (ret)
- goto pe_close;
-
- close(pe_fd);
- }
-
- return ret;
-
-pe_close:
- close(pe_fd);
- return ret;
-}
-
-/*
* show_cache_info - Show generic cache test information
* @no_of_bits: Number of bits
* @avg_llc_val: Average of LLC cache result data