Currently, the units of ->init_fract are milliseconds while those of ->gp_sleep are jiffies. For consistency with each other and with the argument of schedule_timeout_idle(), this commit changes the units of ->init_fract to jiffies. This change does affect the backoff algorithm, but only on systems where HZ is not 1000, and even there the change makes more sense, given that the current setup would "back off" to the same number of jiffies repeatedly. In contrast, with this change, the number of jiffies waited increases on each pass through the loop in the rcu_tasks_wait_gp() function.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -335,8 +335,6 @@ static void rcu_tasks_wait_gp(struct rcu_tasks *rtp) · 334 unmodified lines | |||
| 335 | 335 | ||
| 336 | // Start off with initial wait and slowly back off to 1 HZ wait. | 336 | // Start off with initial wait and slowly back off to 1 HZ wait. |
| 337 | fract = rtp->init_fract; | 337 | fract = rtp->init_fract; |
| 338 | if (fract > HZ) | ||
| 339 | fract = HZ; | ||
| 340 | 338 | ||
| 341 | while (!list_empty(&holdouts)) { | 339 | while (!list_empty(&holdouts)) { |
| 342 | bool firstreport; | 340 | bool firstreport; |
| @@ -345,10 +343,10 @@ static void rcu_tasks_wait_gp(struct rcu_tasks *rtp) · 2 unmodified lines | |||
| 345 | 343 | ||
| 346 | /* Slowly back off waiting for holdouts */ | 344 | /* Slowly back off waiting for holdouts */ |
| 347 | set_tasks_gp_state(rtp, RTGS_WAIT_SCAN_HOLDOUTS); | 345 | set_tasks_gp_state(rtp, RTGS_WAIT_SCAN_HOLDOUTS); |
| 348 | schedule_timeout_idle(HZ/fract); | 346 | schedule_timeout_idle(fract); |
| 349 | 347 | ||
| 350 | if (fract > 1) | 348 | if (fract < HZ) |
| 351 | fract--; | 349 | fract++; |
| 352 | 350 | ||
| 353 | rtst = READ_ONCE(rcu_task_stall_timeout); | 351 | rtst = READ_ONCE(rcu_task_stall_timeout); |
| 354 | needreport = rtst > 0 && time_after(jiffies, lastreport + rtst); | 352 | needreport = rtst > 0 && time_after(jiffies, lastreport + rtst); |
| @@ -557,7 +555,7 @@ EXPORT_SYMBOL_GPL(rcu_barrier_tasks); · 202 unmodified lines | |||
| 557 | static int __init rcu_spawn_tasks_kthread(void) | 555 | static int __init rcu_spawn_tasks_kthread(void) |
| 558 | { | 556 | { |
| 559 | rcu_tasks.gp_sleep = HZ / 10; | 557 | rcu_tasks.gp_sleep = HZ / 10; |
| 560 | rcu_tasks.init_fract = 10; | 558 | rcu_tasks.init_fract = HZ / 10; |
| 561 | rcu_tasks.pregp_func = rcu_tasks_pregp_step; | 559 | rcu_tasks.pregp_func = rcu_tasks_pregp_step; |
| 562 | rcu_tasks.pertask_func = rcu_tasks_pertask; | 560 | rcu_tasks.pertask_func = rcu_tasks_pertask; |
| 563 | rcu_tasks.postscan_func = rcu_tasks_postscan; | 561 | rcu_tasks.postscan_func = rcu_tasks_postscan; |
| @@ -1178,12 +1176,12 @@ static int __init rcu_spawn_tasks_trace_kthread(void) · 614 unmodified lines | |||
| 1178 | { | 1176 | { |
| 1179 | if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB)) { | 1177 | if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB)) { |
| 1180 | rcu_tasks_trace.gp_sleep = HZ / 10; | 1178 | rcu_tasks_trace.gp_sleep = HZ / 10; |
| 1181 | rcu_tasks_trace.init_fract = 10; | 1179 | rcu_tasks_trace.init_fract = HZ / 10; |
| 1182 | } else { | 1180 | } else { |
| 1183 | rcu_tasks_trace.gp_sleep = HZ / 200; | 1181 | rcu_tasks_trace.gp_sleep = HZ / 200; |
| 1184 | if (rcu_tasks_trace.gp_sleep <= 0) | 1182 | if (rcu_tasks_trace.gp_sleep <= 0) |
| 1185 | rcu_tasks_trace.gp_sleep = 1; | 1183 | rcu_tasks_trace.gp_sleep = 1; |
| 1186 | rcu_tasks_trace.init_fract = HZ / 5; | 1184 | rcu_tasks_trace.init_fract = HZ / 200; |
| 1187 | if (rcu_tasks_trace.init_fract <= 0) | 1185 | if (rcu_tasks_trace.init_fract <= 0) |
| 1188 | rcu_tasks_trace.init_fract = 1; | 1186 | rcu_tasks_trace.init_fract = 1; |
| 1189 | } | 1187 | } |