aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/resctrl
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2023-12-15 17:05:01 +0200
committerShuah Khan <skhan@linuxfoundation.org>2024-02-13 13:56:44 -0700
commitb6e6a582f2b357b6f74849b715de12cc38b1ee91 (patch)
treebcb4228a57a1be135a533b02ed17b3247e5ec9cb /tools/testing/selftests/resctrl
parentselftests/resctrl: Remove nested calls in perf event handling (diff)
downloadwireguard-linux-b6e6a582f2b357b6f74849b715de12cc38b1ee91.tar.xz
wireguard-linux-b6e6a582f2b357b6f74849b715de12cc38b1ee91.zip
selftests/resctrl: Consolidate naming of perf event related things
Naming for perf event related functions, types, and variables is inconsistent. Make struct read_format and all functions related to perf events start with "perf_". Adjust variable names towards the same direction but use shorter names for variables where appropriate (pe prefix). 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')
-rw-r--r--tools/testing/selftests/resctrl/cache.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c
index 4f846a2e5e26..7f45c4957f81 100644
--- a/tools/testing/selftests/resctrl/cache.c
+++ b/tools/testing/selftests/resctrl/cache.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include "resctrl.h"
-struct read_format {
+struct perf_event_read {
__u64 nr; /* The number of events */
struct {
__u64 value; /* The value of the event */
@@ -11,11 +11,11 @@ struct read_format {
};
static struct perf_event_attr pea_llc_miss;
-static struct read_format rf_cqm;
-static int fd_lm;
+static struct perf_event_read pe_read;
+static int pe_fd;
char llc_occup_path[1024];
-static void initialize_perf_event_attr(void)
+static void perf_event_attr_initialize(void)
{
pea_llc_miss.type = PERF_TYPE_HARDWARE;
pea_llc_miss.size = sizeof(struct perf_event_attr);
@@ -30,34 +30,34 @@ static void initialize_perf_event_attr(void)
}
/* Start counters to log values */
-static void ioctl_perf_event_ioc_reset_enable(void)
+static void perf_event_reset_enable(void)
{
- ioctl(fd_lm, PERF_EVENT_IOC_RESET, 0);
- ioctl(fd_lm, PERF_EVENT_IOC_ENABLE, 0);
+ ioctl(pe_fd, PERF_EVENT_IOC_RESET, 0);
+ ioctl(pe_fd, PERF_EVENT_IOC_ENABLE, 0);
}
-static void initialize_llc_perf(void)
+static void perf_event_initialize(void)
{
memset(&pea_llc_miss, 0, sizeof(struct perf_event_attr));
- memset(&rf_cqm, 0, sizeof(struct read_format));
+ memset(&pe_read, 0, sizeof(struct perf_event_read));
/* Initialize perf_event_attr structures for HW_CACHE_MISSES */
- initialize_perf_event_attr();
+ perf_event_attr_initialize();
pea_llc_miss.config = PERF_COUNT_HW_CACHE_MISSES;
- rf_cqm.nr = 1;
+ pe_read.nr = 1;
}
-static int reset_enable_llc_perf(pid_t pid, int cpu_no)
+static int perf_open(pid_t pid, int cpu_no)
{
- fd_lm = perf_event_open(&pea_llc_miss, pid, cpu_no, -1, PERF_FLAG_FD_CLOEXEC);
- if (fd_lm == -1) {
+ pe_fd = perf_event_open(&pea_llc_miss, pid, cpu_no, -1, PERF_FLAG_FD_CLOEXEC);
+ if (pe_fd == -1) {
ksft_perror("Error opening leader");
return -1;
}
- ioctl_perf_event_ioc_reset_enable();
+ perf_event_reset_enable();
return 0;
}
@@ -141,15 +141,15 @@ static int perf_event_measure(const char *filename, int bm_pid)
int ret;
/* Stop counters after one span to get miss rate */
- ioctl(fd_lm, PERF_EVENT_IOC_DISABLE, 0);
+ ioctl(pe_fd, PERF_EVENT_IOC_DISABLE, 0);
- ret = read(fd_lm, &rf_cqm, sizeof(struct read_format));
+ ret = read(pe_fd, &pe_read, sizeof(struct perf_event_read));
if (ret == -1) {
ksft_perror("Could not get perf value");
return -1;
}
- return print_results_cache(filename, bm_pid, rf_cqm.values[0].value);
+ return print_results_cache(filename, bm_pid, pe_read.values[0].value);
}
/*
@@ -204,7 +204,7 @@ int cat_val(struct resctrl_val_param *param, size_t span)
if (ret)
return ret;
- initialize_llc_perf();
+ perf_event_initialize();
/* Test runs until the callback setup() tells the test to stop. */
while (1) {
@@ -215,7 +215,7 @@ int cat_val(struct resctrl_val_param *param, size_t span)
}
if (ret < 0)
break;
- ret = reset_enable_llc_perf(bm_pid, param->cpu_no);
+ ret = perf_open(bm_pid, param->cpu_no);
if (ret)
break;
@@ -234,7 +234,7 @@ int cat_val(struct resctrl_val_param *param, size_t span)
return ret;
pe_close:
- close(fd_lm);
+ close(pe_fd);
return ret;
}