selftests/powerpc/dscr: Improve DSCR explicit random test case
authorBenjamin Gray <bgray@linux.ibm.com>
Thu, 6 Apr 2023 04:33:18 +0000 (14:33 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 20 Apr 2023 03:21:45 +0000 (13:21 +1000)
commit3067b89ab62305c54ec15b00a2c4dbaf64809c59
tree6a0510188657f203925daa32b1f9ffebb5fb8c9d
parentfda8158870063b99b88a0904bbb95188973b4297
selftests/powerpc/dscr: Improve DSCR explicit random test case

The tests currently have a single writer thread updating the system
DSCR with a 1/1000 chance looped only 100 times. So only around one in
10 runs actually do anything.

* Add multiple threads to the dscr_explicit_random_test case.
* Use a barrier to make all the threads start work as simultaneously as
  possible.
* Use a rwlock and make all threads have a reasonable chance to write to
  the DSCR on each iteration.
  PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is used to prevent
  writers from starving while all the other threads keep reading.
  Logging the reads/writes shows a decent mix across the whole test.
* Allow all threads a chance to write.
* Make the chance of writing more likely.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230406043320.125138-6-bgray@linux.ibm.com
tools/testing/selftests/powerpc/dscr/dscr.h
tools/testing/selftests/powerpc/dscr/dscr_default_test.c
tools/testing/selftests/powerpc/dscr/dscr_explicit_test.c