All of lore.kernel.org
 help / color / mirror / Atom feed
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 2/3] selftests/resctrl: Replace counter index references with pointers
Date: Thu, 25 Jun 2026 15:14:31 -0700	[thread overview]
Message-ID: <77d30d2d-91db-456e-bf41-2cc31165bd2d@intel.com> (raw)
In-Reply-To: <20260522090540.444554-3-wuyifan50@huawei.com>

Hi Yifan,

Thank you. I just have a few style fixup comments ...

On 5/22/26 2:05 AM, Yifan Wu wrote:
> Replace direct counter number references with pointers to remove the
> dependency on fixed array indexing and enable the use of different
> data structures for counter management.
> 
> Signed-off-by: Yifan Wu <wuyifan50@huawei.com>
> ---
>  tools/testing/selftests/resctrl/resctrl_val.c | 62 +++++++++----------
>  1 file changed, 31 insertions(+), 31 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
> index a72dc4ae61fe..3d2b6919717a 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -42,40 +42,40 @@ 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,
> +	memset(&imc_counter->pe, 0,
>  	       sizeof(struct perf_event_attr));

nit: above can fit on a single line

> -	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;

nit: above can fit on a single line

> +	imc_counter->pe.sample_type = PERF_SAMPLE_IDENTIFIER;
> +	imc_counter->pe.read_format =
>  		PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING;
>  }
>  

...

> @@ -89,21 +89,21 @@ static void get_read_event_and_umask(char *cas_count_cfg, unsigned int count)
>  		if (!token[i])
>  			break;
>  		if (strcmp(token[i], "event") == 0)
> -			imc_counters_config[count].event = strtol(token[i + 1], NULL, 16);
> +			imc_counter->event = strtol(token[i + 1], NULL, 16);
>  		if (strcmp(token[i], "umask") == 0)
> -			imc_counters_config[count].umask = strtol(token[i + 1], NULL, 16);
> +			imc_counter->umask = strtol(token[i + 1], NULL, 16);
>  	}
>  }
>  
> -static int open_perf_read_event(int i, int cpu_no)
> +static int open_perf_read_event(int cpu_no, struct imc_counter_config *imc_counter)
>  {
> -	imc_counters_config[i].fd =
> -		perf_event_open(&imc_counters_config[i].pe, -1, cpu_no, -1,
> +	imc_counter->fd =
> +		perf_event_open(&imc_counter->pe, -1, cpu_no, -1,
>  				PERF_FLAG_FD_CLOEXEC);

Please improve readibility here by moving the above two lines up while ensuring alignment with
open parenthesis. Specifically:
	imc_counter->fd = perf_event_open(&imc_counter->pe, -1, cpu_no, -1,
					  PERF_FLAG_FD_CLOEXEC);
...

With the style fixups:
| Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>

Reinette

  reply	other threads:[~2026-06-25 22:14 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 [this message]
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
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=77d30d2d-91db-456e-bf41-2cc31165bd2d@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 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.