locktorture: Ignore nreaders_stress if no readlock support
authorHou Tao <houtao1@huawei.com>
Fri, 18 Sep 2020 11:44:24 +0000 (19:44 +0800)
committerPaul E. McKenney <paulmck@kernel.org>
Sat, 7 Nov 2020 01:13:52 +0000 (17:13 -0800)
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>
kernel/locking/locktorture.c

index 316531de2a81c3c391ea5a004f767f278bb9d4a1..046ea2d2bc8cb23df259dcb1397aa56802f1cd40 100644 (file)
@@ -870,7 +870,8 @@ static int __init lock_torture_init(void)
                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");
                firsterr = -EINVAL;
                goto unwind;