Commit 52db30ab authored by Paul E. McKenney's avatar Paul E. McKenney

rcu: Add stall-warning checks for RCU-tasks

This commit adds a ten-minute RCU-tasks stall warning.  The actual
time is controlled by the boot/sysfs parameter rcu_task_stall_timeout,
with values less than or equal to zero disabling the stall warnings.
The default value is ten minutes, which means that the tasks that have
not yet responded will get their stacks dumped every ten minutes, until
they pass through a voluntary context switch.
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent f1a828f5
...@@ -2982,6 +2982,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -2982,6 +2982,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
rcupdate.rcu_cpu_stall_timeout= [KNL] rcupdate.rcu_cpu_stall_timeout= [KNL]
Set timeout for RCU CPU stall warning messages. Set timeout for RCU CPU stall warning messages.
rcupdate.rcu_task_stall_timeout= [KNL]
Set timeout in jiffies for RCU task stall warning
messages. Disable with a value less than or equal
to zero.
rdinit= [KNL] rdinit= [KNL]
Format: <full_path> Format: <full_path>
Run specified binary instead of /init from the ramdisk, Run specified binary instead of /init from the ramdisk,
......
...@@ -371,7 +371,7 @@ static DEFINE_RAW_SPINLOCK(rcu_tasks_cbs_lock); ...@@ -371,7 +371,7 @@ static DEFINE_RAW_SPINLOCK(rcu_tasks_cbs_lock);
DEFINE_SRCU(tasks_rcu_exit_srcu); DEFINE_SRCU(tasks_rcu_exit_srcu);
/* Control stall timeouts. Disable with <= 0, otherwise jiffies till stall. */ /* Control stall timeouts. Disable with <= 0, otherwise jiffies till stall. */
static int rcu_task_stall_timeout __read_mostly = HZ * 60 * 3; static int rcu_task_stall_timeout __read_mostly = HZ * 60 * 10;
module_param(rcu_task_stall_timeout, int, 0644); module_param(rcu_task_stall_timeout, int, 0644);
/* Post an RCU-tasks callback. */ /* Post an RCU-tasks callback. */
...@@ -445,8 +445,9 @@ void rcu_barrier_tasks(void) ...@@ -445,8 +445,9 @@ void rcu_barrier_tasks(void)
} }
EXPORT_SYMBOL_GPL(rcu_barrier_tasks); EXPORT_SYMBOL_GPL(rcu_barrier_tasks);
/* See if the current task has stopped holding out, remove from list if so. */ /* See if tasks are still holding out, complain if so. */
static void check_holdout_task(struct task_struct *t) static void check_holdout_task(struct task_struct *t,
bool needreport, bool *firstreport)
{ {
if (!ACCESS_ONCE(t->rcu_tasks_holdout) || if (!ACCESS_ONCE(t->rcu_tasks_holdout) ||
t->rcu_tasks_nvcsw != ACCESS_ONCE(t->nvcsw) || t->rcu_tasks_nvcsw != ACCESS_ONCE(t->nvcsw) ||
...@@ -454,7 +455,15 @@ static void check_holdout_task(struct task_struct *t) ...@@ -454,7 +455,15 @@ static void check_holdout_task(struct task_struct *t)
ACCESS_ONCE(t->rcu_tasks_holdout) = false; ACCESS_ONCE(t->rcu_tasks_holdout) = false;
list_del_rcu(&t->rcu_tasks_holdout_list); list_del_rcu(&t->rcu_tasks_holdout_list);
put_task_struct(t); put_task_struct(t);
return;
} }
if (!needreport)
return;
if (*firstreport) {
pr_err("INFO: rcu_tasks detected stalls on tasks:\n");
*firstreport = false;
}
sched_show_task(t);
} }
/* RCU-tasks kthread that detects grace periods and invokes callbacks. */ /* RCU-tasks kthread that detects grace periods and invokes callbacks. */
...@@ -462,6 +471,7 @@ static int __noreturn rcu_tasks_kthread(void *arg) ...@@ -462,6 +471,7 @@ static int __noreturn rcu_tasks_kthread(void *arg)
{ {
unsigned long flags; unsigned long flags;
struct task_struct *g, *t; struct task_struct *g, *t;
unsigned long lastreport;
struct rcu_head *list; struct rcu_head *list;
struct rcu_head *next; struct rcu_head *next;
LIST_HEAD(rcu_tasks_holdouts); LIST_HEAD(rcu_tasks_holdouts);
...@@ -540,13 +550,24 @@ static int __noreturn rcu_tasks_kthread(void *arg) ...@@ -540,13 +550,24 @@ static int __noreturn rcu_tasks_kthread(void *arg)
* of holdout tasks, removing any that are no longer * of holdout tasks, removing any that are no longer
* holdouts. When the list is empty, we are done. * holdouts. When the list is empty, we are done.
*/ */
lastreport = jiffies;
while (!list_empty(&rcu_tasks_holdouts)) { while (!list_empty(&rcu_tasks_holdouts)) {
bool firstreport;
bool needreport;
int rtst;
schedule_timeout_interruptible(HZ); schedule_timeout_interruptible(HZ);
rtst = ACCESS_ONCE(rcu_task_stall_timeout);
needreport = rtst > 0 &&
time_after(jiffies, lastreport + rtst);
if (needreport)
lastreport = jiffies;
firstreport = true;
WARN_ON(signal_pending(current)); WARN_ON(signal_pending(current));
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(t, &rcu_tasks_holdouts, list_for_each_entry_rcu(t, &rcu_tasks_holdouts,
rcu_tasks_holdout_list) rcu_tasks_holdout_list)
check_holdout_task(t); check_holdout_task(t, needreport, &firstreport);
rcu_read_unlock(); rcu_read_unlock();
} }
......
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