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
11941194 case RTWS_COND_GET:
11951195 rcu_torture_writer_state = RTWS_COND_GET;
11961196 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);
12011198 rcu_torture_writer_state = RTWS_COND_SYNC;
12021199 cur_ops->cond_sync(gp_snap);
12031200 rcu_torture_pipe_update(old_rp);
@@ -1206,12 +1203,9 @@ rcu_torture_writer(void *arg) · 2 unmodified lines
12061203 rcu_torture_writer_state = RTWS_POLL_GET;
12071204 gp_snap = cur_ops->start_gp_poll();
12081205 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);
12151209 rcu_torture_pipe_update(old_rp);
12161210 break;
12171211 case RTWS_SYNC:
@@ -1290,7 +1284,6 @@ static int · 72 unmodified lines
12901284 rcu_torture_fakewriter(void *arg)
12911285 {
12921286 unsigned long gp_snap;
1293− int i;
12941287 DEFINE_TORTURE_RANDOM(rand);
12951288
12961289 VERBOSE_TOROUT_STRING("rcu_torture_fakewriter task started");
@@ -1311,19 +1304,14 @@ rcu_torture_fakewriter(void *arg) · 14 unmodified lines
13111304 break;
13121305 case RTWS_COND_GET:
13131306 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);
13181308 cur_ops->cond_sync(gp_snap);
13191309 break;
13201310 case RTWS_POLL_GET:
13211311 gp_snap = cur_ops->start_gp_poll();
13221312 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);
13271315 }
13281316 break;
13291317 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