diff options
| author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-02-11 11:05:07 -0500 |
|---|---|---|
| committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-02-23 12:04:43 -0500 |
| commit | e086481baf9d0436bdd6e9b739bfa4a83fb89ef5 (patch) | |
| tree | 8c30272e287b2aee92c3f27dc98fb711ea7cb02e /kernel/locking | |
| parent | b46f358ae5e3558a9072f0354128d5749a584d01 (diff) | |
rcutorture: Add a lock_busted to test the test
This commit adds a maximally broken locking primitive in which
lock acquisition and release are both no-ops.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/locking')
| -rw-r--r-- | kernel/locking/locktorture.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index d69d20d9c9db..f26b1a18e34e 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c | |||
| @@ -112,6 +112,37 @@ static struct lock_torture_ops *cur_ops; | |||
| 112 | * Definitions for lock torture testing. | 112 | * Definitions for lock torture testing. |
| 113 | */ | 113 | */ |
| 114 | 114 | ||
| 115 | static int torture_lock_busted_write_lock(void) | ||
| 116 | { | ||
| 117 | return 0; /* BUGGY, do not use in real life!!! */ | ||
| 118 | } | ||
| 119 | |||
| 120 | static void torture_lock_busted_write_delay(struct torture_random_state *trsp) | ||
| 121 | { | ||
| 122 | const unsigned long longdelay_us = 100; | ||
| 123 | |||
| 124 | /* We want a long delay occasionally to force massive contention. */ | ||
| 125 | if (!(torture_random(trsp) % | ||
| 126 | (nrealwriters_stress * 2000 * longdelay_us))) | ||
| 127 | mdelay(longdelay_us); | ||
| 128 | #ifdef CONFIG_PREEMPT | ||
| 129 | if (!(torture_random(trsp) % (nrealwriters_stress * 20000))) | ||
| 130 | preempt_schedule(); /* Allow test to be preempted. */ | ||
| 131 | #endif | ||
| 132 | } | ||
| 133 | |||
| 134 | static void torture_lock_busted_write_unlock(void) | ||
| 135 | { | ||
| 136 | /* BUGGY, do not use in real life!!! */ | ||
| 137 | } | ||
| 138 | |||
| 139 | static struct lock_torture_ops lock_busted_ops = { | ||
| 140 | .writelock = torture_lock_busted_write_lock, | ||
| 141 | .write_delay = torture_lock_busted_write_delay, | ||
| 142 | .writeunlock = torture_lock_busted_write_unlock, | ||
| 143 | .name = "lock_busted" | ||
| 144 | }; | ||
| 145 | |||
| 115 | static DEFINE_SPINLOCK(torture_spinlock); | 146 | static DEFINE_SPINLOCK(torture_spinlock); |
| 116 | 147 | ||
| 117 | static int torture_spin_lock_write_lock(void) __acquires(torture_spinlock) | 148 | static int torture_spin_lock_write_lock(void) __acquires(torture_spinlock) |
| @@ -320,7 +351,7 @@ static int __init lock_torture_init(void) | |||
| 320 | int i; | 351 | int i; |
| 321 | int firsterr = 0; | 352 | int firsterr = 0; |
| 322 | static struct lock_torture_ops *torture_ops[] = { | 353 | static struct lock_torture_ops *torture_ops[] = { |
| 323 | &spin_lock_ops, &spin_lock_irq_ops, | 354 | &lock_busted_ops, &spin_lock_ops, &spin_lock_irq_ops, |
| 324 | }; | 355 | }; |
| 325 | 356 | ||
| 326 | torture_init_begin(torture_type, verbose, &locktorture_runnable); | 357 | torture_init_begin(torture_type, verbose, &locktorture_runnable); |
