mirror of
https://github.com/torvalds/linux.git
synced 2026-11-29 01:43:18 +00:00
To prevent anyone from seeing a test failure appear as a regression and
thinking that it was caused by their code change, insert some noise into
the loop which makes it immune to sampling bias issues (errata 1694299).
The "test data symbol" test can fail with any unrelated change that
shifts the loop into an unfortunate position in the Perf binary which is
almost impossible to debug as the root cause of the test failure.
Ultimately it's caused by the referenced errata.
Fixes: 60abedb8aa ("perf test: Introduce script for data symbol testing")
Reviewed-by: Ian Rogers <[email protected]>
Signed-off-by: James Clark <[email protected]>
Acked-by: Namhyung Kim <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Athira Rajeev <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Spoorthy S <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
41 lines
1001 B
C
41 lines
1001 B
C
#include <linux/compiler.h>
|
|
#include "../tests.h"
|
|
|
|
typedef struct _buf {
|
|
char data1;
|
|
char reserved[55];
|
|
char data2;
|
|
} buf __attribute__((aligned(64)));
|
|
|
|
static buf buf1 = {
|
|
/* to have this in the data section */
|
|
.reserved[0] = 1,
|
|
};
|
|
|
|
static int datasym(int argc __maybe_unused, const char **argv __maybe_unused)
|
|
{
|
|
for (;;) {
|
|
buf1.data1++;
|
|
if (buf1.data1 == 123) {
|
|
/*
|
|
* Add some 'noise' in the loop to work around errata
|
|
* 1694299 on Arm N1.
|
|
*
|
|
* Bias exists in SPE sampling which can cause the load
|
|
* and store instructions to be skipped entirely. This
|
|
* comes and goes randomly depending on the offset the
|
|
* linker places the datasym loop at in the Perf binary.
|
|
* With an extra branch in the middle of the loop that
|
|
* isn't always taken, the instruction stream is no
|
|
* longer a continuous repeating pattern that interacts
|
|
* badly with the bias.
|
|
*/
|
|
buf1.data1++;
|
|
}
|
|
buf1.data2 += buf1.data1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
DEFINE_WORKLOAD(datasym);
|