[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231120111340.7805-13-ilpo.jarvinen@linux.intel.com>
Date: Mon, 20 Nov 2023 13:13:26 +0200
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: linux-kselftest@...r.kernel.org,
Reinette Chatre <reinette.chatre@...el.com>,
Shuah Khan <shuah@...nel.org>,
Shaopeng Tan <tan.shaopeng@...fujitsu.com>,
Maciej Wieczór-Retman
<maciej.wieczor-retman@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>
Cc: linux-kernel@...r.kernel.org,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Subject: [PATCH v2 12/26] selftests/resctrl: Consolidate naming of perf event related things
Naming for perf event related functions, types, and variables is
currently 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@...ux.intel.com>
---
tools/testing/selftests/resctrl/cache.c | 42 ++++++++++++-------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c
index aea4f54d32bd..52d37d1c380f 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) {
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) {
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);
}
/*
@@ -205,7 +205,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) {
@@ -216,7 +216,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;
@@ -235,7 +235,7 @@ int cat_val(struct resctrl_val_param *param, size_t span)
return ret;
pe_close:
- close(fd_lm);
+ close(pe_fd);
return ret;
}
--
2.30.2
Powered by blists - more mailing lists