locktorture: Ignore nreaders_stress if no readlock support

Exclusive locks do not have readlock support, which means that a
locktorture run with the following module parameters will do nothing:

 torture_type=mutex_lock nwriters_stress=0 nreaders_stress=1

This commit therefore rejects this combination for exclusive locks by
returning -EINVAL during module init.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
Hou Tao 2020-09-18 19:44:24 +08:00 committed by Paul E. McKenney
parent 6f26d010e6
commit e5ace37d83
1 changed files with 2 additions and 1 deletions

View File

@ -870,7 +870,8 @@ static int __init lock_torture_init(void)
goto unwind; goto unwind;
} }
if (nwriters_stress == 0 && nreaders_stress == 0) { if (nwriters_stress == 0 &&
(!cxt.cur_ops->readlock || nreaders_stress == 0)) {
pr_alert("lock-torture: must run at least one locking thread\n"); pr_alert("lock-torture: must run at least one locking thread\n");
firsterr = -EINVAL; firsterr = -EINVAL;
goto unwind; goto unwind;