* [PATCH] sched: fix OOPS when build_sched_domains percpu allocation fails
@ 2012-04-25 11:59 he, bo
2012-04-25 12:20 ` Peter Zijlstra
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: he, bo @ 2012-04-25 11:59 UTC (permalink / raw)
To: akpm, mingo, a.p.zijlstra, rusty, william.douglas, linux-kernel,
a.p.zijlstra, yanmin_zhang
Cc: yanmin.zhang, bo.he
From: "he, bo" <bo.he@intel.com>
Under extreme memory used up situation, percpu allocation
might fails. We hit it when system go to suspend-to-ram.
EIP: [<c124411a>] build_sched_domains+0x23a/0xad0
SS:ESP 0068:de725d04
CR2: 0000000034811000
---[ end trace d6086359b670b975 ]---
Kernel panic - not syncing: Fatal exception
Pid: 3026, comm: kworker/u:3 Tainted: G D W
3.0.8-137473-gf42fbef #1
Call Trace:
[<c18cc4f2>] panic+0x66/0x16c
[<c12521a1>] ? oops_exit+0x61/0x90
[<c1205f89>] oops_end+0xb9/0xd0
[<c1227796>] no_context+0xc6/0x1f0
[<c1227958>] __bad_area_nosemaphore+0x98/0x140
[<c1204ebf>] ? dump_trace+0x7f/0xf0
[<c1227d30>] ? pgtable_bad+0x130/0x130
[<c1227a17>] bad_area_nosemaphore+0x17/0x20
[<c1227fa0>] do_page_fault+0x270/0x3c0
[<c1306afa>] ? pcpu_alloc+0x12ca/0x1300
[<c1227d30>] ? pgtable_bad+0x130/0x130
[<c1227d30>] ? pgtable_bad+0x130/0x130
[<c18d09d3>] error_code+0x5f/0x64
[<c13000d8>] ? shmem_setattr+0x198/0x230
[<c1227d30>] ? pgtable_bad+0x130/0x130
[<c124411a>] ? build_sched_domains+0x23a/0xad0
[<c18d01a6>] ? _raw_spin_unlock_irqrestore+0x26/0x50
[<c1244c37>] partition_sched_domains+0x287/0x4b0
[<c12a77be>] cpuset_update_active_cpus+0x1fe/0x210
[<c1673017>] ? __cpufreq_remove_dev+0x167/0x360
[<c18cf03c>] ? down_write+0x1c/0x40
[<c123712d>] cpuset_cpu_inactive+0x1d/0x30
[<c127dff2>] notifier_call_chain+0x52/0x90
[<c127e04e>] __raw_notifier_call_chain+0x1e/0x30
[<c18b37c9>] _cpu_down+0x89/0x230
[<c12547f9>] disable_nonboot_cpus+0x79/0x100
[<c1299fb3>] suspend_devices_and_enter+0x133/0x2e0
[<c129a27d>] enter_state+0x11d/0x180
[<c129a307>] pm_suspend+0x27/0x70
[<c129b8b6>] suspend+0x96/0x1d0
[<c1271aa3>] process_one_work+0x103/0x400
[<c129b820>] ? power_suspend_late+0x90/0x90
[<c12728ac>] worker_thread+0x12c/0x4b0
[<c123748d>] ? sub_preempt_count+0x3d/0x50
[<c18d01a6>] ? _raw_spin_unlock_irqrestore+0x26/0x50
[<c1272780>] ? manage_workers+0x520/0x520
[<c1276f44>] kthread+0x74/0x80
[<c1276ed0>] ? __init_kthread_worker+0x30/0x30
[<c18d113a>] kernel_thread_helper+0x6/0x10
Signed-off-by: he, bo <bo.he@intel.com>
Reviewed-by: Zhang, Yanmin <yanmin.zhang@intel.com>
---
kernel/sched/core.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4603b9d..0533a68 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6405,16 +6405,26 @@ static void __sdt_free(const struct cpumask *cpu_map)
struct sd_data *sdd = &tl->data;
for_each_cpu(j, cpu_map) {
- struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j);
- if (sd && (sd->flags & SD_OVERLAP))
- free_sched_groups(sd->groups, 0);
- kfree(*per_cpu_ptr(sdd->sd, j));
- kfree(*per_cpu_ptr(sdd->sg, j));
- kfree(*per_cpu_ptr(sdd->sgp, j));
+ struct sched_domain *sd;
+
+ if (sdd->sd) {
+ sd = *per_cpu_ptr(sdd->sd, j);
+ if (sd && (sd->flags & SD_OVERLAP))
+ free_sched_groups(sd->groups, 0);
+ kfree(*per_cpu_ptr(sdd->sd, j));
+ }
+
+ if (sdd->sg)
+ kfree(*per_cpu_ptr(sdd->sg, j));
+ if (sdd->sgp)
+ kfree(*per_cpu_ptr(sdd->sgp, j));
}
free_percpu(sdd->sd);
+ sdd->sd = NULL;
free_percpu(sdd->sg);
+ sdd->sg = NULL;
free_percpu(sdd->sgp);
+ sdd->sgp = NULL;
}
}
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] sched: fix OOPS when build_sched_domains percpu allocation fails
2012-04-25 11:59 [PATCH] sched: fix OOPS when build_sched_domains percpu allocation fails he, bo
@ 2012-04-25 12:20 ` Peter Zijlstra
2012-04-25 12:59 ` Srivatsa S. Bhat
2012-04-26 11:56 ` [tip:sched/urgent] sched: Fix OOPS when build_sched_domains() " tip-bot for he, bo
2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2012-04-25 12:20 UTC (permalink / raw)
To: he, bo
Cc: akpm, mingo, rusty, william.douglas, linux-kernel, yanmin_zhang,
yanmin.zhang
On Wed, 2012-04-25 at 19:59 +0800, he, bo wrote:
> From: "he, bo" <bo.he@intel.com>
>
> Under extreme memory used up situation, percpu allocation
> might fails. We hit it when system go to suspend-to-ram.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sched: fix OOPS when build_sched_domains percpu allocation fails
2012-04-25 11:59 [PATCH] sched: fix OOPS when build_sched_domains percpu allocation fails he, bo
2012-04-25 12:20 ` Peter Zijlstra
@ 2012-04-25 12:59 ` Srivatsa S. Bhat
2012-04-26 11:56 ` [tip:sched/urgent] sched: Fix OOPS when build_sched_domains() " tip-bot for he, bo
2 siblings, 0 replies; 4+ messages in thread
From: Srivatsa S. Bhat @ 2012-04-25 12:59 UTC (permalink / raw)
To: he, bo
Cc: akpm, mingo, a.p.zijlstra, rusty, william.douglas, linux-kernel,
yanmin_zhang, yanmin.zhang
On 04/25/2012 05:29 PM, he, bo wrote:
> From: "he, bo" <bo.he@intel.com>
>
> Under extreme memory used up situation, percpu allocation
> might fails. We hit it when system go to suspend-to-ram.
>
> EIP: [<c124411a>] build_sched_domains+0x23a/0xad0
> SS:ESP 0068:de725d04
> CR2: 0000000034811000
> ---[ end trace d6086359b670b975 ]---
> Kernel panic - not syncing: Fatal exception
> Pid: 3026, comm: kworker/u:3 Tainted: G D W
> 3.0.8-137473-gf42fbef #1
> Call Trace:
> [<c18cc4f2>] panic+0x66/0x16c
> [<c12521a1>] ? oops_exit+0x61/0x90
> [<c1205f89>] oops_end+0xb9/0xd0
> [<c1227796>] no_context+0xc6/0x1f0
> [<c1227958>] __bad_area_nosemaphore+0x98/0x140
> [<c1204ebf>] ? dump_trace+0x7f/0xf0
> [<c1227d30>] ? pgtable_bad+0x130/0x130
> [<c1227a17>] bad_area_nosemaphore+0x17/0x20
> [<c1227fa0>] do_page_fault+0x270/0x3c0
> [<c1306afa>] ? pcpu_alloc+0x12ca/0x1300
> [<c1227d30>] ? pgtable_bad+0x130/0x130
> [<c1227d30>] ? pgtable_bad+0x130/0x130
> [<c18d09d3>] error_code+0x5f/0x64
> [<c13000d8>] ? shmem_setattr+0x198/0x230
> [<c1227d30>] ? pgtable_bad+0x130/0x130
> [<c124411a>] ? build_sched_domains+0x23a/0xad0
> [<c18d01a6>] ? _raw_spin_unlock_irqrestore+0x26/0x50
> [<c1244c37>] partition_sched_domains+0x287/0x4b0
> [<c12a77be>] cpuset_update_active_cpus+0x1fe/0x210
> [<c1673017>] ? __cpufreq_remove_dev+0x167/0x360
> [<c18cf03c>] ? down_write+0x1c/0x40
> [<c123712d>] cpuset_cpu_inactive+0x1d/0x30
> [<c127dff2>] notifier_call_chain+0x52/0x90
> [<c127e04e>] __raw_notifier_call_chain+0x1e/0x30
> [<c18b37c9>] _cpu_down+0x89/0x230
> [<c12547f9>] disable_nonboot_cpus+0x79/0x100
> [<c1299fb3>] suspend_devices_and_enter+0x133/0x2e0
> [<c129a27d>] enter_state+0x11d/0x180
> [<c129a307>] pm_suspend+0x27/0x70
> [<c129b8b6>] suspend+0x96/0x1d0
> [<c1271aa3>] process_one_work+0x103/0x400
> [<c129b820>] ? power_suspend_late+0x90/0x90
> [<c12728ac>] worker_thread+0x12c/0x4b0
> [<c123748d>] ? sub_preempt_count+0x3d/0x50
> [<c18d01a6>] ? _raw_spin_unlock_irqrestore+0x26/0x50
> [<c1272780>] ? manage_workers+0x520/0x520
> [<c1276f44>] kthread+0x74/0x80
> [<c1276ed0>] ? __init_kthread_worker+0x30/0x30
> [<c18d113a>] kernel_thread_helper+0x6/0x10
>
> Signed-off-by: he, bo <bo.he@intel.com>
> Reviewed-by: Zhang, Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Regards,
Srivatsa S. Bhat
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:sched/urgent] sched: Fix OOPS when build_sched_domains() percpu allocation fails
2012-04-25 11:59 [PATCH] sched: fix OOPS when build_sched_domains percpu allocation fails he, bo
2012-04-25 12:20 ` Peter Zijlstra
2012-04-25 12:59 ` Srivatsa S. Bhat
@ 2012-04-26 11:56 ` tip-bot for he, bo
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for he, bo @ 2012-04-26 11:56 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, torvalds, a.p.zijlstra, srivatsa.bhat,
akpm, stable, bo.he, yanmin.zhang, tglx
Commit-ID: fb2cf2c660971bea0ad86a9a5c19ad39eab61344
Gitweb: http://git.kernel.org/tip/fb2cf2c660971bea0ad86a9a5c19ad39eab61344
Author: he, bo <bo.he@intel.com>
AuthorDate: Wed, 25 Apr 2012 19:59:21 +0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 26 Apr 2012 12:54:53 +0200
sched: Fix OOPS when build_sched_domains() percpu allocation fails
Under extreme memory used up situations, percpu allocation
might fail. We hit it when system goes to suspend-to-ram,
causing a kworker panic:
EIP: [<c124411a>] build_sched_domains+0x23a/0xad0
Kernel panic - not syncing: Fatal exception
Pid: 3026, comm: kworker/u:3
3.0.8-137473-gf42fbef #1
Call Trace:
[<c18cc4f2>] panic+0x66/0x16c
[...]
[<c1244c37>] partition_sched_domains+0x287/0x4b0
[<c12a77be>] cpuset_update_active_cpus+0x1fe/0x210
[<c123712d>] cpuset_cpu_inactive+0x1d/0x30
[...]
With this fix applied build_sched_domains() will return -ENOMEM and
the suspend attempt fails.
Signed-off-by: he, bo <bo.he@intel.com>
Reviewed-by: Zhang, Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: <stable@kernel.org>
Link: http://lkml.kernel.org/r/1335355161.5892.17.camel@hebo
[ So, we fail to deallocate a CPU because we cannot allocate RAM :-/
I don't like that kind of sad behavior but nevertheless it should
not crash under high memory load. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/core.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4603b9d..0533a68 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6405,16 +6405,26 @@ static void __sdt_free(const struct cpumask *cpu_map)
struct sd_data *sdd = &tl->data;
for_each_cpu(j, cpu_map) {
- struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j);
- if (sd && (sd->flags & SD_OVERLAP))
- free_sched_groups(sd->groups, 0);
- kfree(*per_cpu_ptr(sdd->sd, j));
- kfree(*per_cpu_ptr(sdd->sg, j));
- kfree(*per_cpu_ptr(sdd->sgp, j));
+ struct sched_domain *sd;
+
+ if (sdd->sd) {
+ sd = *per_cpu_ptr(sdd->sd, j);
+ if (sd && (sd->flags & SD_OVERLAP))
+ free_sched_groups(sd->groups, 0);
+ kfree(*per_cpu_ptr(sdd->sd, j));
+ }
+
+ if (sdd->sg)
+ kfree(*per_cpu_ptr(sdd->sg, j));
+ if (sdd->sgp)
+ kfree(*per_cpu_ptr(sdd->sgp, j));
}
free_percpu(sdd->sd);
+ sdd->sd = NULL;
free_percpu(sdd->sg);
+ sdd->sg = NULL;
free_percpu(sdd->sgp);
+ sdd->sgp = NULL;
}
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-26 11:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-25 11:59 [PATCH] sched: fix OOPS when build_sched_domains percpu allocation fails he, bo
2012-04-25 12:20 ` Peter Zijlstra
2012-04-25 12:59 ` Srivatsa S. Bhat
2012-04-26 11:56 ` [tip:sched/urgent] sched: Fix OOPS when build_sched_domains() " tip-bot for he, bo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox