Because rcu_torture_writer() and rcu_torture_fakewriter() predate hrtimers, they do timer-wheel-decoupled timed waits by using the timer-wheel-based schedule_timeout_interruptible() functions in conjunction with a random udelay()-based wait. This latter unnecessarily burns CPU time, so this commit instead uses torture_hrtimeout_jiffies() to decouple from the timer wheels without busy-waiting.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -1194,10 +1194,7 @@ rcu_torture_writer(void *arg) · 1193 unmodified lines | ||
| 1194 | 1194 | case RTWS_COND_GET: |
| 1195 | 1195 | rcu_torture_writer_state = RTWS_COND_GET; |
| 1196 | 1196 | gp_snap = cur_ops->get_gp_state(); |
| 1197 | − i = torture_random(&rand) % 16; | |
| 1198 | − if (i != 0) | |
| 1199 | − schedule_timeout_interruptible(i); | |
| 1200 | − udelay(torture_random(&rand) % 1000); | |
| 1197 | + torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand); | |
| 1201 | 1198 | rcu_torture_writer_state = RTWS_COND_SYNC; |
| 1202 | 1199 | cur_ops->cond_sync(gp_snap); |
| 1203 | 1200 | rcu_torture_pipe_update(old_rp); |
| @@ -1206,12 +1203,9 @@ rcu_torture_writer(void *arg) · 2 unmodified lines | ||
| 1206 | 1203 | rcu_torture_writer_state = RTWS_POLL_GET; |
| 1207 | 1204 | gp_snap = cur_ops->start_gp_poll(); |
| 1208 | 1205 | rcu_torture_writer_state = RTWS_POLL_WAIT; |
| 1209 | − while (!cur_ops->poll_gp_state(gp_snap)) { | |
| 1210 | − i = torture_random(&rand) % 16; | |
| 1211 | − if (i != 0) | |
| 1212 | − schedule_timeout_interruptible(i); | |
| 1213 | − udelay(torture_random(&rand) % 1000); | |
| 1214 | − } | |
| 1206 | + while (!cur_ops->poll_gp_state(gp_snap)) | |
| 1207 | + torture_hrtimeout_jiffies(torture_random(&rand) % 16, | |
| 1208 | + &rand); | |
| 1215 | 1209 | rcu_torture_pipe_update(old_rp); |
| 1216 | 1210 | break; |
| 1217 | 1211 | case RTWS_SYNC: |
| @@ -1290,7 +1284,6 @@ static int · 72 unmodified lines | ||
| 1290 | 1284 | rcu_torture_fakewriter(void *arg) |
| 1291 | 1285 | { |
| 1292 | 1286 | unsigned long gp_snap; |
| 1293 | − int i; | |
| 1294 | 1287 | DEFINE_TORTURE_RANDOM(rand); |
| 1295 | 1288 | |
| 1296 | 1289 | VERBOSE_TOROUT_STRING("rcu_torture_fakewriter task started"); |
| @@ -1311,19 +1304,14 @@ rcu_torture_fakewriter(void *arg) · 14 unmodified lines | ||
| 1311 | 1304 | break; |
| 1312 | 1305 | case RTWS_COND_GET: |
| 1313 | 1306 | gp_snap = cur_ops->get_gp_state(); |
| 1314 | − i = torture_random(&rand) % 16; | |
| 1315 | − if (i != 0) | |
| 1316 | − schedule_timeout_interruptible(i); | |
| 1317 | − udelay(torture_random(&rand) % 1000); | |
| 1307 | + torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand); | |
| 1318 | 1308 | cur_ops->cond_sync(gp_snap); |
| 1319 | 1309 | break; |
| 1320 | 1310 | case RTWS_POLL_GET: |
| 1321 | 1311 | gp_snap = cur_ops->start_gp_poll(); |
| 1322 | 1312 | while (!cur_ops->poll_gp_state(gp_snap)) { |
| 1323 | − i = torture_random(&rand) % 16; | |
| 1324 | − if (i != 0) | |
| 1325 | − schedule_timeout_interruptible(i); | |
| 1326 | − udelay(torture_random(&rand) % 1000); | |
| 1313 | + torture_hrtimeout_jiffies(torture_random(&rand) % 16, | |
| 1314 | + &rand); | |
| 1327 | 1315 | } |
| 1328 | 1316 | break; |
| 1329 | 1317 | case RTWS_SYNC: |