public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 V2 09/13] selftests/resctrl: Make benchmark parameter passing robust
Date: Fri, 4 Oct 2024 15:21:31 -0700	[thread overview]
Message-ID: <6ae8be57-be40-4b85-a171-ce535bb5b5a4@intel.com> (raw)
In-Reply-To: <9a70486a-5cb1-98ff-4ac6-498907886d2b@linux.intel.com>

Hi Ilpo,

On 10/4/24 7:05 AM, Ilpo Järvinen wrote:
> On Thu, 12 Sep 2024, Reinette Chatre wrote:

>>  tools/testing/selftests/resctrl/cmt_test.c    |  32 ++----
>>  tools/testing/selftests/resctrl/mba_test.c    |  13 ++-
>>  tools/testing/selftests/resctrl/mbm_test.c    |  22 ++--
>>  tools/testing/selftests/resctrl/resctrl.h     |  54 ++++++---
>>  .../testing/selftests/resctrl/resctrl_tests.c | 104 +++++++++++++-----
>>  tools/testing/selftests/resctrl/resctrl_val.c |  43 ++++----
>>  6 files changed, 176 insertions(+), 92 deletions(-)
>>
>> diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c
>> index 0c045080d808..a7effe76b419 100644
>> --- a/tools/testing/selftests/resctrl/cmt_test.c
>> +++ b/tools/testing/selftests/resctrl/cmt_test.c
>> @@ -116,15 +116,13 @@ static void cmt_test_cleanup(void)
>>  
>>  static int cmt_run_test(const struct resctrl_test *test, const struct user_params *uparams)
>>  {
>> -	const char * const *cmd = uparams->benchmark_cmd;
>> -	const char *new_cmd[BENCHMARK_ARGS];
>> +	struct fill_buf_param fill_buf = {0};
> 
> Empty initializer is enough to have the fields initialized to zero.

Sure.

...

>> diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
>> index 82801245e4c1..98462752cb46 100644
>> --- a/tools/testing/selftests/resctrl/resctrl.h
>> +++ b/tools/testing/selftests/resctrl/resctrl.h
>> @@ -43,16 +43,35 @@
>>  
>>  #define DEFAULT_SPAN		(250 * MB)
>>  
>> +/*
>> + * fill_buf_param:	"fill_buf" benchmark parameters
>> + * @buf_size:		Size (in bytes) of buffer used in benchmark.
>> + *			"fill_buf" allocates and initializes buffer of
>> + *			@buf_size. User can change value via command line.
>> + * @memflush:		If 0 then the buffer will not be flushed after
>> + *			allocation and initialization, otherwise the
>> + *			buffer will be flushed. User can change value via
>> + *			command line.
>> + */
>> +struct fill_buf_param {
>> +	size_t		buf_size;
>> +	int		memflush;
> 
> bool?
> 
> Or is there a plan to use other values than 0 and 1?

Sure. There is no need to keep the original user provided values. I am not aware of
any other planned values. 

>> +static struct fill_buf_param *alloc_fill_buf_param(struct user_params *uparams)
>> +{
>> +	struct fill_buf_param *fill_param = NULL;
>> +	char *endptr = NULL;
>> +
>> +	if (!uparams->benchmark_cmd[0] || strcmp(uparams->benchmark_cmd[0], "fill_buf"))
>> +		return NULL;
>> +
>> +	fill_param = malloc(sizeof(*fill_param));
>> +	if (!fill_param)
>> +		ksft_exit_skip("Unable to allocate memory for fill_buf parameters.\n");
>> +
>> +	if (uparams->benchmark_cmd[1]) {
>> +		errno = 0;
>> +		fill_param->buf_size = strtoul(uparams->benchmark_cmd[1], &endptr, 10);
>> +		if (errno || uparams->benchmark_cmd[1] == endptr) {
> 
> Should this also check that there is no extra garbage?

Good point. Instead of adding another check I plan to replace existing endptr check
with a different test that ensures that "*endptr == '\0'".


>>  static void run_benchmark(int signum, siginfo_t *info, void *ucontext)
>>  {
>> -	char **benchmark_cmd;
>> -	int ret, memflush;
>> -	size_t span;
>> +	struct benchmark_info *benchmark_info;
>> +	const struct user_params *uparams;
>> +	struct resctrl_val_param *param;
>>  	FILE *fp;
>> +	int ret;
>>  
>> -	benchmark_cmd = info->si_ptr;
>> +	benchmark_info = info->si_ptr;
> 
> I'd just assign this directly while defining the local variable.
> 

Sure.

Thank you.

Reinette

  reply	other threads:[~2024-10-04 22:21 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12 18:13 [PATCH V2 00/13] selftests/resctrl: Support diverse platforms with MBM and MBA tests Reinette Chatre
2024-09-12 18:13 ` [PATCH V2 01/13] selftests/resctrl: Make functions only used in same file static Reinette Chatre
2024-09-12 18:13 ` [PATCH V2 02/13] selftests/resctrl: Print accurate buffer size as part of MBM results Reinette Chatre
2024-09-12 18:13 ` [PATCH V2 03/13] selftests/resctrl: Fix memory overflow due to unhandled wraparound Reinette Chatre
2024-09-30 13:16   ` Ilpo Järvinen
2024-09-12 18:13 ` [PATCH V2 04/13] selftests/resctrl: Protect against array overrun during iMC config parsing Reinette Chatre
2024-09-30 13:35   ` Ilpo Järvinen
2024-09-30 16:04     ` Reinette Chatre
2024-09-12 18:13 ` [PATCH V2 05/13] selftests/resctrl: Make wraparound handling obvious Reinette Chatre
2024-09-12 18:13 ` [PATCH V2 06/13] selftests/resctrl: Remove "once" parameter required to be false Reinette Chatre
2024-09-30 13:49   ` Ilpo Järvinen
2024-09-30 16:07     ` Reinette Chatre
2024-09-12 18:13 ` [PATCH V2 07/13] selftests/resctrl: Only support measured read operation Reinette Chatre
2024-09-30 13:52   ` Ilpo Järvinen
2024-09-30 16:05     ` Reinette Chatre
2024-09-12 18:13 ` [PATCH V2 08/13] selftests/resctrl: Remove unused measurement code Reinette Chatre
2024-09-30 13:59   ` Ilpo Järvinen
2024-09-12 18:13 ` [PATCH V2 09/13] selftests/resctrl: Make benchmark parameter passing robust Reinette Chatre
2024-10-04 14:05   ` Ilpo Järvinen
2024-10-04 22:21     ` Reinette Chatre [this message]
2024-09-12 18:13 ` [PATCH V2 10/13] selftests/resctrl: Ensure measurements skip initialization of default benchmark Reinette Chatre
2024-10-04 14:11   ` Ilpo Järvinen
2024-09-12 18:14 ` [PATCH V2 11/13] selftests/resctrl: Use cache size to determine "fill_buf" buffer size Reinette Chatre
2024-10-04 14:20   ` Ilpo Järvinen
2024-10-04 22:23     ` Reinette Chatre
2024-09-12 18:14 ` [PATCH V2 12/13] selftests/resctrl: Do not compare performance counters and resctrl at low bandwidth Reinette Chatre
2024-10-04 14:23   ` Ilpo Järvinen
2024-09-12 18:14 ` [PATCH V2 13/13] selftests/resctrl: Keep results from first test run Reinette Chatre
2024-10-04 14:29   ` Ilpo Järvinen
2024-10-04 22:24     ` 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=6ae8be57-be40-4b85-a171-ce535bb5b5a4@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