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 V3 12/15] selftests/resctrl: Use cache size to determine "fill_buf" buffer size
Date: Fri, 18 Oct 2024 12:06:48 +0300 (EEST) [thread overview]
Message-ID: <064588b9-f6a9-cf49-bbca-c502314490ba@linux.intel.com> (raw)
In-Reply-To: <388c93423d9a071f5877f3edb4f55ef64bf384bc.1729218182.git.reinette.chatre@intel.com>
[-- Attachment #1: Type: text/plain, Size: 5525 bytes --]
On Thu, 17 Oct 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, now renamed to MINIMUM_SPAN, that has been appropriate for
> testing so far.
>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Look good, thanks.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
> ---
> Changes since V2:
> - Move duplicate code into helper. (Ilpo)
> - Rename DEFAULT_SPAN to MINIMUM_SPAN to reflect its new purpose. (Ilpo)
> - Do _not_ add Ilpo's Reviewed-by tag ... the patch changed too much.
>
> 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/fill_buf.c | 13 +++++++++++++
> tools/testing/selftests/resctrl/mba_test.c | 7 ++++++-
> tools/testing/selftests/resctrl/mbm_test.c | 7 ++++++-
> tools/testing/selftests/resctrl/resctrl.h | 3 ++-
> tools/testing/selftests/resctrl/resctrl_tests.c | 2 +-
> 5 files changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c
> index 380cc35f10c6..19a01a52dc1a 100644
> --- a/tools/testing/selftests/resctrl/fill_buf.c
> +++ b/tools/testing/selftests/resctrl/fill_buf.c
> @@ -129,3 +129,16 @@ unsigned char *alloc_buffer(size_t buf_size, bool memflush)
>
> return buf;
> }
> +
> +ssize_t get_fill_buf_size(int cpu_no, const char *cache_type)
> +{
> + unsigned long cache_total_size = 0;
> + int ret;
> +
> + ret = get_cache_size(cpu_no, cache_type, &cache_total_size);
> + if (ret)
> + return ret;
> +
> + return cache_total_size * 2 > MINIMUM_SPAN ?
> + cache_total_size * 2 : MINIMUM_SPAN;
> +}
> diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c
> index 74d95c460bd0..bf37f3555660 100644
> --- a/tools/testing/selftests/resctrl/mba_test.c
> +++ b/tools/testing/selftests/resctrl/mba_test.c
> @@ -182,7 +182,12 @@ 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;
> + ssize_t buf_size;
> +
> + buf_size = get_fill_buf_size(uparams->cpu, "L3");
> + if (buf_size < 0)
> + return buf_size;
> + fill_buf.buf_size = buf_size;
> fill_buf.memflush = true;
> param.fill_buf = &fill_buf;
> }
> diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c
> index 72261413c868..4224f8ce3538 100644
> --- a/tools/testing/selftests/resctrl/mbm_test.c
> +++ b/tools/testing/selftests/resctrl/mbm_test.c
> @@ -149,7 +149,12 @@ 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;
> + ssize_t buf_size;
> +
> + buf_size = get_fill_buf_size(uparams->cpu, "L3");
> + if (buf_size < 0)
> + return buf_size;
> + fill_buf.buf_size = buf_size;
> fill_buf.memflush = true;
> param.fill_buf = &fill_buf;
> }
> diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
> index 032cd9ebd761..a553fe975938 100644
> --- a/tools/testing/selftests/resctrl/resctrl.h
> +++ b/tools/testing/selftests/resctrl/resctrl.h
> @@ -41,7 +41,7 @@
>
> #define BENCHMARK_ARGS 64
>
> -#define DEFAULT_SPAN (250 * MB)
> +#define MINIMUM_SPAN (250 * MB)
>
> /*
> * fill_buf_param: "fill_buf" benchmark parameters
> @@ -169,6 +169,7 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
> unsigned char *alloc_buffer(size_t buf_size, bool memflush);
> void mem_flush(unsigned char *buf, size_t buf_size);
> void fill_cache_read(unsigned char *buf, size_t buf_size, bool once);
> +ssize_t get_fill_buf_size(int cpu_no, const char *cache_type);
> int initialize_read_mem_bw_imc(void);
> int measure_read_mem_bw(const struct user_params *uparams,
> struct resctrl_val_param *param, pid_t bm_pid);
> diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
> index 88768f4d4961..790f4eb7871a 100644
> --- a/tools/testing/selftests/resctrl/resctrl_tests.c
> +++ b/tools/testing/selftests/resctrl/resctrl_tests.c
> @@ -189,7 +189,7 @@ static struct fill_buf_param *alloc_fill_buf_param(struct user_params *uparams)
> ksft_exit_skip("Unable to parse benchmark buffer size.\n");
> }
> } else {
> - fill_param->buf_size = DEFAULT_SPAN;
> + fill_param->buf_size = MINIMUM_SPAN;
> }
>
> if (uparams->benchmark_cmd[2]) {
>
next prev parent reply other threads:[~2024-10-18 9:06 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
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 [this message]
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=064588b9-f6a9-cf49-bbca-c502314490ba@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