From: Tang Chen <tangchen@cn.fujitsu.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: miaox@cn.fujitsu.com, wency@cn.fujitsu.com,
linux-kernel@vger.kernel.org, linux-numa@vger.kernel.org,
Tang Chen <tangchen@cn.fujitsu.com>
Subject: [PATCH] Do not use cpu_to_node() to find an offlined cpu's node.
Date: Mon, 8 Oct 2012 10:59:43 +0800 [thread overview]
Message-ID: <1349665183-11718-1-git-send-email-tangchen@cn.fujitsu.com> (raw)
If a cpu is offline, its nid will be set to -1, and cpu_to_node(cpu) will
return -1. As a result, cpumask_of_node(nid) will return NULL. In this case,
find_next_bit() in for_each_cpu will get a NULL pointer and cause panic.
Here is a call trace:
[ 609.824017] Call Trace:
[ 609.824017] <IRQ>
[ 609.824017] [<ffffffff810b0721>] select_fallback_rq+0x71/0x190
[ 609.824017] [<ffffffff810b086e>] ? try_to_wake_up+0x2e/0x2f0
[ 609.824017] [<ffffffff810b0b0b>] try_to_wake_up+0x2cb/0x2f0
[ 609.824017] [<ffffffff8109da08>] ? __run_hrtimer+0x78/0x320
[ 609.824017] [<ffffffff810b0b85>] wake_up_process+0x15/0x20
[ 609.824017] [<ffffffff8109ce62>] hrtimer_wakeup+0x22/0x30
[ 609.824017] [<ffffffff8109da13>] __run_hrtimer+0x83/0x320
[ 609.824017] [<ffffffff8109ce40>] ? update_rmtp+0x80/0x80
[ 609.824017] [<ffffffff8109df56>] hrtimer_interrupt+0x106/0x280
[ 609.824017] [<ffffffff810a72c8>] ? sd_free_ctl_entry+0x68/0x70
[ 609.824017] [<ffffffff8167cf39>] smp_apic_timer_interrupt+0x69/0x99
[ 609.824017] [<ffffffff8167be2f>] apic_timer_interrupt+0x6f/0x80
There is a hrtimer process sleeping, whose cpu has already been offlined.
When it is waken up, it tries to find another cpu to run, and get a -1 nid.
As a result, cpumask_of_node(-1) returns NULL, and causes ernel panic.
This patch fixes this problem by judging if the nid is -1.
If nid is not -1, a cpu on the same node will be picked.
Else, a online cpu on another node will be picked.
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
kernel/sched/core.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 66b36ab..e76dce9 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1263,18 +1263,24 @@ EXPORT_SYMBOL_GPL(kick_process);
*/
static int select_fallback_rq(int cpu, struct task_struct *p)
{
- const struct cpumask *nodemask = cpumask_of_node(cpu_to_node(cpu));
+ int nid = cpu_to_node(cpu);
+ const struct cpumask *nodemask = NULL;
enum { cpuset, possible, fail } state = cpuset;
int dest_cpu;
- /* Look for allowed, online CPU in same node. */
- for_each_cpu(dest_cpu, nodemask) {
- if (!cpu_online(dest_cpu))
- continue;
- if (!cpu_active(dest_cpu))
- continue;
- if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p)))
- return dest_cpu;
+ /* If the cpu has been offlined, its nid was set to -1. */
+ if (nid != -1) {
+ nodemask = cpumask_of_node(nid);
+
+ /* Look for allowed, online CPU in same node. */
+ for_each_cpu(dest_cpu, nodemask) {
+ if (!cpu_online(dest_cpu))
+ continue;
+ if (!cpu_active(dest_cpu))
+ continue;
+ if (cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p)))
+ return dest_cpu;
+ }
}
for (;;) {
--
1.7.1
next reply other threads:[~2012-10-08 3:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-08 2:59 Tang Chen [this message]
2012-10-09 6:21 ` David Rientjes
2012-10-09 8:34 ` Wen Congyang
2012-10-09 8:39 ` Tang Chen
2012-10-09 10:04 ` David Rientjes
2012-10-09 10:22 ` Wen Congyang
2012-10-09 20:00 ` David Rientjes
2012-10-09 10:57 ` Peter Zijlstra
2012-10-09 20:36 ` David Rientjes
2012-10-09 20:47 ` Peter Zijlstra
2012-10-09 23:27 ` David Rientjes
2012-10-10 2:06 ` Wen Congyang
2012-10-10 3:48 ` Wen Congyang
2012-10-10 9:10 ` Peter Zijlstra
2012-10-10 9:33 ` Wen Congyang
2012-10-10 9:51 ` Peter Zijlstra
2012-10-10 10:10 ` Wen Congyang
2012-10-10 10:07 ` Peter Zijlstra
2012-10-10 20:30 ` David Rientjes
2012-10-10 20:37 ` Andrew Morton
2012-10-10 20:57 ` David Rientjes
2012-10-18 0:52 ` David Rientjes
2012-10-18 2:51 ` Tang Chen
2012-10-18 3:29 ` David Rientjes
2012-10-19 11:18 ` Peter Zijlstra
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=1349665183-11718-1-git-send-email-tangchen@cn.fujitsu.com \
--to=tangchen@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-numa@vger.kernel.org \
--cc=miaox@cn.fujitsu.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=wency@cn.fujitsu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®