From: Oleg Nesterov <oleg@tv-sign.ru>
To: Gautham R Shenoy <ego@in.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Srivatsa Vaddagiri <vatsa@in.ibm.com>,
linux-kernel@vger.kernel.org,
Dipankar Sarma <dipankar@in.ibm.com>,
Paul E McKenney <paulmck@us.ibm.com>
Subject: Re: Cpu-Hotplug and Real-Time
Date: Tue, 7 Aug 2007 19:13:36 +0400 [thread overview]
Message-ID: <20070807151336.GA507@tv-sign.ru> (raw)
In-Reply-To: <20070807131216.GA20424@in.ibm.com>
On 08/07, Gautham R Shenoy wrote:
>
> After some debugging, I saw that the hang occured because
> the high prio process was stuck in a loop doing yield() inside
> wait_task_inactive(). Description follows:
>
> Say a high-prio task (A) does a kthread_create(B),
> followed by a kthread_bind(B, cpu1). At this moment,
> only cpu0 is online.
>
> Now, immediately after being created, B would
> do a
> complete(&create->started) [kernel/kthread.c: kthread()],
> before scheduling itself out.
>
> This complete() will wake up kthreadd, which had spawned B.
> It is possible that during the wakeup, kthreadd might preempt B.
> Thus, B is still on the runqueue, and not yet called schedule().
>
> kthreadd, will inturn do a
> complete(&create->done); [kernel/kthread.c: create_kthread()]
> which will wake up the thread which had called kthread_create().
> In our case it's task A, which will run immediately, since its priority
> is higher.
>
> A will now call kthread_bind(B, cpu1).
> kthread_bind(), calls wait_task_inactive(B), to ensures that
> B has scheduled itself out.
>
> B is still on the runqueue, so A calls yield() in wait_task_inactive().
> But since A is the task with the highest prio, scheduler schedules it
> back again.
>
> Thus B never gets to run to schedule itself out.
> A loops waiting for B to schedule out leading to system hang.
As for kthread_bind(), I think wait_task_inactive+set_task_cpu is just
an optimization, and easy to "fix":
--- kernel/kthread.c 2007-07-28 16:58:17.000000000 +0400
+++ /proc/self/fd/0 2007-08-07 18:56:54.248073547 +0400
@@ -166,10 +166,7 @@ void kthread_bind(struct task_struct *k,
WARN_ON(1);
return;
}
- /* Must have done schedule() in kthread() before we set_task_cpu */
- wait_task_inactive(k);
- set_task_cpu(k, cpu);
- k->cpus_allowed = cpumask_of_cpu(cpu);
+ set_cpus_allowed(current, cpumask_of_cpu(cpu));
}
EXPORT_SYMBOL(kthread_bind);
But I think we have another case. An RT ptracer can share the same CPU
with ptracee. The latter sets TASK_STOPPED, unlocks ->siglock, and takes
a preemption. Ptracer does ptrace_check_attach(), sees TASK_STOPPED, and
yields in wait_task_inactive.
Oleg.
next prev parent reply other threads:[~2007-08-07 15:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-07 13:12 Cpu-Hotplug and Real-Time Gautham R Shenoy
2007-08-07 15:13 ` Oleg Nesterov [this message]
2007-08-07 17:33 ` Venki Pallipadi
2007-08-07 18:36 ` Oleg Nesterov
2007-08-09 17:03 ` rt ptracer can monopolize CPU (was: Cpu-Hotplug and Real-Time) Oleg Nesterov
2007-08-16 12:06 ` Gautham R Shenoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070807151336.GA507@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=dipankar@in.ibm.com \
--cc=ego@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@us.ibm.com \
--cc=vatsa@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.