From: Reinette Chatre <reinette.chatre@intel.com>
To: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
Fenghua Yu <fenghua.yu@intel.com>, Shuah Khan <shuah@kernel.org>
Cc: <ilpo.jarvinen@linux.intel.com>, <linux-kernel@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH v2 2/4] selftests/resctrl: Add helpers for the non-contiguous test
Date: Mon, 8 Jan 2024 14:36:36 -0800 [thread overview]
Message-ID: <ddc900a6-7337-4721-ab0f-917c32e917ff@intel.com> (raw)
In-Reply-To: <c7b66a4682829894ec72d8a1f78e324233ef0535.1702392177.git.maciej.wieczor-retman@intel.com>
Hi Maciej,
On 12/12/2023 6:52 AM, Maciej Wieczor-Retman wrote:
> The CAT non-contiguous selftests have to read the file responsible for
> reporting support of non-contiguous CBMs in Intel CAT. Then the test
"in Intel CAT" -> "in kernel (resctrl)"
> compares if that information matches what is reported by CPUID output.
>
> Add a generic helper function to read a chosen functionality support
> information.
Since this is a generic function that just reads a value from a file it
cannot be assumed that the value represents functionality support.
>
> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> ---
> Changelog v2:
> - Added this patch.
>
> tools/testing/selftests/resctrl/resctrl.h | 1 +
> tools/testing/selftests/resctrl/resctrlfs.c | 25 +++++++++++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
> index 739e16d08a7b..8f72d94b9cbe 100644
> --- a/tools/testing/selftests/resctrl/resctrl.h
> +++ b/tools/testing/selftests/resctrl/resctrl.h
> @@ -161,6 +161,7 @@ unsigned int count_contiguous_bits(unsigned long val, unsigned int *start);
> int get_full_cbm(const char *cache_type, unsigned long *mask);
> int get_mask_no_shareable(const char *cache_type, unsigned long *mask);
> int get_cache_size(int cpu_no, const char *cache_type, unsigned long *cache_size);
> +int read_info_res_file(const char *resource, const char *filename);
> void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
> int signal_handler_register(void);
> void signal_handler_unregister(void);
> diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
> index 0e97036a64b8..70333440ff2f 100644
> --- a/tools/testing/selftests/resctrl/resctrlfs.c
> +++ b/tools/testing/selftests/resctrl/resctrlfs.c
> @@ -249,6 +249,31 @@ static int get_bit_mask(const char *filename, unsigned long *mask)
> return 0;
> }
>
> +int read_info_res_file(const char *resource, const char *filename)
Considering that this is intended to be a new generic utility, could you
please add some function documentation?
> +{
> + char file_path[PATH_MAX];
> + FILE *fp;
> + int ret;
> +
> + snprintf(file_path, sizeof(file_path), "%s/%s/%s", INFO_PATH, resource,
> + filename);
> +
> + fp = fopen(file_path, "r");
> + if (!fp) {
> + perror("Error in opening sparse_masks file\n");
The error messages do not match the goal of this function to be generic.
Also, please note the recent cleanup done by Ilpo to replace the perror()
by ksft_perror().
> + return -1;
> + }
> +
> + if (fscanf(fp, "%u", &ret) <= 0) {
I find this to be potentially confusing. The function claims to be a generic
utility to read a value from a resctrl file ... but hidden within is that the
value is required to be unsigned, which is then cast into an int. This could be
made more specific and robust with something like below:
int resource_info_unsigned_get(const char *resource, const char *filename,
unsigned int *val)
The return value will be the result of the request. If resource_info_unsigned_get()
returns 0 then @val will contain the value read.
> + perror("Could not get sparse_masks contents\n");
> + fclose(fp);
> + return -1;
> + }
> +
> + fclose(fp);
> + return ret;
> +}
> +
> /*
> * create_bit_mask- Create bit mask from start, len pair
> * @start: LSB of the mask
Reinette
next prev parent reply other threads:[~2024-01-08 22:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 14:52 [PATCH v2 0/4] selftests/resctrl: Add non-contiguous CBMs in Intel CAT selftest Maciej Wieczor-Retman
2023-12-12 14:52 ` [PATCH v2 1/4] selftests/resctrl: Add test groups and name L3 CAT test L3_CAT Maciej Wieczor-Retman
2024-01-08 22:31 ` Reinette Chatre
2024-01-17 10:09 ` Maciej Wieczór-Retman
2023-12-12 14:52 ` [PATCH v2 2/4] selftests/resctrl: Add helpers for the non-contiguous test Maciej Wieczor-Retman
2024-01-08 22:36 ` Reinette Chatre [this message]
2024-01-17 9:59 ` Maciej Wieczór-Retman
2023-12-12 14:52 ` [PATCH v2 3/4] selftests/resctrl: Split validate_resctrl_feature_request() Maciej Wieczor-Retman
2024-01-08 22:38 ` Reinette Chatre
2024-01-17 9:49 ` Maciej Wieczór-Retman
2024-01-17 18:48 ` Reinette Chatre
2023-12-12 14:52 ` [PATCH v2 4/4] selftests/resctrl: Add non-contiguous CBMs CAT test Maciej Wieczor-Retman
2024-01-08 22:42 ` Reinette Chatre
2024-01-09 9:13 ` Ilpo Järvinen
2024-01-09 17:17 ` Reinette Chatre
2024-01-17 8:26 ` Maciej Wieczór-Retman
2024-01-17 18:49 ` Reinette Chatre
2024-01-18 12:02 ` Maciej Wieczór-Retman
2024-01-18 17:15 ` Reinette Chatre
2024-01-19 7:37 ` Maciej Wieczór-Retman
2024-01-19 16:39 ` Reinette Chatre
2024-01-22 7:56 ` Maciej Wieczór-Retman
2024-01-22 16:32 ` Reinette Chatre
2024-01-23 7:58 ` Maciej Wieczór-Retman
2024-01-23 17:42 ` Reinette Chatre
2024-01-25 7:12 ` Maciej Wieczór-Retman
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=ddc900a6-7337-4721-ab0f-917c32e917ff@intel.com \
--to=reinette.chatre@intel.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