Commit a1229491 authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Paul E. McKenney

locktorture: Cannot hold read and write lock

... trigger an error if so.
Signed-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 219f800f
...@@ -453,14 +453,19 @@ static int lock_torture_writer(void *arg) ...@@ -453,14 +453,19 @@ static int lock_torture_writer(void *arg)
do { do {
if ((torture_random(&rand) & 0xfffff) == 0) if ((torture_random(&rand) & 0xfffff) == 0)
schedule_timeout_uninterruptible(1); schedule_timeout_uninterruptible(1);
cxt.cur_ops->writelock(); cxt.cur_ops->writelock();
if (WARN_ON_ONCE(lock_is_write_held)) if (WARN_ON_ONCE(lock_is_write_held))
lwsp->n_lock_fail++; lwsp->n_lock_fail++;
lock_is_write_held = 1; lock_is_write_held = 1;
if (WARN_ON_ONCE(lock_is_read_held))
lwsp->n_lock_fail++; /* rare, but... */
lwsp->n_lock_acquired++; lwsp->n_lock_acquired++;
cxt.cur_ops->write_delay(&rand); cxt.cur_ops->write_delay(&rand);
lock_is_write_held = 0; lock_is_write_held = 0;
cxt.cur_ops->writeunlock(); cxt.cur_ops->writeunlock();
stutter_wait("lock_torture_writer"); stutter_wait("lock_torture_writer");
} while (!torture_must_stop()); } while (!torture_must_stop());
torture_kthread_stopping("lock_torture_writer"); torture_kthread_stopping("lock_torture_writer");
...@@ -482,12 +487,17 @@ static int lock_torture_reader(void *arg) ...@@ -482,12 +487,17 @@ static int lock_torture_reader(void *arg)
do { do {
if ((torture_random(&rand) & 0xfffff) == 0) if ((torture_random(&rand) & 0xfffff) == 0)
schedule_timeout_uninterruptible(1); schedule_timeout_uninterruptible(1);
cxt.cur_ops->readlock(); cxt.cur_ops->readlock();
lock_is_read_held = 1; lock_is_read_held = 1;
if (WARN_ON_ONCE(lock_is_write_held))
lrsp->n_lock_fail++; /* rare, but... */
lrsp->n_lock_acquired++; lrsp->n_lock_acquired++;
cxt.cur_ops->read_delay(&rand); cxt.cur_ops->read_delay(&rand);
lock_is_read_held = 0; lock_is_read_held = 0;
cxt.cur_ops->readunlock(); cxt.cur_ops->readunlock();
stutter_wait("lock_torture_reader"); stutter_wait("lock_torture_reader");
} while (!torture_must_stop()); } while (!torture_must_stop());
torture_kthread_stopping("lock_torture_reader"); torture_kthread_stopping("lock_torture_reader");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment