Skip to content

Commit c24501b

Browse files
joelagnelpaulmckrcu
authored andcommitted
locktorture: Make the rt_boost factor a tunable
The rt boosting in locktorture has a factor variable s currently large enough that boosting only happens once every minute or so. Add a tunable to reduce the factor so that boosting happens more often, to test paths and arrive at failure modes earlier. With this change, I can set the factor to like 50 and have the boosting happens every 10 seconds or so. Tested with boot parameters: locktorture.torture_type=mutex_lock locktorture.onoff_interval=1 locktorture.nwriters_stress=8 locktorture.stutter=0 locktorture.rt_boost=1 locktorture.rt_boost_factor=50 locktorture.nlocks=3 Signed-off-by: Joel Fernandes (Google) <[email protected]> Reviewed-by: Davidlohr Bueso <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent e01f3a1 commit c24501b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

kernel/locking/locktorture.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ torture_param(int, stat_interval, 60,
4848
torture_param(int, stutter, 5, "Number of jiffies to run/halt test, 0=disable");
4949
torture_param(int, rt_boost, 2,
5050
"Do periodic rt-boost. 0=Disable, 1=Only for rt_mutex, 2=For all lock types.");
51+
torture_param(int, rt_boost_factor, 50, "A factor determining how often rt-boost happens.");
5152
torture_param(int, verbose, 1,
5253
"Enable verbose debugging printk()s");
5354

@@ -131,12 +132,12 @@ static void torture_lock_busted_write_unlock(int tid __maybe_unused)
131132

132133
static void __torture_rt_boost(struct torture_random_state *trsp)
133134
{
134-
const unsigned int factor = 50000; /* yes, quite arbitrary */
135+
const unsigned int factor = rt_boost_factor;
135136

136137
if (!rt_task(current)) {
137138
/*
138-
* Boost priority once every ~50k operations. When the
139-
* task tries to take the lock, the rtmutex it will account
139+
* Boost priority once every rt_boost_factor operations. When
140+
* the task tries to take the lock, the rtmutex it will account
140141
* for the new priority, and do any corresponding pi-dance.
141142
*/
142143
if (trsp && !(torture_random(trsp) %
@@ -146,8 +147,9 @@ static void __torture_rt_boost(struct torture_random_state *trsp)
146147
return;
147148
} else {
148149
/*
149-
* The task will remain boosted for another ~500k operations,
150-
* then restored back to its original prio, and so forth.
150+
* The task will remain boosted for another 10 * rt_boost_factor
151+
* operations, then restored back to its original prio, and so
152+
* forth.
151153
*
152154
* When @trsp is nil, we want to force-reset the task for
153155
* stopping the kthread.

0 commit comments

Comments
 (0)