]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/resctrl: Ensure measurements skip initialization of default benchmark
authorReinette Chatre <reinette.chatre@intel.com>
Thu, 24 Oct 2024 21:18:48 +0000 (14:18 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 5 Nov 2024 00:02:03 +0000 (17:02 -0700)
commit3cb3f0b8755919648281064d44c06319743db343
treec1496a048a08da4ae63a95cfeff6ac482fe3865d
parente958c21e2edecd17c87c4a2df39d1e47a3f7c039
selftests/resctrl: Ensure measurements skip initialization of default benchmark

The CMT, MBA, and MBM tests rely on the resctrl_val() wrapper to
start and run a benchmark while providing test specific flows
via callbacks to do test specific configuration and measurements.

At a high level, the resctrl_val() flow is:
a) Start by fork()ing a child process that installs a signal
   handler for SIGUSR1 that, on receipt of SIGUSR1, will
   start running a benchmark.
b) Assign the child process created in (a) to the resctrl
   control and monitoring group that dictates the memory and
   cache allocations with which the process can run and will
   contain all resctrl monitoring data of that process.
c) Once parent and child are considered "ready" (determined via
   a message over a pipe) the parent signals the child (via
   SIGUSR1) to start the benchmark, waits one second for the
   benchmark to run, and then starts collecting monitoring data
   for the tests, potentially also changing allocation
   configuration depending on the various test callbacks.

A problem with the above flow is the "black box" view of the
benchmark that is combined with an arbitrarily chosen
"wait one second" before measurements start. No matter what
the benchmark does, it is given one second to initialize before
measurements start.

The default benchmark "fill_buf" consists of two parts,
first it prepares a buffer (allocate, initialize, then flush), then it
reads from the buffer (in unpredictable ways) until terminated.
Depending on the system and the size of the buffer, the first "prepare"
part may not be complete by the time the one second delay expires. Test
measurements may thus start before the work needing to be measured runs.

Split the default benchmark into its "prepare" and "runtime" parts and
simplify the resctrl_val() wrapper while doing so. This same split
cannot be done for the user provided benchmark (without a user
interface change), so the current behavior is maintained for user
provided benchmark.

Assign the test itself to the control and monitoring group and run the
"prepare" part of the benchmark in this context, ensuring it runs with
required cache and memory bandwidth allocations. With the benchmark
preparation complete it is only needed to fork() the "runtime" part
of the benchmark (or entire user provided benchmark).

Keep the "wait one second" delay before measurements start. For the
default "fill_buf" benchmark this time now covers only the "runtime"
portion that needs to be measured. For the user provided benchmark this
delay maintains current behavior.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/resctrl/fill_buf.c
tools/testing/selftests/resctrl/resctrl.h
tools/testing/selftests/resctrl/resctrl_val.c