mutex subsystem, synchro-test module
Subsystems (2)
PATCH 12/20 mutex subsystem, synchro-test module
From: David Howells <[email protected]>
The attached patch adds a module for testing and benchmarking mutexes, semaphores and R/W semaphores.
Using it is simple:
insmod synchro-test.ko <args>
It will exit with error ENOANO after running the tests and printing the results to the kernel console log.
The available arguments are:
(*) mx=N
Start up to N mutex thrashing threads, where N is at most 20. All will try and thrash the same mutex.
(*) sm=N
Start up to N counting semaphore thrashing threads, where N is at most
20. All will try and thrash the same semaphore.
(*) ism=M
Initialise the counting semaphore with M, where M is any positive integer greater than zero. The default is 4.
(*) rd=N
(*) wr=O
(*) dg=P
Start up to N reader thrashing threads, O writer thrashing threads and P downgrader thrashing threads, where N, O and P are at most 20 apiece. All will try and thrash the same read/write semaphore.
(*) elapse=N
Run the tests for N seconds. The default is 5.
(*) load=N
Each thread delays for N uS whilst holding the lock. The dfault is 0.
(*) interval=N
Each thread delays for N uS whilst not holding the lock. The default is 0.
(*) do_sched=1
Each thread will call schedule if required after each iteration.
(*) v=1
Print more verbose information, including a thread iteration distribution list.
The module should be enabled by turning on CONFIG_DEBUG_SYNCHRO_TEST to "m".
----
Documentation/synchro-test.txt | 59 ++++ kernel/Makefile | 1 kernel/synchro-test.c | 508 +++++++++++++++++++++++++++++++++++++++++ lib/Kconfig.debug | 14 + 4 files changed, 582 insertions(+)
Documentation/synchro-test.txt new file +59 -0
@@ -0,0 +1,59 @@ +The synchro-test.ko module can be used for testing and benchmarking mutexes, +semaphores and R/W semaphores. + +The module is compiled by setting CONFIG_DEBUG_SYNCHRO_TEST to "m" when +configuring the kernel. + +Using it is simple: + + insmod synchro-test.ko <args> + +It will exit with error ENOANO after running the tests and printing the +results to the kernel console log. + +The available arguments are: + + (*) mx=N + + Start up to N mutex thrashing threads, where N is at most 20. All will + try and thrash the same mutex. + + (*) sm=N + + Start up to N counting semaphore thrashing threads, where N is at most + 20. All will try and thrash the same semaphore. + + (*) ism=M + + Initialise the counting semaphore with M, where M is any positive + integer greater than zero. The default is 4. + + (*) rd=N + (*) wr=O + (*) dg=P + + Start up to N reader thrashing threads, O writer thrashing threads and + P downgrader thrashing threads, where N, O and P are at most 20 + apiece. All will try and thrash the same read/write semaphore. + + (*) elapse=N + + Run the tests for N seconds. The default is 5. + + (*) load=N + + Each thread delays for N uS whilst holding the lock. The default is 0. + + (*) interval=N + + Each thread delays for N uS whilst not holding the lock. The default + is 0. + + (*) do_sched=1 + + Each thread will call schedule if required after each iteration. + + (*) v=1 + + Print more verbose information, including a thread iteration + distribution list.
kernel/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_GENERIC_HARDIRQS) += irq/ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o +obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y) # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
kernel/synchro-test.c new file +508 -0
508 lines not on this page · raw message
lib/Kconfig.debug +14 -0
@@ -207,3 +207,17 @@ config RCU_TORTURE_TEST at boot time (you probably don't). Say M if you want the RCU torture tests to build as a module. Say N if you are unsure. + +config DEBUG_SYNCHRO_TEST + tristate "Synchronisation primitive testing module" + depends on DEBUG_KERNEL + default n + help + This option provides a kernel module that can thrash the sleepable + synchronisation primitives (mutexes and semaphores). + + You should say N or M here. Whilst the module can be built in, it's + not recommended as it requires module parameters supplying to get it + to do anything. + + See Documentation/synchro-test.txt.