@@ -46,6 +46,8 @@ torture_param(int, shutdown_secs, 0, "Shutdown time (j), <= zero to disable.");
46
46
torture_param (int , stat_interval , 60 ,
47
47
"Number of seconds between stats printk()s" );
48
48
torture_param (int , stutter , 5 , "Number of jiffies to run/halt test, 0=disable" );
49
+ torture_param (int , rt_boost , 2 ,
50
+ "Do periodic rt-boost. 0=Disable, 1=Only for rt_mutex, 2=For all lock types." );
49
51
torture_param (int , verbose , 1 ,
50
52
"Enable verbose debugging printk()s" );
51
53
@@ -127,15 +129,49 @@ static void torture_lock_busted_write_unlock(int tid __maybe_unused)
127
129
/* BUGGY, do not use in real life!!! */
128
130
}
129
131
130
- static void torture_boost_dummy (struct torture_random_state * trsp )
132
+ static void __torture_rt_boost (struct torture_random_state * trsp )
131
133
{
132
- /* Only rtmutexes care about priority */
134
+ const unsigned int factor = 50000 ; /* yes, quite arbitrary */
135
+
136
+ if (!rt_task (current )) {
137
+ /*
138
+ * Boost priority once every ~50k operations. When the
139
+ * task tries to take the lock, the rtmutex it will account
140
+ * for the new priority, and do any corresponding pi-dance.
141
+ */
142
+ if (trsp && !(torture_random (trsp ) %
143
+ (cxt .nrealwriters_stress * factor ))) {
144
+ sched_set_fifo (current );
145
+ } else /* common case, do nothing */
146
+ return ;
147
+ } else {
148
+ /*
149
+ * The task will remain boosted for another ~500k operations,
150
+ * then restored back to its original prio, and so forth.
151
+ *
152
+ * When @trsp is nil, we want to force-reset the task for
153
+ * stopping the kthread.
154
+ */
155
+ if (!trsp || !(torture_random (trsp ) %
156
+ (cxt .nrealwriters_stress * factor * 2 ))) {
157
+ sched_set_normal (current , 0 );
158
+ } else /* common case, do nothing */
159
+ return ;
160
+ }
161
+ }
162
+
163
+ static void torture_rt_boost (struct torture_random_state * trsp )
164
+ {
165
+ if (rt_boost != 2 )
166
+ return ;
167
+
168
+ __torture_rt_boost (trsp );
133
169
}
134
170
135
171
static struct lock_torture_ops lock_busted_ops = {
136
172
.writelock = torture_lock_busted_write_lock ,
137
173
.write_delay = torture_lock_busted_write_delay ,
138
- .task_boost = torture_boost_dummy ,
174
+ .task_boost = torture_rt_boost ,
139
175
.writeunlock = torture_lock_busted_write_unlock ,
140
176
.readlock = NULL ,
141
177
.read_delay = NULL ,
@@ -179,7 +215,7 @@ __releases(torture_spinlock)
179
215
static struct lock_torture_ops spin_lock_ops = {
180
216
.writelock = torture_spin_lock_write_lock ,
181
217
.write_delay = torture_spin_lock_write_delay ,
182
- .task_boost = torture_boost_dummy ,
218
+ .task_boost = torture_rt_boost ,
183
219
.writeunlock = torture_spin_lock_write_unlock ,
184
220
.readlock = NULL ,
185
221
.read_delay = NULL ,
@@ -206,7 +242,7 @@ __releases(torture_spinlock)
206
242
static struct lock_torture_ops spin_lock_irq_ops = {
207
243
.writelock = torture_spin_lock_write_lock_irq ,
208
244
.write_delay = torture_spin_lock_write_delay ,
209
- .task_boost = torture_boost_dummy ,
245
+ .task_boost = torture_rt_boost ,
210
246
.writeunlock = torture_lock_spin_write_unlock_irq ,
211
247
.readlock = NULL ,
212
248
.read_delay = NULL ,
@@ -275,7 +311,7 @@ __releases(torture_rwlock)
275
311
static struct lock_torture_ops rw_lock_ops = {
276
312
.writelock = torture_rwlock_write_lock ,
277
313
.write_delay = torture_rwlock_write_delay ,
278
- .task_boost = torture_boost_dummy ,
314
+ .task_boost = torture_rt_boost ,
279
315
.writeunlock = torture_rwlock_write_unlock ,
280
316
.readlock = torture_rwlock_read_lock ,
281
317
.read_delay = torture_rwlock_read_delay ,
@@ -318,7 +354,7 @@ __releases(torture_rwlock)
318
354
static struct lock_torture_ops rw_lock_irq_ops = {
319
355
.writelock = torture_rwlock_write_lock_irq ,
320
356
.write_delay = torture_rwlock_write_delay ,
321
- .task_boost = torture_boost_dummy ,
357
+ .task_boost = torture_rt_boost ,
322
358
.writeunlock = torture_rwlock_write_unlock_irq ,
323
359
.readlock = torture_rwlock_read_lock_irq ,
324
360
.read_delay = torture_rwlock_read_delay ,
@@ -358,7 +394,7 @@ __releases(torture_mutex)
358
394
static struct lock_torture_ops mutex_lock_ops = {
359
395
.writelock = torture_mutex_lock ,
360
396
.write_delay = torture_mutex_delay ,
361
- .task_boost = torture_boost_dummy ,
397
+ .task_boost = torture_rt_boost ,
362
398
.writeunlock = torture_mutex_unlock ,
363
399
.readlock = NULL ,
364
400
.read_delay = NULL ,
@@ -456,7 +492,7 @@ static struct lock_torture_ops ww_mutex_lock_ops = {
456
492
.exit = torture_ww_mutex_exit ,
457
493
.writelock = torture_ww_mutex_lock ,
458
494
.write_delay = torture_mutex_delay ,
459
- .task_boost = torture_boost_dummy ,
495
+ .task_boost = torture_rt_boost ,
460
496
.writeunlock = torture_ww_mutex_unlock ,
461
497
.readlock = NULL ,
462
498
.read_delay = NULL ,
@@ -474,37 +510,6 @@ __acquires(torture_rtmutex)
474
510
return 0 ;
475
511
}
476
512
477
- static void torture_rtmutex_boost (struct torture_random_state * trsp )
478
- {
479
- const unsigned int factor = 50000 ; /* yes, quite arbitrary */
480
-
481
- if (!rt_task (current )) {
482
- /*
483
- * Boost priority once every ~50k operations. When the
484
- * task tries to take the lock, the rtmutex it will account
485
- * for the new priority, and do any corresponding pi-dance.
486
- */
487
- if (trsp && !(torture_random (trsp ) %
488
- (cxt .nrealwriters_stress * factor ))) {
489
- sched_set_fifo (current );
490
- } else /* common case, do nothing */
491
- return ;
492
- } else {
493
- /*
494
- * The task will remain boosted for another ~500k operations,
495
- * then restored back to its original prio, and so forth.
496
- *
497
- * When @trsp is nil, we want to force-reset the task for
498
- * stopping the kthread.
499
- */
500
- if (!trsp || !(torture_random (trsp ) %
501
- (cxt .nrealwriters_stress * factor * 2 ))) {
502
- sched_set_normal (current , 0 );
503
- } else /* common case, do nothing */
504
- return ;
505
- }
506
- }
507
-
508
513
static void torture_rtmutex_delay (struct torture_random_state * trsp )
509
514
{
510
515
const unsigned long shortdelay_us = 2 ;
@@ -530,10 +535,18 @@ __releases(torture_rtmutex)
530
535
rt_mutex_unlock (& torture_rtmutex );
531
536
}
532
537
538
+ static void torture_rt_boost_rtmutex (struct torture_random_state * trsp )
539
+ {
540
+ if (!rt_boost )
541
+ return ;
542
+
543
+ __torture_rt_boost (trsp );
544
+ }
545
+
533
546
static struct lock_torture_ops rtmutex_lock_ops = {
534
547
.writelock = torture_rtmutex_lock ,
535
548
.write_delay = torture_rtmutex_delay ,
536
- .task_boost = torture_rtmutex_boost ,
549
+ .task_boost = torture_rt_boost_rtmutex ,
537
550
.writeunlock = torture_rtmutex_unlock ,
538
551
.readlock = NULL ,
539
552
.read_delay = NULL ,
@@ -600,7 +613,7 @@ __releases(torture_rwsem)
600
613
static struct lock_torture_ops rwsem_lock_ops = {
601
614
.writelock = torture_rwsem_down_write ,
602
615
.write_delay = torture_rwsem_write_delay ,
603
- .task_boost = torture_boost_dummy ,
616
+ .task_boost = torture_rt_boost ,
604
617
.writeunlock = torture_rwsem_up_write ,
605
618
.readlock = torture_rwsem_down_read ,
606
619
.read_delay = torture_rwsem_read_delay ,
@@ -652,7 +665,7 @@ static struct lock_torture_ops percpu_rwsem_lock_ops = {
652
665
.exit = torture_percpu_rwsem_exit ,
653
666
.writelock = torture_percpu_rwsem_down_write ,
654
667
.write_delay = torture_rwsem_write_delay ,
655
- .task_boost = torture_boost_dummy ,
668
+ .task_boost = torture_rt_boost ,
656
669
.writeunlock = torture_percpu_rwsem_up_write ,
657
670
.readlock = torture_percpu_rwsem_down_read ,
658
671
.read_delay = torture_rwsem_read_delay ,
0 commit comments