History

rcutorture: Use torture_hrtimeout_jiffies() to avoid busy-waits

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.

Paul E. McKenney committed 5 years ago

Commit ea31fd91 parent ae19aaa1 file · +7 −19Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/rcu/rcutorture.c+7−19
@@ -1194,10 +1194,7 @@ rcu_torture_writer(void *arg) · 1193 unmodified lines
1194 case RTWS_COND_GET:1194 case RTWS_COND_GET:
1195 rcu_torture_writer_state = RTWS_COND_GET;1195 rcu_torture_writer_state = RTWS_COND_GET;
1196 gp_snap = cur_ops->get_gp_state();1196 gp_snap = cur_ops->get_gp_state();
1197 i = torture_random(&rand) % 16;1197 torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand);
1198 if (i != 0)
1199 schedule_timeout_interruptible(i);
1200 udelay(torture_random(&rand) % 1000);
1201 rcu_torture_writer_state = RTWS_COND_SYNC;1198 rcu_torture_writer_state = RTWS_COND_SYNC;
1202 cur_ops->cond_sync(gp_snap);1199 cur_ops->cond_sync(gp_snap);
1203 rcu_torture_pipe_update(old_rp);1200 rcu_torture_pipe_update(old_rp);
@@ -1206,12 +1203,9 @@ rcu_torture_writer(void *arg) · 2 unmodified lines
1206 rcu_torture_writer_state = RTWS_POLL_GET;1203 rcu_torture_writer_state = RTWS_POLL_GET;
1207 gp_snap = cur_ops->start_gp_poll();1204 gp_snap = cur_ops->start_gp_poll();
1208 rcu_torture_writer_state = RTWS_POLL_WAIT;1205 rcu_torture_writer_state = RTWS_POLL_WAIT;
1209 while (!cur_ops->poll_gp_state(gp_snap)) {1206 while (!cur_ops->poll_gp_state(gp_snap))
1210 i = torture_random(&rand) % 16;1207 torture_hrtimeout_jiffies(torture_random(&rand) % 16,
1211 if (i != 0)1208 &rand);
1212 schedule_timeout_interruptible(i);
1213 udelay(torture_random(&rand) % 1000);
1214 }
1215 rcu_torture_pipe_update(old_rp);1209 rcu_torture_pipe_update(old_rp);
1216 break;1210 break;
1217 case RTWS_SYNC:1211 case RTWS_SYNC:
@@ -1290,7 +1284,6 @@ static int · 72 unmodified lines
1290rcu_torture_fakewriter(void *arg)1284rcu_torture_fakewriter(void *arg)
1291{1285{
1292 unsigned long gp_snap;1286 unsigned long gp_snap;
1293 int i;
1294 DEFINE_TORTURE_RANDOM(rand);1287 DEFINE_TORTURE_RANDOM(rand);
1295 1288
1296 VERBOSE_TOROUT_STRING("rcu_torture_fakewriter task started");1289 VERBOSE_TOROUT_STRING("rcu_torture_fakewriter task started");
@@ -1311,19 +1304,14 @@ rcu_torture_fakewriter(void *arg) · 14 unmodified lines
1311 break;1304 break;
1312 case RTWS_COND_GET:1305 case RTWS_COND_GET:
1313 gp_snap = cur_ops->get_gp_state();1306 gp_snap = cur_ops->get_gp_state();
1314 i = torture_random(&rand) % 16;1307 torture_hrtimeout_jiffies(torture_random(&rand) % 16, &rand);
1315 if (i != 0)
1316 schedule_timeout_interruptible(i);
1317 udelay(torture_random(&rand) % 1000);
1318 cur_ops->cond_sync(gp_snap);1308 cur_ops->cond_sync(gp_snap);
1319 break;1309 break;
1320 case RTWS_POLL_GET:1310 case RTWS_POLL_GET:
1321 gp_snap = cur_ops->start_gp_poll();1311 gp_snap = cur_ops->start_gp_poll();
1322 while (!cur_ops->poll_gp_state(gp_snap)) {1312 while (!cur_ops->poll_gp_state(gp_snap)) {
1323 i = torture_random(&rand) % 16;1313 torture_hrtimeout_jiffies(torture_random(&rand) % 16,
1324 if (i != 0)1314 &rand);
1325 schedule_timeout_interruptible(i);
1326 udelay(torture_random(&rand) % 1000);
1327 }1315 }
1328 break;1316 break;
1329 case RTWS_SYNC:1317 case RTWS_SYNC:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t