Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	linux-kselftest@vger.kernel.org, "Shuah Khan" <shuah@kernel.org>,
	"Babu Moger" <babu.moger@amd.com>,
	"Maciej Wieczór-Retman" <maciej.wieczor-retman@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 01/16] selftests/resctrl: Open get_mem_bw_imc() fd for loops
Date: Wed, 24 Apr 2024 21:37:02 -0700	[thread overview]
Message-ID: <a35a663a-090c-45f8-84cc-1f575ef107c5@intel.com> (raw)
In-Reply-To: <20240408163247.3224-2-ilpo.jarvinen@linux.intel.com>

Hi Ilpo,

On 4/8/2024 9:32 AM, Ilpo Järvinen wrote:
> get_mem_bw_imc() handles fds in a for loop but close() is based on two
> fixed indexes READ and WRITE.
> 
> Open code all for loops to READ+WRITE entries for clarity.
> 
> Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
> 
> v3:
> - Rework entirely, use open coding instead of for loops for clarity
> ---
>  tools/testing/selftests/resctrl/resctrl_val.c | 22 ++++++++++---------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
> index 445f306d4c2f..456cf0d0b8ca 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -306,26 +306,28 @@ static int initialize_mem_bw_imc(void)
>  static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
>  {
>  	float reads, writes, of_mul_read, of_mul_write;
> -	int imc, j, ret;
> +	int imc, ret;
>  
>  	/* Start all iMC counters to log values (both read and write) */
>  	reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1;
>  	for (imc = 0; imc < imcs; imc++) {
> -		for (j = 0; j < 2; j++) {
> -			ret = open_perf_event(imc, cpu_no, j);
> -			if (ret)
> -				return -1;
> -		}
> -		for (j = 0; j < 2; j++)
> -			membw_ioctl_perf_event_ioc_reset_enable(imc, j);
> +		ret = open_perf_event(imc, cpu_no, READ);
> +		if (ret)
> +			return -1;
> +		ret = open_perf_event(imc, cpu_no, WRITE);
> +		if (ret)
> +			return -1;
> +
> +		membw_ioctl_perf_event_ioc_reset_enable(imc, READ);
> +		membw_ioctl_perf_event_ioc_reset_enable(imc, WRITE);
>  	}

The above highlights how the error checking is broken here and
leaving this code like this until the later fix arrives is confusing (to me).
Could you please squash "selftests/resctrl: Fix closing IMC fds on error" into this
patch?

Even so, I do not think that this addresses all the issues with error handling
surrounding these fds.
If I understand correctly these fds are currently (and remains to be after this
series) closed within get_mem_bw_imc(). In this series there seems to be
many occasions where open_perf_event() succeeds but later failures encountered
before get_mem_bw_imc() results in these fds not being cleaned up. What do you think of
having a perf_close_imc_mem_bw() to match with perf_open_imc_mem_bw() that
closes the fds and can be called from within get_mem_bw_imc() as well as
earlier if a failure is encountered between perf_open_imc_mem_bw()
and get_mem_bw_imc()?

Reinette

  reply	other threads:[~2024-04-25  4:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 16:32 [PATCH v3 00/16] selftests/resctrl: resctrl_val() related cleanups & improvements Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 01/16] selftests/resctrl: Open get_mem_bw_imc() fd for loops Ilpo Järvinen
2024-04-25  4:37   ` Reinette Chatre [this message]
2024-04-08 16:32 ` [PATCH v3 02/16] selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1) only Ilpo Järvinen
2024-04-25  4:38   ` Reinette Chatre
2024-04-08 16:32 ` [PATCH v3 03/16] selftests/resctrl: Fix closing IMC fds on error Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 04/16] selftests/resctrl: Make "bandwidth" consistent in comments & prints Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 05/16] selftests/resctrl: Consolidate get_domain_id() into resctrl_val() Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 06/16] selftests/resctrl: Use correct type for pids Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 07/16] selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope Ilpo Järvinen
2024-04-25  4:37   ` Reinette Chatre
2024-04-08 16:32 ` [PATCH v3 08/16] selftests/resctrl: Rename measure_vals() to measure_mem_bw_vals() & document Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 09/16] selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM tests Ilpo Järvinen
2024-04-25  4:38   ` Reinette Chatre
2024-04-08 16:32 ` [PATCH v3 10/16] selftests/resctrl: Add ->measure() callback to resctrl_val_param Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 11/16] selftests/resctrl: Add ->init() callback into resctrl_val_param Ilpo Järvinen
2024-04-25  4:39   ` Reinette Chatre
2024-04-08 16:32 ` [PATCH v3 12/16] selftests/resctrl: Simplify bandwidth report type handling Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 13/16] selftests/resctrl: Make some strings passed to resctrlfs functions const Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 14/16] selftests/resctrl: Convert ctrlgrp & mongrp to pointers Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 15/16] selftests/resctrl: Remove mongrp from MBA test Ilpo Järvinen
2024-04-08 16:32 ` [PATCH v3 16/16] selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl() Ilpo Järvinen
2024-04-24 13:49 ` [PATCH v3 00/16] selftests/resctrl: resctrl_val() related cleanups & improvements Shuah Khan
2024-04-25  4:46   ` 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=a35a663a-090c-45f8-84cc-1f575ef107c5@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=babu.moger@amd.com \
    --cc=fenghua.yu@intel.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=shuah@kernel.org \
    /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