Commit fd897573 authored by Paul E. McKenney's avatar Paul E. McKenney

rcu: Improve diagnostics for failed RCU grace-period start

If a grace period fails to start (for example, because you commented
out the last two lines of rcu_accelerate_cbs_unlocked()), rcu_core()
will invoke rcu_check_gp_start_stall(), which will notice and complain.
However, this complaint is lacking crucial debugging information such
as when the last wakeup executed and what the value of ->gp_seq was at
that time.  This commit therefore removes the current pr_alert() from
rcu_check_gp_start_stall(), instead invoking show_rcu_gp_kthreads(),
which has been updated to print the needed information, which is collected
by rcu_gp_kthread_wake().
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
parent a9fefdb2
...@@ -512,6 +512,14 @@ void rcu_force_quiescent_state(void) ...@@ -512,6 +512,14 @@ void rcu_force_quiescent_state(void)
} }
EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); EXPORT_SYMBOL_GPL(rcu_force_quiescent_state);
/*
* Return the root node of the rcu_state structure.
*/
static struct rcu_node *rcu_get_root(void)
{
return &rcu_state.node[0];
}
/* /*
* Convert a ->gp_state value to a character string. * Convert a ->gp_state value to a character string.
*/ */
...@@ -529,19 +537,30 @@ void show_rcu_gp_kthreads(void) ...@@ -529,19 +537,30 @@ void show_rcu_gp_kthreads(void)
{ {
int cpu; int cpu;
unsigned long j; unsigned long j;
unsigned long ja;
unsigned long jr;
unsigned long jw;
struct rcu_data *rdp; struct rcu_data *rdp;
struct rcu_node *rnp; struct rcu_node *rnp;
j = jiffies - READ_ONCE(rcu_state.gp_activity); j = jiffies;
pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %ld\n", ja = j - READ_ONCE(rcu_state.gp_activity);
jr = j - READ_ONCE(rcu_state.gp_req_activity);
jw = j - READ_ONCE(rcu_state.gp_wake_time);
pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n",
rcu_state.name, gp_state_getname(rcu_state.gp_state), rcu_state.name, gp_state_getname(rcu_state.gp_state),
rcu_state.gp_state, rcu_state.gp_kthread->state, j); rcu_state.gp_state,
rcu_state.gp_kthread ? rcu_state.gp_kthread->state : 0x1ffffL,
ja, jr, jw, (long)READ_ONCE(rcu_state.gp_wake_seq),
(long)READ_ONCE(rcu_state.gp_seq),
(long)READ_ONCE(rcu_get_root()->gp_seq_needed),
READ_ONCE(rcu_state.gp_flags));
rcu_for_each_node_breadth_first(rnp) { rcu_for_each_node_breadth_first(rnp) {
if (ULONG_CMP_GE(rcu_state.gp_seq, rnp->gp_seq_needed)) if (ULONG_CMP_GE(rcu_state.gp_seq, rnp->gp_seq_needed))
continue; continue;
pr_info("\trcu_node %d:%d ->gp_seq %lu ->gp_seq_needed %lu\n", pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld\n",
rnp->grplo, rnp->grphi, rnp->gp_seq, rnp->grplo, rnp->grphi, (long)rnp->gp_seq,
rnp->gp_seq_needed); (long)rnp->gp_seq_needed);
if (!rcu_is_leaf_node(rnp)) if (!rcu_is_leaf_node(rnp))
continue; continue;
for_each_leaf_node_possible_cpu(rnp, cpu) { for_each_leaf_node_possible_cpu(rnp, cpu) {
...@@ -550,8 +569,8 @@ void show_rcu_gp_kthreads(void) ...@@ -550,8 +569,8 @@ void show_rcu_gp_kthreads(void)
ULONG_CMP_GE(rcu_state.gp_seq, ULONG_CMP_GE(rcu_state.gp_seq,
rdp->gp_seq_needed)) rdp->gp_seq_needed))
continue; continue;
pr_info("\tcpu %d ->gp_seq_needed %lu\n", pr_info("\tcpu %d ->gp_seq_needed %ld\n",
cpu, rdp->gp_seq_needed); cpu, (long)rdp->gp_seq_needed);
} }
} }
/* sched_show_task(rcu_state.gp_kthread); */ /* sched_show_task(rcu_state.gp_kthread); */
...@@ -577,14 +596,6 @@ void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags, ...@@ -577,14 +596,6 @@ void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
} }
EXPORT_SYMBOL_GPL(rcutorture_get_gp_data); EXPORT_SYMBOL_GPL(rcutorture_get_gp_data);
/*
* Return the root node of the rcu_state structure.
*/
static struct rcu_node *rcu_get_root(void)
{
return &rcu_state.node[0];
}
/* /*
* Enter an RCU extended quiescent state, which can be either the * Enter an RCU extended quiescent state, which can be either the
* idle loop or adaptive-tickless usermode execution. * idle loop or adaptive-tickless usermode execution.
...@@ -1560,7 +1571,8 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp) ...@@ -1560,7 +1571,8 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp)
* Awaken the grace-period kthread. Don't do a self-awaken, and don't * Awaken the grace-period kthread. Don't do a self-awaken, and don't
* bother awakening when there is nothing for the grace-period kthread * bother awakening when there is nothing for the grace-period kthread
* to do (as in several CPUs raced to awaken, and we lost), and finally * to do (as in several CPUs raced to awaken, and we lost), and finally
* don't try to awaken a kthread that has not yet been created. * don't try to awaken a kthread that has not yet been created. If
* all those checks are passed, track some debug information and awaken.
*/ */
static void rcu_gp_kthread_wake(void) static void rcu_gp_kthread_wake(void)
{ {
...@@ -1568,6 +1580,8 @@ static void rcu_gp_kthread_wake(void) ...@@ -1568,6 +1580,8 @@ static void rcu_gp_kthread_wake(void)
!READ_ONCE(rcu_state.gp_flags) || !READ_ONCE(rcu_state.gp_flags) ||
!rcu_state.gp_kthread) !rcu_state.gp_kthread)
return; return;
WRITE_ONCE(rcu_state.gp_wake_time, jiffies);
WRITE_ONCE(rcu_state.gp_wake_seq, READ_ONCE(rcu_state.gp_seq));
swake_up_one(&rcu_state.gp_wq); swake_up_one(&rcu_state.gp_wq);
} }
...@@ -2657,16 +2671,11 @@ rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp, ...@@ -2657,16 +2671,11 @@ rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp,
raw_spin_unlock_irqrestore_rcu_node(rnp, flags); raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
return; return;
} }
pr_alert("%s: g%ld->%ld gar:%lu ga:%lu f%#x gs:%d %s->state:%#lx\n",
__func__, (long)READ_ONCE(rcu_state.gp_seq),
(long)READ_ONCE(rnp_root->gp_seq_needed),
j - rcu_state.gp_req_activity, j - rcu_state.gp_activity,
rcu_state.gp_flags, rcu_state.gp_state, rcu_state.name,
rcu_state.gp_kthread ? rcu_state.gp_kthread->state : 0x1ffffL);
WARN_ON(1); WARN_ON(1);
if (rnp_root != rnp) if (rnp_root != rnp)
raw_spin_unlock_rcu_node(rnp_root); raw_spin_unlock_rcu_node(rnp_root);
raw_spin_unlock_irqrestore_rcu_node(rnp, flags); raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
show_rcu_gp_kthreads();
} }
/* /*
......
...@@ -309,6 +309,8 @@ struct rcu_state { ...@@ -309,6 +309,8 @@ struct rcu_state {
struct swait_queue_head gp_wq; /* Where GP task waits. */ struct swait_queue_head gp_wq; /* Where GP task waits. */
short gp_flags; /* Commands for GP task. */ short gp_flags; /* Commands for GP task. */
short gp_state; /* GP kthread sleep state. */ short gp_state; /* GP kthread sleep state. */
unsigned long gp_wake_time; /* Last GP kthread wake. */
unsigned long gp_wake_seq; /* ->gp_seq at ^^^. */
/* End of fields guarded by root rcu_node's lock. */ /* End of fields guarded by root rcu_node's lock. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment