datasym.c 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <linux/compiler.h>
  2. #include "../tests.h"
  3. typedef struct _buf {
  4. char data1;
  5. char reserved[55];
  6. char data2;
  7. } buf __attribute__((aligned(64)));
  8. static buf buf1 = {
  9. /* to have this in the data section */
  10. .reserved[0] = 1,
  11. };
  12. static int datasym(int argc __maybe_unused, const char **argv __maybe_unused)
  13. {
  14. for (;;) {
  15. buf1.data1++;
  16. if (buf1.data1 == 123) {
  17. /*
  18. * Add some 'noise' in the loop to work around errata
  19. * 1694299 on Arm N1.
  20. *
  21. * Bias exists in SPE sampling which can cause the load
  22. * and store instructions to be skipped entirely. This
  23. * comes and goes randomly depending on the offset the
  24. * linker places the datasym loop at in the Perf binary.
  25. * With an extra branch in the middle of the loop that
  26. * isn't always taken, the instruction stream is no
  27. * longer a continuous repeating pattern that interacts
  28. * badly with the bias.
  29. */
  30. buf1.data1++;
  31. }
  32. buf1.data2 += buf1.data1;
  33. }
  34. return 0;
  35. }
  36. DEFINE_WORKLOAD(datasym);