Skip to content

Commit afea227

Browse files
committed
rcutorture: Export RCU grace-period kthread wait state to rcutorture
This commit allows rcutorture to print additional state for the RCU grace-period kthreads in cases where RCU seems reluctant to start a new grace period. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent 945fa9c commit afea227

5 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎include/linux/rcutiny.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ static inline void rcu_sched_force_quiescent_state(void)
119119
{
120120
}
121121

122+
static inline void show_rcu_gp_kthreads(void)
123+
{
124+
}
125+
122126
static inline void rcu_cpu_stall_reset(void)
123127
{
124128
}

‎include/linux/rcutree.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern unsigned long rcutorture_vernum;
8484
long rcu_batches_completed(void);
8585
long rcu_batches_completed_bh(void);
8686
long rcu_batches_completed_sched(void);
87+
void show_rcu_gp_kthreads(void);
8788

8889
void rcu_force_quiescent_state(void);
8990
void rcu_bh_force_quiescent_state(void);

‎kernel/rcu/rcutorture.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ rcu_torture_printk(char *page)
10341034
"??? Writer stall state %d g%lu c%lu f%#x\n",
10351035
rcu_torture_writer_state,
10361036
gpnum, completed, flags);
1037+
show_rcu_gp_kthreads();
10371038
rcutorture_trace_dump();
10381039
}
10391040
rtcv_snap = rcu_torture_current_version;

‎kernel/rcu/tree.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,21 @@ void rcu_bh_force_quiescent_state(void)
279279
}
280280
EXPORT_SYMBOL_GPL(rcu_bh_force_quiescent_state);
281281

282+
/*
283+
* Show the state of the grace-period kthreads.
284+
*/
285+
void show_rcu_gp_kthreads(void)
286+
{
287+
struct rcu_state *rsp;
288+
289+
for_each_rcu_flavor(rsp) {
290+
pr_info("%s: wait state: %d ->state: %#lx\n",
291+
rsp->name, rsp->gp_state, rsp->gp_kthread->state);
292+
/* sched_show_task(rsp->gp_kthread); */
293+
}
294+
}
295+
EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads);
296+
282297
/*
283298
* Record the number of times rcutorture tests have been initiated and
284299
* terminated. This information allows the debugfs tracing stats to be
@@ -1626,6 +1641,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
16261641
trace_rcu_grace_period(rsp->name,
16271642
ACCESS_ONCE(rsp->gpnum),
16281643
TPS("reqwait"));
1644+
rsp->gp_state = RCU_GP_WAIT_GPS;
16291645
wait_event_interruptible(rsp->gp_wq,
16301646
ACCESS_ONCE(rsp->gp_flags) &
16311647
RCU_GP_FLAG_INIT);
@@ -1653,6 +1669,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
16531669
trace_rcu_grace_period(rsp->name,
16541670
ACCESS_ONCE(rsp->gpnum),
16551671
TPS("fqswait"));
1672+
rsp->gp_state = RCU_GP_WAIT_FQS;
16561673
ret = wait_event_interruptible_timeout(rsp->gp_wq,
16571674
((gf = ACCESS_ONCE(rsp->gp_flags)) &
16581675
RCU_GP_FLAG_FQS) ||

‎kernel/rcu/tree.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ struct rcu_state {
406406
unsigned long completed; /* # of last completed gp. */
407407
struct task_struct *gp_kthread; /* Task for grace periods. */
408408
wait_queue_head_t gp_wq; /* Where GP task waits. */
409-
int gp_flags; /* Commands for GP task. */
409+
short gp_flags; /* Commands for GP task. */
410+
short gp_state; /* GP kthread sleep state. */
410411

411412
/* End of fields guarded by root rcu_node's lock. */
412413

@@ -469,6 +470,11 @@ struct rcu_state {
469470
#define RCU_GP_FLAG_INIT 0x1 /* Need grace-period initialization. */
470471
#define RCU_GP_FLAG_FQS 0x2 /* Need grace-period quiescent-state forcing. */
471472

473+
/* Values for rcu_state structure's gp_flags field. */
474+
#define RCU_GP_WAIT_INIT 0 /* Initial state. */
475+
#define RCU_GP_WAIT_GPS 1 /* Wait for grace-period start. */
476+
#define RCU_GP_WAIT_FQS 2 /* Wait for force-quiescent-state time. */
477+
472478
extern struct list_head rcu_struct_flavors;
473479

474480
/* Sequence through rcu_state structures for each RCU flavor. */

0 commit comments

Comments
 (0)