Lines Matching +full:init +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0+
3 * Module-based torture test facility for locking
28 #include <linux/delay.h>
36 torture_param(int, nwriters_stress, -1,
37 "Number of write-locking stress-test threads");
38 torture_param(int, nreaders_stress, -1,
39 "Number of read-locking stress-test threads");
77 void (*init)(void); member
117 /* We want a long delay occasionally to force massive contention. */ in torture_lock_busted_write_delay()
160 /* We want a short delay mostly to emulate likely code, and in torture_spin_lock_write_delay()
161 * we want a long delay occasionally to force massive contention. in torture_spin_lock_write_delay()
196 cxt.cur_ops->flags = flags; in torture_spin_lock_write_lock_irq()
203 spin_unlock_irqrestore(&torture_spinlock, cxt.cur_ops->flags); in torture_lock_spin_write_unlock_irq()
231 /* We want a short delay mostly to emulate likely code, and in torture_rwlock_write_delay()
232 * we want a long delay occasionally to force massive contention. in torture_rwlock_write_delay()
259 /* We want a short delay mostly to emulate likely code, and in torture_rwlock_read_delay()
260 * we want a long delay occasionally to force massive contention. in torture_rwlock_read_delay()
292 cxt.cur_ops->flags = flags; in torture_rwlock_write_lock_irq()
299 write_unlock_irqrestore(&torture_rwlock, cxt.cur_ops->flags); in torture_rwlock_write_unlock_irq()
308 cxt.cur_ops->flags = flags; in torture_rwlock_read_lock_irq()
315 read_unlock_irqrestore(&torture_rwlock, cxt.cur_ops->flags); in torture_rwlock_read_unlock_irq()
342 /* We want a long delay occasionally to force massive contention. */ in torture_mutex_delay()
423 err = ww_mutex_lock(ll->lock, ctx); in torture_ww_mutex_lock()
429 ww_mutex_unlock(ln->lock); in torture_ww_mutex_lock()
431 if (err != -EDEADLK) in torture_ww_mutex_lock()
434 ww_mutex_lock_slow(ll->lock, ctx); in torture_ww_mutex_lock()
435 list_move(&ll->link, &list); in torture_ww_mutex_lock()
455 .init = torture_ww_mutex_init,
485 * for the new priority, and do any corresponding pi-dance. in torture_rtmutex_boost()
497 * When @trsp is nil, we want to force-reset the task for in torture_rtmutex_boost()
514 * We want a short delay mostly to emulate likely code, and in torture_rtmutex_delay()
515 * we want a long delay occasionally to force massive contention. in torture_rtmutex_delay()
557 /* We want a long delay occasionally to force massive contention. */ in torture_rwsem_write_delay()
584 /* We want a long delay occasionally to force massive contention. */ in torture_rwsem_read_delay()
611 #include <linux/percpu-rwsem.h>
651 .init = torture_percpu_rwsem_init,
670 int tid = lwsp - cxt.lwsa; in lock_torture_writer()
680 cxt.cur_ops->task_boost(&rand); in lock_torture_writer()
681 cxt.cur_ops->writelock(tid); in lock_torture_writer()
683 lwsp->n_lock_fail++; in lock_torture_writer()
686 lwsp->n_lock_fail++; /* rare, but... */ in lock_torture_writer()
688 lwsp->n_lock_acquired++; in lock_torture_writer()
689 cxt.cur_ops->write_delay(&rand); in lock_torture_writer()
692 cxt.cur_ops->writeunlock(tid); in lock_torture_writer()
697 cxt.cur_ops->task_boost(NULL); /* reset prio */ in lock_torture_writer()
709 int tid = lrsp - cxt.lrsa; in lock_torture_reader()
719 cxt.cur_ops->readlock(tid); in lock_torture_reader()
722 lrsp->n_lock_fail++; /* rare, but... */ in lock_torture_reader()
724 lrsp->n_lock_acquired++; in lock_torture_reader()
725 cxt.cur_ops->read_delay(&rand); in lock_torture_reader()
727 cxt.cur_ops->readunlock(tid); in lock_torture_reader()
736 * Create an lock-torture-statistics message in the specified buffer.
773 * (or the init/cleanup functions when lock_torture_stats thread is not
781 if (cxt.cur_ops->readlock) in lock_torture_stats_print()
795 if (cxt.cur_ops->readlock) { in lock_torture_stats_print()
833 …"--- %s%s: nwriters_stress=%d nreaders_stress=%d stat_interval=%d verbose=%d shuffle_interval=%d s… in lock_torture_print_module_parms()
850 * However cxt->cur_ops.init() may have been invoked, so beside in lock_torture_cleanup()
851 * perform the underlying torture-specific cleanups, cur_ops.exit() in lock_torture_cleanup()
874 lock_torture_stats_print(); /* -After- the stats thread is stopped! */ in lock_torture_cleanup()
893 if (cxt.cur_ops->exit) in lock_torture_cleanup()
894 cxt.cur_ops->exit(); in lock_torture_cleanup()
918 return -EBUSY; in lock_torture_init()
923 if (strcmp(torture_type, cxt.cur_ops->name) == 0) in lock_torture_init()
927 pr_alert("lock-torture: invalid torture type: \"%s\"\n", in lock_torture_init()
929 pr_alert("lock-torture types:"); in lock_torture_init()
931 pr_alert(" %s", torture_ops[i]->name); in lock_torture_init()
933 firsterr = -EINVAL; in lock_torture_init()
938 (!cxt.cur_ops->readlock || nreaders_stress == 0)) { in lock_torture_init()
939 pr_alert("lock-torture: must run at least one locking thread\n"); in lock_torture_init()
940 firsterr = -EINVAL; in lock_torture_init()
949 if (cxt.cur_ops->init) { in lock_torture_init()
950 cxt.cur_ops->init(); in lock_torture_init()
976 firsterr = -ENOMEM; in lock_torture_init()
986 if (cxt.cur_ops->readlock) { in lock_torture_init()
993 * of threads as the writer-only locks default. in lock_torture_init()
1006 firsterr = -ENOMEM; in lock_torture_init()
1051 firsterr = -ENOMEM; in lock_torture_init()
1056 if (cxt.cur_ops->readlock) { in lock_torture_init()
1064 firsterr = -ENOMEM; in lock_torture_init()
1089 if (cxt.cur_ops->readlock == NULL || (j >= cxt.nrealreaders_stress)) in lock_torture_init()