public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Reinette Chatre <reinette.chatre@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 11/13] selftests/resctrl: Use cache size to determine "fill_buf" buffer size
Date: Fri, 4 Oct 2024 17:20:27 +0300 (EEST)	[thread overview]
Message-ID: <ea3aca92-1571-7220-6211-6424de0b21da@linux.intel.com> (raw)
In-Reply-To: <ad51e32e5d4f8d99b691e7269e5179228e6a13a7.1726164080.git.reinette.chatre@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3250 bytes --]

On Thu, 12 Sep 2024, Reinette Chatre wrote:

> By default the MBM and MBA tests use the "fill_buf" benchmark to
> read from a buffer with the goal to measure the memory bandwidth
> generated by this buffer access.
> 
> Care should be taken when sizing the buffer used by the "fill_buf"
> benchmark. If the buffer is small enough to fit in the cache then
> it cannot be expected that the benchmark will generate much memory
> bandwidth. For example, on a system with 320MB L3 cache the existing
> hardcoded default of 250MB is insufficient.
> 
> Use the measured cache size to determine a buffer size that can be
> expected to trigger memory access while keeping the existing default
> as minimum that has been appropriate for testing so far.
> 
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
> Changes since V1:
> - Ensure buffer is at least double L3 cache size. (Ilpo)
> - Support user override of default buffer size. (Ilpo)
> ---
>  tools/testing/selftests/resctrl/mba_test.c | 8 +++++++-
>  tools/testing/selftests/resctrl/mbm_test.c | 8 +++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c
> index 7e43056c8737..d8d9637c1951 100644
> --- a/tools/testing/selftests/resctrl/mba_test.c
> +++ b/tools/testing/selftests/resctrl/mba_test.c
> @@ -182,7 +182,13 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param
>  		fill_buf.memflush = uparams->fill_buf->memflush;
>  		param.fill_buf = &fill_buf;
>  	} else if (!uparams->benchmark_cmd[0]) {
> -		fill_buf.buf_size = DEFAULT_SPAN;
> +		unsigned long cache_total_size = 0;
> +
> +		ret = get_cache_size(uparams->cpu, "L3", &cache_total_size);
> +		if (ret)
> +			return ret;
> +		fill_buf.buf_size = cache_total_size * 2 > DEFAULT_SPAN ?
> +				    cache_total_size * 2 : DEFAULT_SPAN;
>  		fill_buf.memflush = 1;
>  		param.fill_buf = &fill_buf;
>  	}
> diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c
> index b1f03a73333f..7635ee6b9339 100644
> --- a/tools/testing/selftests/resctrl/mbm_test.c
> +++ b/tools/testing/selftests/resctrl/mbm_test.c
> @@ -149,7 +149,13 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
>  		fill_buf.memflush = uparams->fill_buf->memflush;
>  		param.fill_buf = &fill_buf;
>  	} else if (!uparams->benchmark_cmd[0]) {
> -		fill_buf.buf_size = DEFAULT_SPAN;
> +		unsigned long cache_total_size = 0;
> +
> +		ret = get_cache_size(uparams->cpu, "L3", &cache_total_size);
> +		if (ret)
> +			return ret;
> +		fill_buf.buf_size = cache_total_size * 2 > DEFAULT_SPAN ?
> +				    cache_total_size * 2 : DEFAULT_SPAN;
>  		fill_buf.memflush = 1;
>  		param.fill_buf = &fill_buf;
>  	}
> 

It has a bit of code duplication feel in it so I'd consider adding 
something like ssize_t get_default_span() (perhaps there exists a better 
name for it that is not "span" based). Also DEFAULT_SPAN is no longer
truly the default span.

But neither is the end of the world as is...

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


-- 
 i.


  reply	other threads:[~2024-10-04 14:20 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
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 [this message]
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=ea3aca92-1571-7220-6211-6424de0b21da@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=babu.moger@amd.com \
    --cc=fenghua.yu@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=reinette.chatre@intel.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