From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Reinette Chatre <reinette.chatre@intel.com>
Cc: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com,
tony.luck@intel.com, babu.moger@amd.com, fenghuay@nvidia.com,
peternewman@google.com, zide.chen@intel.com,
dapeng1.mi@linux.intel.com, ben.horgan@arm.com,
yu.c.chen@intel.com, jason.zeng@intel.com,
linux-kselftest@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
patches@lists.linux.dev
Subject: Re: [PATCH v3 09/10] selftests/resctrl: Simplify perf usage in CAT test
Date: Fri, 27 Mar 2026 19:47:58 +0200 (EET) [thread overview]
Message-ID: <2e88c88e-35ef-dc38-5717-f732064f9ab8@linux.intel.com> (raw)
In-Reply-To: <ff80aaca24d306435b72a1b53ef8fa01f2b5010f.1773432891.git.reinette.chatre@intel.com>
[-- Attachment #1: Type: text/plain, Size: 5745 bytes --]
On Fri, 13 Mar 2026, Reinette Chatre wrote:
> 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.
>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> Tested-by: Chen Yu <yu.c.chen@intel.com>
> ---
> Changes since v2:
> - Add Chen Yu's tag.
> ---
> tools/testing/selftests/resctrl/cache.c | 17 +++++------------
> tools/testing/selftests/resctrl/cat_test.c | 4 +---
> tools/testing/selftests/resctrl/resctrl.h | 11 +----------
> 3 files changed, 7 insertions(+), 25 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);
> }
>
> /*
> diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
> index 8bc47f06679a..6aac03147d41 100644
> --- a/tools/testing/selftests/resctrl/cat_test.c
> +++ b/tools/testing/selftests/resctrl/cat_test.c
> @@ -135,7 +135,6 @@ static int cat_test(const struct resctrl_test *test,
> struct resctrl_val_param *param,
> size_t span, unsigned long current_mask)
> {
> - struct perf_event_read pe_read;
> struct perf_event_attr pea;
> cpu_set_t old_affinity;
> unsigned char *buf;
> @@ -159,7 +158,6 @@ static int cat_test(const struct resctrl_test *test,
> goto reset_affinity;
>
> perf_event_attr_initialize(&pea, PERF_COUNT_HW_CACHE_MISSES);
> - perf_event_initialize_read_format(&pe_read);
> pe_fd = perf_open(&pea, bm_pid, uparams->cpu);
> if (pe_fd < 0) {
> ret = -1;
> @@ -192,7 +190,7 @@ static int cat_test(const struct resctrl_test *test,
>
> fill_cache_read(buf, span, true);
>
> - ret = perf_event_measure(pe_fd, &pe_read, param->filename, bm_pid);
> + ret = perf_event_measure(pe_fd, param->filename, bm_pid);
> if (ret)
> goto free_buf;
> }
> diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
> index 3bad2d80c09b..175101022bf3 100644
> --- a/tools/testing/selftests/resctrl/resctrl.h
> +++ b/tools/testing/selftests/resctrl/resctrl.h
> @@ -148,13 +148,6 @@ struct resctrl_val_param {
> struct fill_buf_param *fill_buf;
> };
>
> -struct perf_event_read {
> - __u64 nr; /* The number of events */
> - struct {
> - __u64 value; /* The value of the event */
> - } values[2];
> -};
> -
> /*
> * Memory location that consumes values compiler must not optimize away.
> * Volatile ensures writes to this location cannot be optimized away by
> @@ -210,11 +203,9 @@ unsigned int count_bits(unsigned long n);
> int snc_kernel_support(void);
>
> void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config);
> -void perf_event_initialize_read_format(struct perf_event_read *pe_read);
> int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no);
> int perf_event_reset_enable(int pe_fd);
> -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);
> int measure_llc_resctrl(const char *filename, pid_t bm_pid);
> int minimize_l2_occupancy(const struct resctrl_test *test,
> const struct user_params *uparams,
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
next prev parent reply other threads:[~2026-03-27 17:48 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 20:32 [PATCH v3 00/10] selftests/resctrl: Fixes and improvements focused on Intel platforms Reinette Chatre
2026-03-13 20:32 ` [PATCH v3 01/10] selftests/resctrl: Improve accuracy of cache occupancy test Reinette Chatre
2026-03-26 12:44 ` Ilpo Järvinen
2026-03-13 20:32 ` [PATCH v3 02/10] selftests/resctrl: Reduce interference from L2 occupancy during " Reinette Chatre
2026-03-26 12:56 ` Ilpo Järvinen
2026-03-13 20:32 ` [PATCH v3 03/10] selftests/resctrl: Do not store iMC counter value in counter config structure Reinette Chatre
2026-03-13 20:32 ` [PATCH v3 04/10] selftests/resctrl: Prepare for parsing multiple events per iMC Reinette Chatre
2026-03-26 13:03 ` Ilpo Järvinen
2026-03-26 14:34 ` Reinette Chatre
2026-03-13 20:32 ` [PATCH v3 05/10] selftests/resctrl: Support multiple events associated with iMC Reinette Chatre
2026-03-27 17:28 ` Ilpo Järvinen
2026-03-13 20:32 ` [PATCH v3 06/10] selftests/resctrl: Increase size of buffer used in MBM and MBA tests Reinette Chatre
2026-03-27 17:30 ` Ilpo Järvinen
2026-03-13 20:32 ` [PATCH v3 07/10] selftests/resctrl: Raise threshold at which MBM and PMU values are compared Reinette Chatre
2026-03-27 17:34 ` Ilpo Järvinen
2026-03-27 23:19 ` Reinette Chatre
2026-03-13 20:32 ` [PATCH v3 08/10] selftests/resctrl: Remove requirement on cache miss rate Reinette Chatre
2026-03-27 17:45 ` Ilpo Järvinen
2026-03-27 23:21 ` Reinette Chatre
2026-03-31 8:07 ` Ilpo Järvinen
2026-03-31 17:39 ` Reinette Chatre
2026-03-13 20:32 ` [PATCH v3 09/10] selftests/resctrl: Simplify perf usage in CAT test Reinette Chatre
2026-03-27 17:47 ` Ilpo Järvinen [this message]
2026-03-13 20:32 ` [PATCH v3 10/10] selftests/resctrl: Reduce L2 impact on " Reinette Chatre
2026-03-27 17:49 ` Ilpo Järvinen
2026-03-27 23:22 ` Reinette Chatre
2026-03-31 19:13 ` [PATCH v3 00/10] selftests/resctrl: Fixes and improvements focused on Intel platforms Shuah Khan
2026-03-31 20:22 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2e88c88e-35ef-dc38-5717-f732064f9ab8@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=jason.zeng@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=peternewman@google.com \
--cc=reinette.chatre@intel.com \
--cc=shuah@kernel.org \
--cc=tony.luck@intel.com \
--cc=yu.c.chen@intel.com \
--cc=zide.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.