提交 ad474cac 编写于 作者: O Oleg Nesterov 提交者: Ingo Molnar

fix for account_group_exec_runtime(), make sure ->signal can't be freed under rq->lock

Impact: fix hang/crash on ia64 under high load

This is ugly, but the simplest patch by far.

Unlike other similar routines, account_group_exec_runtime() could be
called "implicitly" from within scheduler after exit_notify(). This
means we can race with the parent doing release_task(), we can't just
check ->signal != NULL.

Change __exit_signal() to do spin_unlock_wait(&task_rq(tsk)->lock)
before __cleanup_signal() to make sure ->signal can't be freed under
task_rq(tsk)->lock. Note that task_rq_unlock_wait() doesn't care
about the case when tsk changes cpu/rq under us, this should be OK.

Thanks to Ingo who nacked my previous buggy patch.
Signed-off-by: NOleg Nesterov <oleg@redhat.com>
Acked-by: NPeter Zijlstra <peterz@infradead.org>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Reported-by: NDoug Chapman <doug.chapman@hp.com>
上级 5ac5c4d6
...@@ -247,6 +247,7 @@ extern void init_idle(struct task_struct *idle, int cpu); ...@@ -247,6 +247,7 @@ extern void init_idle(struct task_struct *idle, int cpu);
extern void init_idle_bootup_task(struct task_struct *idle); extern void init_idle_bootup_task(struct task_struct *idle);
extern int runqueue_is_locked(void); extern int runqueue_is_locked(void);
extern void task_rq_unlock_wait(struct task_struct *p);
extern cpumask_t nohz_cpu_mask; extern cpumask_t nohz_cpu_mask;
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ) #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
......
...@@ -141,6 +141,11 @@ static void __exit_signal(struct task_struct *tsk) ...@@ -141,6 +141,11 @@ static void __exit_signal(struct task_struct *tsk)
if (sig) { if (sig) {
flush_sigqueue(&sig->shared_pending); flush_sigqueue(&sig->shared_pending);
taskstats_tgid_free(sig); taskstats_tgid_free(sig);
/*
* Make sure ->signal can't go away under rq->lock,
* see account_group_exec_runtime().
*/
task_rq_unlock_wait(tsk);
__cleanup_signal(sig); __cleanup_signal(sig);
} }
} }
......
...@@ -969,6 +969,14 @@ static struct rq *task_rq_lock(struct task_struct *p, unsigned long *flags) ...@@ -969,6 +969,14 @@ static struct rq *task_rq_lock(struct task_struct *p, unsigned long *flags)
} }
} }
void task_rq_unlock_wait(struct task_struct *p)
{
struct rq *rq = task_rq(p);
smp_mb(); /* spin-unlock-wait is not a full memory barrier */
spin_unlock_wait(&rq->lock);
}
static void __task_rq_unlock(struct rq *rq) static void __task_rq_unlock(struct rq *rq)
__releases(rq->lock) __releases(rq->lock)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册