From: Reinette Chatre <reinette.chatre@intel.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: fenghua.yu@intel.com, shuah@kernel.org, tony.luck@intel.com,
peternewman@google.com, babu.moger@amd.com,
"Maciej Wieczór-Retman" <maciej.wieczor-retman@intel.com>,
linux-kselftest@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V3 02/15] selftests/resctrl: Print accurate buffer size as part of MBM results
Date: Fri, 18 Oct 2024 10:34:13 -0700 [thread overview]
Message-ID: <42afcd9f-48a3-4d31-a39b-df8c42f2e5ff@intel.com> (raw)
In-Reply-To: <68a7ff59-289c-1d50-d454-ab2fcf6baf22@linux.intel.com>
Hi Ilpo,
On 10/18/24 1:46 AM, Ilpo Järvinen wrote:
> On Thu, 17 Oct 2024, Reinette Chatre wrote:
>> @@ -138,15 +139,26 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
>> .setup = mbm_setup,
>> .measure = mbm_measure,
>> };
>> + char *endptr = NULL;
>> + size_t span = 0;
>> int ret;
>>
>> remove(RESULT_FILE_NAME);
>>
>> + if (uparams->benchmark_cmd[0] && strcmp(uparams->benchmark_cmd[0], "fill_buf") == 0) {
>> + if (uparams->benchmark_cmd[1]) {
>> + errno = 0;
>> + span = strtoul(uparams->benchmark_cmd[1], &endptr, 10);
>> + if (errno || *endptr != '\0')
>
> This no longer catches "" string as error. I tested strtoul() with an
> empty string and errno remains at 0.
>
>> + return -errno;
>
> Another issue is that in cases where errno=0 (both *endptr != '\0' and
> endptr == uparams->benchmark_cmd[1]), this function doesn't return
> a proper error code but -0.
>
Thank you for catching this. I addressed it with the fixup below:
@@ -146,11 +146,11 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
remove(RESULT_FILE_NAME);
if (uparams->benchmark_cmd[0] && strcmp(uparams->benchmark_cmd[0], "fill_buf") == 0) {
- if (uparams->benchmark_cmd[1]) {
+ if (uparams->benchmark_cmd[1] && *uparams->benchmark_cmd[1] != '\0') {
errno = 0;
span = strtoul(uparams->benchmark_cmd[1], &endptr, 10);
if (errno || *endptr != '\0')
- return -errno;
+ return -EINVAL;
}
}
The above does not address all that can go wrong when user, for example, runs:
resctrl_tests -t mbm fill_buf ""
The above snippet will ignore the invalid value and focus on the issue addressed in
this patch, which is to not print DEFAULT_SPAN when that is not the size used.
At this point of the series run_benchmark() still uses strtoul() to parse the
empty string. This is fixed in the later patch "selftests/resctrl: Make benchmark
parameter passing robust" that will also be fixed to handle the empty string.
Reinette
next prev parent reply other threads:[~2024-10-18 17:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 2:33 [PATCH V3 00/15] selftests/resctrl: Support diverse platforms with MBM and MBA tests Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 01/15] selftests/resctrl: Make functions only used in same file static Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 02/15] selftests/resctrl: Print accurate buffer size as part of MBM results Reinette Chatre
2024-10-18 8:46 ` Ilpo Järvinen
2024-10-18 17:34 ` Reinette Chatre [this message]
2024-10-18 2:33 ` [PATCH V3 03/15] selftests/resctrl: Fix memory overflow due to unhandled wraparound Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 04/15] selftests/resctrl: Protect against array overrun during iMC config parsing Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 05/15] selftests/resctrl: Protect against array overflow when reading strings Reinette Chatre
2024-10-18 8:53 ` Ilpo Järvinen
2024-10-18 2:33 ` [PATCH V3 06/15] selftests/resctrl: Make wraparound handling obvious Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 07/15] selftests/resctrl: Remove "once" parameter required to be false Reinette Chatre
2024-10-18 8:54 ` Ilpo Järvinen
2024-10-18 2:33 ` [PATCH V3 08/15] selftests/resctrl: Only support measured read operation Reinette Chatre
2024-10-18 8:55 ` Ilpo Järvinen
2024-10-18 2:33 ` [PATCH V3 09/15] selftests/resctrl: Remove unused measurement code Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 10/15] selftests/resctrl: Make benchmark parameter passing robust Reinette Chatre
2024-10-18 9:03 ` Ilpo Järvinen
2024-10-18 17:34 ` Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 11/15] selftests/resctrl: Ensure measurements skip initialization of default benchmark Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 12/15] selftests/resctrl: Use cache size to determine "fill_buf" buffer size Reinette Chatre
2024-10-18 9:06 ` Ilpo Järvinen
2024-10-18 2:33 ` [PATCH V3 13/15] selftests/resctrl: Do not compare performance counters and resctrl at low bandwidth Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 14/15] selftests/resctrl: Keep results from first test run Reinette Chatre
2024-10-18 2:33 ` [PATCH V3 15/15] selftests/resctrl: Replace magic constants used as array size Reinette Chatre
2024-10-18 9:08 ` Ilpo Järvinen
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=42afcd9f-48a3-4d31-a39b-df8c42f2e5ff@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=peternewman@google.com \
--cc=shuah@kernel.org \
--cc=tony.luck@intel.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