This commit adds a grace-period count and a count of IPIs sent since boot, which is printed in response to rcutorture writer stalls and at the end of rcutorture testing. These counts will be used to evaluate various schemes to reduce the number of IPIs sent.
Unified · Split
| @@ -30,6 +30,8 @@ typedef void (*postgp_func_t)(struct rcu_tasks *rtp); · 29 unmodified lines | |||
| 30 | * @gp_state: Grace period's most recent state transition (debugging). | 30 | * @gp_state: Grace period's most recent state transition (debugging). |
| 31 | * @gp_jiffies: Time of last @gp_state transition. | 31 | * @gp_jiffies: Time of last @gp_state transition. |
| 32 | * @gp_start: Most recent grace-period start in jiffies. | 32 | * @gp_start: Most recent grace-period start in jiffies. |
| 33 | * @n_gps: Number of grace periods completed since boot. | ||
| 34 | * @n_ipis: Number of IPIs sent to encourage grace periods to end. | ||
| 33 | * @pregp_func: This flavor's pre-grace-period function (optional). | 35 | * @pregp_func: This flavor's pre-grace-period function (optional). |
| 34 | * @pertask_func: This flavor's per-task scan function (optional). | 36 | * @pertask_func: This flavor's per-task scan function (optional). |
| 35 | * @postscan_func: This flavor's post-task scan function (optional). | 37 | * @postscan_func: This flavor's post-task scan function (optional). |
| @@ -47,6 +49,8 @@ struct rcu_tasks { · 11 unmodified lines | |||
| 47 | int gp_state; | 49 | int gp_state; |
| 48 | unsigned long gp_jiffies; | 50 | unsigned long gp_jiffies; |
| 49 | unsigned long gp_start; | 51 | unsigned long gp_start; |
| 52 | unsigned long n_gps; | ||
| 53 | unsigned long n_ipis; | ||
| 50 | struct task_struct *kthread_ptr; | 54 | struct task_struct *kthread_ptr; |
| 51 | rcu_tasks_gp_func_t gp_func; | 55 | rcu_tasks_gp_func_t gp_func; |
| 52 | pregp_func_t pregp_func; | 56 | pregp_func_t pregp_func; |
| @@ -208,6 +212,7 @@ static int __noreturn rcu_tasks_kthread(void *arg) · 155 unmodified lines | |||
| 208 | set_tasks_gp_state(rtp, RTGS_WAIT_GP); | 212 | set_tasks_gp_state(rtp, RTGS_WAIT_GP); |
| 209 | rtp->gp_start = jiffies; | 213 | rtp->gp_start = jiffies; |
| 210 | rtp->gp_func(rtp); | 214 | rtp->gp_func(rtp); |
| 215 | rtp->n_gps++; | ||
| 211 | 216 | ||
| 212 | /* Invoke the callbacks. */ | 217 | /* Invoke the callbacks. */ |
| 213 | set_tasks_gp_state(rtp, RTGS_INVOKE_CBS); | 218 | set_tasks_gp_state(rtp, RTGS_INVOKE_CBS); |
| @@ -285,11 +290,12 @@ static void __init rcu_tasks_bootup_oddness(void) · 71 unmodified lines | |||
| 285 | /* Dump out rcutorture-relevant state common to all RCU-tasks flavors. */ | 290 | /* Dump out rcutorture-relevant state common to all RCU-tasks flavors. */ |
| 286 | static void show_rcu_tasks_generic_gp_kthread(struct rcu_tasks *rtp, char *s) | 291 | static void show_rcu_tasks_generic_gp_kthread(struct rcu_tasks *rtp, char *s) |
| 287 | { | 292 | { |
| 288 | pr_info("%s: %s(%d) since %lu %c%c %s\n", | 293 | pr_info("%s: %s(%d) since %lu g:%lu i:%lu %c%c %s\n", |
| 289 | rtp->kname, | 294 | rtp->kname, |
| 290 | tasks_gp_state_getname(rtp), | 295 | tasks_gp_state_getname(rtp), |
| 291 | data_race(rtp->gp_state), | 296 | data_race(rtp->gp_state), |
| 292 | jiffies - data_race(rtp->gp_jiffies), | 297 | jiffies - data_race(rtp->gp_jiffies), |
| 298 | data_race(rtp->n_gps), data_race(rtp->n_ipis), | ||
| 293 | ".k"[!!data_race(rtp->kthread_ptr)], | 299 | ".k"[!!data_race(rtp->kthread_ptr)], |
| 294 | ".C"[!!data_race(rtp->cbs_head)], | 300 | ".C"[!!data_race(rtp->cbs_head)], |
| 295 | s); | 301 | s); |
| @@ -592,6 +598,7 @@ static void rcu_tasks_be_rude(struct work_struct *work) · 296 unmodified lines | |||
| 592 | // Wait for one rude RCU-tasks grace period. | 598 | // Wait for one rude RCU-tasks grace period. |
| 593 | static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp) | 599 | static void rcu_tasks_rude_wait_gp(struct rcu_tasks *rtp) |
| 594 | { | 600 | { |
| 601 | rtp->n_ipis += cpumask_weight(cpu_online_mask); | ||
| 595 | schedule_on_each_cpu(rcu_tasks_be_rude); | 602 | schedule_on_each_cpu(rcu_tasks_be_rude); |
| 596 | } | 603 | } |
| 597 | 604 | ||
| @@ -856,6 +863,7 @@ static void trc_wait_for_one_reader(struct task_struct *t, · 258 unmodified lines | |||
| 856 | atomic_inc(&trc_n_readers_need_end); | 863 | atomic_inc(&trc_n_readers_need_end); |
| 857 | per_cpu(trc_ipi_to_cpu, cpu) = true; | 864 | per_cpu(trc_ipi_to_cpu, cpu) = true; |
| 858 | t->trc_ipi_to_cpu = cpu; | 865 | t->trc_ipi_to_cpu = cpu; |
| 866 | rcu_tasks_trace.n_ipis++; | ||
| 859 | if (smp_call_function_single(cpu, | 867 | if (smp_call_function_single(cpu, |
| 860 | trc_read_check_handler, t, 0)) { | 868 | trc_read_check_handler, t, 0)) { |
| 861 | // Just in case there is some other reason for | 869 | // Just in case there is some other reason for |