Hi Ilpo,

On 11/20/2023 3:13 AM, Ilpo Järvinen wrote:
> When reading memory in order, HW prefetching optimizations will
> interfere with measuring how caches and memory are being accessed. This
> adds noise into the results.
> 
> Change the fill_buf reading loop to not use an obvious in-order access
> using multiply by a prime and modulo.
> 
> Using a prime multiplier with modulo ensures the entire buffer is
> eventually read. 23 is small enough that the reads are spread out but
> wrapping does not occur very frequently (wrapping too often can trigger
> L2 hits more frequently which causes noise to the test because getting
> the data from LLC is not required).
> 
> It was discovered that not all primes work equally well and some can
> cause wildly unstable results (e.g., in an earlier version of this
> patch, the reads were done in reversed order and 59 was used as the
> prime resulting in unacceptably high and unstable results in MBA and
> MBM test on some architectures).
> 
> Link: 
> https://lore.kernel.org/linux-kselftest/tyapr01mb6330025b5e6537f94da49acb8b...@tyapr01mb6330.jpnprd01.prod.outlook.com/
> Signed-off-by: Ilpo Järvinen <[email protected]>
> ---

I am not very comfortable with all the uncertainty involved in this
patch. A consolation is that this is surely an improvement.

Reviewed-by: Reinette Chatre <[email protected]>

Reinette

Reply via email to