locktorture: Torture rwlocks
Subsystems (5)
Davidlohr Bueso
maintainercover locktorture: Torture rwlocks
We are still missing the ability to torture rwlocks, particularly the new queued variant (patch 1). The rest of the patches are miscellaneous updates.
Hopefully the set is straightforward enough that it can still be considered for v3.18.
Davidlohr Bueso (4):
locktorture: Support rwlocks
locktorture: Fix __acquire annotation for spinlock irq
locktorture: Cannot hold read and write lock
locktorture: Cleanup header usage
Documentation/locking/locktorture.txt | 5 + kernel/locking/locktorture.c | 141 ++++++++++++++++++--- .../selftests/rcutorture/configs/lock/CFLIST | 1 + .../selftests/rcutorture/configs/lock/LOCK04 | 6 + .../selftests/rcutorture/configs/lock/LOCK04.boot | 1 + 5 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK04 create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK04.boot
Signature · 1 line
1.8.4.5
Davidlohr Bueso
maintainerPATCH 1/4 locktorture: Support rwlocks
Add a "rw_lock" torture test to stress kernel rwlocks and their irq variant. Reader critical regions are 5x longer than writers. As such a similar ratio of lock acquisitions is seen in the statistics. In the case of massive contention, both hold the lock for 1/10 of a second.
--- Documentation/locking/locktorture.txt | 5 + kernel/locking/locktorture.c | 115 ++++++++++++++++++++- .../selftests/rcutorture/configs/lock/CFLIST | 1 + .../selftests/rcutorture/configs/lock/LOCK04 | 6 ++ .../selftests/rcutorture/configs/lock/LOCK04.boot | 1 + 5 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK04 create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK04.boot
Documentation/locking/locktorture.txt +5 -0
@@ -45,6 +45,11 @@ torture_type Type of lock to torture. By default, only spinlocks will o "spin_lock_irq": spin_lock_irq() and spin_unlock_irq() pairs. + o "rw_lock": read/write lock() and unlock() rwlock pairs. + + o "rw_lock_irq": read/write lock_irq() and unlock_irq() + rwlock pairs. + o "mutex_lock": mutex_lock() and mutex_unlock() pairs. o "rwsem_lock": read/write down() and up() semaphore pairs.
kernel/locking/locktorture.c +112 -3
139 lines not on this page · raw message
tools/testing/selftests/rcutorture/configs/lock/CFLIST +1 -0
@@ -1,3 +1,4 @@ LOCK01 LOCK02 LOCK03 +LOCK04
tools/testing/selftests/rcutorture/configs/lock/LOCK04 new file +6 -0
@@ -0,0 +1,6 @@ +CONFIG_SMP=y +CONFIG_NR_CPUS=4 +CONFIG_HOTPLUG_CPU=y +CONFIG_PREEMPT_NONE=n +CONFIG_PREEMPT_VOLUNTARY=n +CONFIG_PREEMPT=y
tools/testing/selftests/rcutorture/configs/lock/LOCK04.boot new file +1 -0
@@ -0,0 +1 @@ +locktorture.torture_type=rw_lock
Signature · 1 line
1.8.4.5
Davidlohr Bueso
maintainerPATCH 2/4 locktorture: Fix __acquire annotation for spinlock irq
In reply to Davidlohr BuesoIts quite easy to get mixed up with the names -- 'torture_spinlock_irq' is not actually a valid spinlock name.
--- kernel/locking/locktorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/locktorture.c +1 -1
@@ -205,7 +205,7 @@ static struct lock_torture_ops spin_lock_ops = { };static int torture_spin_lock_write_lock_irq (void ) -__acquires (torture_spinlock_irq) +__acquires (torture_spinlock) {unsigned long flags;
Signature · 1 line
1.8.4.5
Davidlohr Bueso
maintainerPATCH 3/4 locktorture: Cannot hold read and write lock
In reply to Davidlohr Bueso... trigger an error if so.
--- kernel/locking/locktorture.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/locking/locktorture.c +10 -0
@@ -453,14 +453,19 @@ static int lock_torture_writer(void *arg)do {if ((torture_random (&rand) &0xfffff ) ==0 )schedule_timeout_uninterruptible (1 ); + cxt.cur_ops->writelock ();if (WARN_ON_ONCE (lock_is_write_held)) lwsp->n_lock_fail++; lock_is_write_held =1 ; +if (WARN_ON_ONCE (lock_is_read_held)) + lwsp->n_lock_fail++;/* rare, but... */ + lwsp->n_lock_acquired++; cxt.cur_ops->write_delay (&rand); lock_is_write_held =0 ; cxt.cur_ops->writeunlock (); +stutter_wait ("lock_torture_writer" ); }while (!torture_must_stop ());torture_kthread_stopping ("lock_torture_writer" );
@@ -482,12 +487,17 @@ static int lock_torture_reader(void *arg)do {if ((torture_random (&rand) &0xfffff ) ==0 )schedule_timeout_uninterruptible (1 ); + cxt.cur_ops->readlock (); lock_is_read_held =1 ; +if (WARN_ON_ONCE (lock_is_write_held)) + lrsp->n_lock_fail++;/* rare, but... */ + lrsp->n_lock_acquired++; cxt.cur_ops->read_delay (&rand); lock_is_read_held =0 ; cxt.cur_ops->readunlock (); +stutter_wait ("lock_torture_reader" ); }while (!torture_must_stop ());torture_kthread_stopping ("lock_torture_reader" );
Signature · 1 line
1.8.4.5
Davidlohr Bueso
maintainerPATCH 4/4 locktorture: Cleanup header usage
In reply to Davidlohr BuesoRemove some unnecessary ones and explicitly include rwsem.h
--- kernel/locking/locktorture.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
kernel/locking/locktorture.c +1 -13
@@ -20,32 +20,20 @@* Author: Paul E. McKenney <[email protected]> * Based on kernel/rcu/torture.c. */ -#include <linux/types.h> #include <linux/kernel.h> -#include <linux/init.h> #include <linux/module.h> #include <linux/kthread.h> -#include <linux/err.h> #include <linux/spinlock.h> #include <linux/rwlock.h> #include <linux/mutex.h> +#include <linux/rwsem.h> #include <linux/smp.h> #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/atomic.h> -#include <linux/bitops.h> -#include <linux/completion.h> #include <linux/moduleparam.h> -#include <linux/percpu.h> -#include <linux/notifier.h> -#include <linux/reboot.h> -#include <linux/freezer.h> -#include <linux/cpu.h> #include <linux/delay.h> -#include <linux/stat.h> #include <linux/slab.h> -#include <linux/trace_clock.h> -#include <asm/byteorder.h> #include <linux/torture.h> MODULE_LICENSE ("GPL" );
Signature · 1 line
1.8.4.5
Paul E. McKenney
AppliedQuoted 6 lines · Davidlohr Bueso
We are still missing the ability to torture rwlocks, particularly the new queued variant (patch 1). The rest of the patches are miscellaneous updates.
Hopefully the set is straightforward enough that it can still be considered for v3.18.
Queued, thank you!
Running a quick set of tests, if these pass, will send a pull request along.
Thanx, Paul
Quoted 18 lines
Davidlohr Bueso (4):
locktorture: Support rwlocks
locktorture: Fix__acquireannotation for spinlock irq
locktorture: Cannot hold read and write lock
locktorture: Cleanup header usageDocumentation/locking/locktorture.txt | 5 + kernel/locking/locktorture.c | 141 ++++++++++++++++++--- .../selftests/rcutorture/configs/lock/CFLIST | 1 + .../selftests/rcutorture/configs/lock/LOCK04 | 6 + .../selftests/rcutorture/configs/lock/LOCK04.boot | 1 + 5 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK04 create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK04.bootSignature · 1 line
1.8.4.5