From: Reinette Chatre <reinette.chatre@intel.com>
To: Yifan Wu <wuyifan50@huawei.com>, <tony.luck@intel.com>,
<Dave.Martin@arm.com>, <james.morse@arm.com>,
<babu.moger@amd.com>, <shuah@kernel.org>,
<tan.shaopeng@fujitsu.com>, <fenghuay@nvidia.com>,
<ben.horgan@arm.com>, <zengheng4@huawei.com>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kselftest@vger.kernel.org>, <linuxarm@huawei.com>
Cc: <xiaqinxin@huawei.com>, <prime.zeng@hisilicon.com>,
<wangyushan12@huawei.com>, <xuwei5@huawei.com>,
<fanghao11@huawei.com>, <wangzhou1@hisilicon.com>
Subject: Re: [PATCH v3 3/3] selftests/resctrl: Enable dynamic management of IMC counters via linked list
Date: Thu, 25 Jun 2026 15:14:53 -0700 [thread overview]
Message-ID: <8b51dca5-d1fe-492d-8d54-7709aee4a6c5@intel.com> (raw)
In-Reply-To: <20260522090540.444554-4-wuyifan50@huawei.com>
Hi Yifan,
On 5/22/26 2:05 AM, Yifan Wu wrote:
> @@ -242,14 +233,13 @@ static int read_from_imc_dir(char *imc_dir, unsigned int *count)
> * counter's event and umask for the memory read events that will be
> * measured.
> *
> - * Enumerate all these details into an array of structures.
> + * Enumerate all these details into a linked list of structures.
> *
> * Return: >= 0 on success. < 0 on failure.
> */
> -static int num_of_imcs(void)
> +static int enumerate_imcs(void)
The first sentence of this function's comments still describes the behavior being
changed in this patch. How about a fixup like below:
diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
index 129e8d76222a..fe3b3517ae49 100644
--- a/tools/testing/selftests/resctrl/resctrl_val.c
+++ b/tools/testing/selftests/resctrl/resctrl_val.c
@@ -226,12 +226,10 @@ static int read_from_imc_dir(char *imc_dir)
}
/*
- * A system can have 'n' number of iMC (Integrated Memory Controller)
- * counters, get that 'n'. Discover the properties of the available
- * counters in support of needed performance measurement via perf.
- * For each iMC counter get it's type and config. Also obtain each
- * counter's event and umask for the memory read events that will be
- * measured.
+ * Discover the properties of the available iMC (Integrated Memory Controller)
+ * counters in support of needed performance measurement via perf. For each iMC
+ * counter get it's type and config. Also obtain each counter's event and umask
+ * for the memory read events that will be measured.
*
* Enumerate all these details into a linked list of structures.
*
...
> int initialize_read_mem_bw_imc(void)
> {
> - int imc;
> + struct imc_counter_config *imc_counter;
> + int ret;
>
> - imcs = num_of_imcs();
> - if (imcs <= 0)
> - return imcs;
> + ret = enumerate_imcs();
> + if (ret < 0)
> + return ret;
>
> /* Initialize perf_event_attr structures for all iMC's */
> - for (imc = 0; imc < imcs; imc++)
> - read_mem_bw_initialize_perf_event_attr(&imc_counters_config[imc]);
> + list_for_each_entry(imc_counter, &imc_counters_list, entry) {
> + read_mem_bw_initialize_perf_event_attr(imc_counter);
> + }
nit: unnecessary braces
>
> return 0;
> }
> @@ -328,11 +320,11 @@ void cleanup_read_mem_bw_imc(void)
>
> static void perf_close_imc_read_mem_bw(void)
> {
> - int mc;
> + struct imc_counter_config *imc_counter;
>
> - for (mc = 0; mc < imcs; mc++) {
> - if (imc_counters_config[mc].fd != -1)
> - close(imc_counters_config[mc].fd);
> + list_for_each_entry(imc_counter, &imc_counters_list, entry) {
> + if (imc_counter->fd != -1)
> + close(imc_counter->fd);
> }
> }
>
With fixup applied and nit addressed:
| Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reinette
next prev parent reply other threads:[~2026-06-25 22:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 9:05 [PATCH v3 0/3] selftests/resctrl: Add dynamic linked list management for IMC counters Yifan Wu
2026-05-22 9:05 ` [PATCH v3 1/3] selftests/resctrl: Introduce " Yifan Wu
2026-06-25 22:14 ` Reinette Chatre
2026-05-22 9:05 ` [PATCH v3 2/3] selftests/resctrl: Replace counter index references with pointers Yifan Wu
2026-06-25 22:14 ` Reinette Chatre
2026-06-26 9:41 ` wuyifan
2026-05-22 9:05 ` [PATCH v3 3/3] selftests/resctrl: Enable dynamic management of IMC counters via linked list Yifan Wu
2026-06-25 22:14 ` Reinette Chatre [this message]
2026-06-26 9:43 ` wuyifan
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=8b51dca5-d1fe-492d-8d54-7709aee4a6c5@intel.com \
--to=reinette.chatre@intel.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=fanghao11@huawei.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=prime.zeng@hisilicon.com \
--cc=shuah@kernel.org \
--cc=tan.shaopeng@fujitsu.com \
--cc=tony.luck@intel.com \
--cc=wangyushan12@huawei.com \
--cc=wangzhou1@hisilicon.com \
--cc=wuyifan50@huawei.com \
--cc=xiaqinxin@huawei.com \
--cc=xuwei5@huawei.com \
--cc=zengheng4@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox