From: Yifan Wu <wuyifan50@huawei.com>
To: <tony.luck@intel.com>, <reinette.chatre@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>, <jonathan.cameron@huawei.com>,
<zengheng4@huawei.com>, <wuyifan50@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: [PATCH v2 3/6] selftests/resctrl: Refactor the initialization of IMC's perf_event_attr using linked list
Date: Fri, 10 Apr 2026 17:33:49 +0800 [thread overview]
Message-ID: <20260410093352.3988125-4-wuyifan50@huawei.com> (raw)
In-Reply-To: <20260410093352.3988125-1-wuyifan50@huawei.com>
The initialization of perf_event_attr in iMC is refactord using
linked list. Removed the initialization of the global variable imcs.
Signed-off-by: Yifan Wu <wuyifan50@huawei.com>
---
tools/testing/selftests/resctrl/resctrl_val.c | 38 +++++++++----------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
index 60cda2214c13..ce675d349a6e 100644
--- a/tools/testing/selftests/resctrl/resctrl_val.c
+++ b/tools/testing/selftests/resctrl/resctrl_val.c
@@ -42,20 +42,18 @@ static struct imc_counter_config imc_counters_config[MAX_IMCS];
LIST_HEAD(imc_counters_list);
static const struct resctrl_test *current_test;
-static void read_mem_bw_initialize_perf_event_attr(int i)
+static void read_mem_bw_initialize_perf_event_attr(struct imc_counter_config *imc_counter)
{
- memset(&imc_counters_config[i].pe, 0,
- sizeof(struct perf_event_attr));
- imc_counters_config[i].pe.type = imc_counters_config[i].type;
- imc_counters_config[i].pe.size = sizeof(struct perf_event_attr);
- imc_counters_config[i].pe.disabled = 1;
- imc_counters_config[i].pe.inherit = 1;
- imc_counters_config[i].pe.exclude_guest = 0;
- imc_counters_config[i].pe.config =
- imc_counters_config[i].umask << 8 |
- imc_counters_config[i].event;
- imc_counters_config[i].pe.sample_type = PERF_SAMPLE_IDENTIFIER;
- imc_counters_config[i].pe.read_format =
+ imc_counter->pe.type = imc_counter->type;
+ imc_counter->pe.size = sizeof(struct perf_event_attr);
+ imc_counter->pe.disabled = 1;
+ imc_counter->pe.inherit = 1;
+ imc_counter->pe.exclude_guest = 0;
+ imc_counter->pe.config =
+ imc_counter->umask << 8 |
+ imc_counter->event;
+ imc_counter->pe.sample_type = PERF_SAMPLE_IDENTIFIER;
+ imc_counter->pe.read_format =
PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING;
}
@@ -292,15 +290,17 @@ static int num_of_imcs(void)
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 = num_of_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);
+ list_for_each_entry(imc_counter, &imc_counters_list, entry) {
+ read_mem_bw_initialize_perf_event_attr(imc_counter);
+ }
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-04-10 9:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 9:33 [PATCH v2 0/6] selftests/resctrl: Add dynamic linked list management for IMC counters Yifan Wu
2026-04-10 9:33 ` [PATCH v2 1/6] selftests/resctrl: Introduced " Yifan Wu
2026-04-22 16:02 ` Reinette Chatre
2026-05-06 7:17 ` wuyifan
2026-05-07 16:13 ` Reinette Chatre
2026-05-08 10:14 ` wuyifan
2026-04-10 9:33 ` [PATCH v2 2/6] selftests/resctrl: Refactor the discovery of IMC counters using linked list Yifan Wu
2026-04-22 16:04 ` Reinette Chatre
2026-04-10 9:33 ` Yifan Wu [this message]
2026-04-22 16:05 ` [PATCH v2 3/6] selftests/resctrl: Refactor the initialization of IMC's perf_event_attr " Reinette Chatre
2026-04-10 9:33 ` [PATCH v2 4/6] selftests/resctrl: Refactor perf event open/close " Yifan Wu
2026-04-22 16:05 ` Reinette Chatre
2026-04-10 9:33 ` [PATCH v2 5/6] selftests/resctrl: Refactor reading from IMC " Yifan Wu
2026-04-10 9:33 ` [PATCH v2 6/6] selftests/resctrl: Remove the definition of the IMC counter config array and imcs Yifan Wu
2026-04-22 16:05 ` 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=20260410093352.3988125-4-wuyifan50@huawei.com \
--to=wuyifan50@huawei.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=jonathan.cameron@huawei.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=reinette.chatre@intel.com \
--cc=shuah@kernel.org \
--cc=tan.shaopeng@fujitsu.com \
--cc=tony.luck@intel.com \
--cc=wangyushan12@huawei.com \
--cc=wangzhou1@hisilicon.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