aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2014-09-29 09:14:25 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-09-30 03:10:02 -0400
commita1229491006a3d55cc0d7e6d496be39915ccefdd (patch)
treefec585adeb011833630c936148f4cf722d62e96d /kernel/locking
parent219f800f99db6f4e43a582cb9e0d98931f13c012 (diff)
locktorture: Cannot hold read and write lock
... trigger an error if so. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/locking')
-rw-r--r--kernel/locking/locktorture.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index 9e9cd111fb0f..b05dc46c4297 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -453,14 +453,19 @@ static int lock_torture_writer(void *arg)
453 do { 453 do {
454 if ((torture_random(&rand) & 0xfffff) == 0) 454 if ((torture_random(&rand) & 0xfffff) == 0)
455 schedule_timeout_uninterruptible(1); 455 schedule_timeout_uninterruptible(1);
456
456 cxt.cur_ops->writelock(); 457 cxt.cur_ops->writelock();
457 if (WARN_ON_ONCE(lock_is_write_held)) 458 if (WARN_ON_ONCE(lock_is_write_held))
458 lwsp->n_lock_fail++; 459 lwsp->n_lock_fail++;
459 lock_is_write_held = 1; 460 lock_is_write_held = 1;
461 if (WARN_ON_ONCE(lock_is_read_held))
462 lwsp->n_lock_fail++; /* rare, but... */
463
460 lwsp->n_lock_acquired++; 464 lwsp->n_lock_acquired++;
461 cxt.cur_ops->write_delay(&rand); 465 cxt.cur_ops->write_delay(&rand);
462 lock_is_write_held = 0; 466 lock_is_write_held = 0;
463 cxt.cur_ops->writeunlock(); 467 cxt.cur_ops->writeunlock();
468
464 stutter_wait("lock_torture_writer"); 469 stutter_wait("lock_torture_writer");
465 } while (!torture_must_stop()); 470 } while (!torture_must_stop());
466 torture_kthread_stopping("lock_torture_writer"); 471 torture_kthread_stopping("lock_torture_writer");
@@ -482,12 +487,17 @@ static int lock_torture_reader(void *arg)
482 do { 487 do {
483 if ((torture_random(&rand) & 0xfffff) == 0) 488 if ((torture_random(&rand) & 0xfffff) == 0)
484 schedule_timeout_uninterruptible(1); 489 schedule_timeout_uninterruptible(1);
490
485 cxt.cur_ops->readlock(); 491 cxt.cur_ops->readlock();
486 lock_is_read_held = 1; 492 lock_is_read_held = 1;
493 if (WARN_ON_ONCE(lock_is_write_held))
494 lrsp->n_lock_fail++; /* rare, but... */
495
487 lrsp->n_lock_acquired++; 496 lrsp->n_lock_acquired++;
488 cxt.cur_ops->read_delay(&rand); 497 cxt.cur_ops->read_delay(&rand);
489 lock_is_read_held = 0; 498 lock_is_read_held = 0;
490 cxt.cur_ops->readunlock(); 499 cxt.cur_ops->readunlock();
500
491 stutter_wait("lock_torture_reader"); 501 stutter_wait("lock_torture_reader");
492 } while (!torture_must_stop()); 502 } while (!torture_must_stop());
493 torture_kthread_stopping("lock_torture_reader"); 503 torture_kthread_stopping("lock_torture_reader");