diff options
| author | Reinette Chatre <reinette.chatre@intel.com> | 2026-04-03 18:56:08 -0700 |
|---|---|---|
| committer | Shuah Khan <skhan@linuxfoundation.org> | 2026-05-04 18:40:02 -0600 |
| commit | da707d9fedabf71d1973543f0cf244d2ef597c0d (patch) | |
| tree | 0fe1117d7093800d2fdbfc447cea20f4add1851e /tools/testing/selftests/resctrl/cache.c | |
| parent | ca2e4f4ba15a00218bff3b89ff57b20d0164de0a (diff) | |
| download | linux-da707d9fedabf71d1973543f0cf244d2ef597c0d.tar.gz linux-da707d9fedabf71d1973543f0cf244d2ef597c0d.zip | |
selftests/resctrl: Simplify perf usage in CAT test
The CAT test relies on the PERF_COUNT_HW_CACHE_MISSES event to determine if
modifying a cache portion size is successful. This event is configured to
report the data as part of an event group, but no other events are added to
the group.
Remove the unnecessary PERF_FORMAT_GROUP format setting. This eliminates
the need for struct perf_event_read and results in read() of the associated
file descriptor to return just one value associated with the
PERF_COUNT_HW_CACHE_MISSES event of interest.
Link: https://lore.kernel.org/r/fb69325eba5031b735fa79effaaacd797c9c6040.1775266384.git.reinette.chatre@intel.com
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Chen Yu <yu.c.chen@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.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.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index bef71b6feacc..df9bea584a2d 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -10,7 +10,6 @@ void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config) memset(pea, 0, sizeof(*pea)); pea->type = PERF_TYPE_HARDWARE; pea->size = sizeof(*pea); - pea->read_format = PERF_FORMAT_GROUP; pea->exclude_kernel = 1; pea->exclude_hv = 1; pea->exclude_idle = 1; @@ -37,19 +36,13 @@ int perf_event_reset_enable(int pe_fd) return 0; } -void perf_event_initialize_read_format(struct perf_event_read *pe_read) -{ - memset(pe_read, 0, sizeof(*pe_read)); - pe_read->nr = 1; -} - int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no) { int pe_fd; pe_fd = perf_event_open(pea, pid, cpu_no, -1, PERF_FLAG_FD_CLOEXEC); if (pe_fd == -1) { - ksft_perror("Error opening leader"); + ksft_perror("Unable to set up performance monitoring"); return -1; } @@ -132,9 +125,9 @@ static int print_results_cache(const char *filename, pid_t bm_pid, __u64 llc_val * * Return: =0 on success. <0 on failure. */ -int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, pid_t bm_pid) +int perf_event_measure(int pe_fd, const char *filename, pid_t bm_pid) { + __u64 value; int ret; /* Stop counters after one span to get miss rate */ @@ -142,13 +135,13 @@ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, if (ret < 0) return ret; - ret = read(pe_fd, pe_read, sizeof(*pe_read)); + ret = read(pe_fd, &value, sizeof(value)); if (ret == -1) { ksft_perror("Could not get perf value"); return -1; } - return print_results_cache(filename, bm_pid, pe_read->values[0].value); + return print_results_cache(filename, bm_pid, value); } /* |
