From: Yong Zhang <yong.zhang0@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-rt-users@vger.kernel.org, tglx@linutronix.de
Subject: [PATCH -rt 2/5] hotplug: Call cpu_unplug_begin() a little early
Date: Sun, 16 Oct 2011 18:56:44 +0800 [thread overview]
Message-ID: <1318762607-2261-3-git-send-email-yong.zhang0@gmail.com> (raw)
In-Reply-To: <1318762607-2261-1-git-send-email-yong.zhang0@gmail.com>
cpu_unplug_begin() should be called before CPU_DOWN_PREPARE,
because at CPU_DOWN_PREPARE cpu_active is cleared and sched_domain
is rebuilt, it will finally lead to thread 'sync_unplug' will
be running on the cpu on which it's created.
I found by an incorrect warning on smp_processor_id() called by
sync_unplug/1, and trace shows below:
(echo 1 > /sys/device/system/cpu/cpu1/online)
bash-1664 [000] 83.136620: _cpu_down: Bind sync_unplug to cpu 1
bash-1664 [000] 83.136623: sched_wait_task: comm=sync_unplug/1 pid=1724 prio=120
bash-1664 [000] 83.136624: _cpu_down: Wake sync_unplug
bash-1664 [000] 83.136629: sched_wakeup: comm=sync_unplug/1 pid=1724 prio=120 success=1 target_cpu=000
Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
---
kernel/cpu.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 83fb084..13066a3 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -337,22 +337,20 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
return -EBUSY;
}
- err = __cpu_notify(CPU_DOWN_PREPARE | mod, hcpu, -1, &nr_calls);
+ cpu_hotplug_begin();
+ err = cpu_unplug_begin(cpu);
if (err) {
- nr_calls--;
- __cpu_notify(CPU_DOWN_FAILED | mod, hcpu, nr_calls, NULL);
- printk("%s: attempt to take down CPU %u failed\n",
- __func__, cpu);
+ printk("cpu_unplug_begin(%d) failed\n", cpu);
goto out_cancel;
}
- cpu_hotplug_begin();
- err = cpu_unplug_begin(cpu);
+ err = __cpu_notify(CPU_DOWN_PREPARE | mod, hcpu, -1, &nr_calls);
if (err) {
nr_calls--;
__cpu_notify(CPU_DOWN_FAILED | mod, hcpu, nr_calls, NULL);
- printk("cpu_unplug_begin(%d) failed\n", cpu);
- goto out_cancel;
+ printk("%s: attempt to take down CPU %u failed\n",
+ __func__, cpu);
+ goto out_release;
}
err = __stop_machine(take_cpu_down, &tcd_param, cpumask_of(cpu));
--
1.7.1
next prev parent reply other threads:[~2011-10-16 10:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-16 10:56 [RFC] [PATCH -rt 0/5] patchset focusing on cpu hotplug Yong Zhang
2011-10-16 10:56 ` [PATCH -rt 1/5] hotplug: sync_unplug: No '\n' in task name Yong Zhang
2011-10-16 10:56 ` Yong Zhang [this message]
2011-10-16 10:56 ` [RFC] [PATCH -rt 3/5] printk: don't call printk_tick in printk_needs_cpu() Yong Zhang
2011-10-16 10:56 ` [PATCH -rt 4/5] workqueue: hotplug fix Yong Zhang
2011-10-19 7:14 ` Thomas Gleixner
2011-10-24 2:26 ` Yong Zhang
2011-10-24 9:25 ` Thomas Gleixner
2011-10-16 10:56 ` [RFC] [PATCH -rt 5/5] cpufreq: get rid of get_online_cpus()/put_online_cpus() Yong Zhang
2011-10-19 9:12 ` Thomas Gleixner
2011-10-24 2:44 ` Yong Zhang
2011-10-24 9:24 ` Thomas Gleixner
2011-10-24 11:30 ` Yong Zhang
2011-10-24 11:45 ` Thomas Gleixner
2011-10-24 11:56 ` Yong Zhang
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=1318762607-2261-3-git-send-email-yong.zhang0@gmail.com \
--to=yong.zhang0@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).