lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ea3aca92-1571-7220-6211-6424de0b21da@linux.intel.com>
Date: Fri, 4 Oct 2024 17:20:27 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Reinette Chatre <reinette.chatre@...el.com>
cc: fenghua.yu@...el.com, shuah@...nel.org, tony.luck@...el.com, 
    peternewman@...gle.com, babu.moger@....com, 
    Maciej Wieczór-Retman <maciej.wieczor-retman@...el.com>, 
    linux-kselftest@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V2 11/13] selftests/resctrl: Use cache size to determine
 "fill_buf" buffer size

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@...el.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@...ux.intel.com>


-- 
 i.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ